HTML Tags not parsing correctly in newer Nagios Install

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
mmartin
Posts: 45
Joined: Fri Jul 15, 2011 12:45 pm

HTML Tags not parsing correctly in newer Nagios Install

Post by mmartin »

Hello All,

We have recently upgraded our Nagios Core software from:
OLD Version: Nagios Core 3.2.3
NEW Version: Nagios Core 3.5.1
I have this one service check that sends some HTML Tags in its command output like bold tags <b>, italics <i>, underline <u>, line-breaks <br>, etc... Now in the old version these were parsed as is and when viewing the output from the All Services page in Nagios, it would use those tags that I pass. But now it seems like the new Nagios install parses the output differently now, to where it changes the tags to its 'coded' equivalent... For example "<b>" becomes "<b>" in the newer version.

Here is an example:
OUTPUT SENT:

Code: Select all

"<b>CRITICAL:</b> There are Files in '/path/to-a/directory' above the Critical Level of (1.5 GB).<table CLASS='DirStyle'><tr><td CLASS='DirStatus'>- CRITICAL</td><td>FILE.NAME</td><td CLASS='DirSize'>1.64 GB</td></tr></table>"
OLD Nagios, Source of Services Page:

Code: Select all

<b>CRITICAL:</b> There are Files in '/path/to-a/directory' above the Critical Level of (1.5 GB).<table CLASS='DirStyle'><tr><td CLASS='DirStatus'>- CRITICAL</td><td>FILE.NAME</td><td CLASS='DirSize'>1.64 GB</td></tr></table>
NEW Nagios, Source of Services Page:

Code: Select all

<b>CRITICAL:</b> There are Files in '/path/to-a/directory' above the Critical Level of (1.5 GB).<table CLASS='DirStyle'><tr><td CLASS='DirStatus'>- CRITICAL</td><td>PROS.CONT</td><td CLASS='DirSize'>1.64 GB</td></tr></table>
On the NEW Nagios install when you are viewing the All Services page, it shows "<b>" instead of "<b>" unlike when viewing the Source when it does show "<b>" instead...

Any idea if something changed in this new version? And is there anyway to get these HTML tags parsed like they used to be..?
Any thoughts or suggestions would be much appreciated!

Thanks in Advance,
Matt
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: HTML Tags not parsing correctly in newer Nagios Install

Post by tmcdonald »

/usr/local/nagios/etc/cgi.cfg

Code: Select all

escape_html_tags=1
change to 0 and restart nagios.
Former Nagios employee
mmartin
Posts: 45
Joined: Fri Jul 15, 2011 12:45 pm

Re: HTML Tags not parsing correctly in newer Nagios Install

Post by mmartin »

Hey tmcdonald, thanks for the reply!!

Excellent..!!! That did it.
You just saved me probably a few hours of re-compiling nagios and editing the status.c file, thanks so much!

I'm pretty sure this is the line in the status.c file below (*"status.cgi" after compiling) which swaps out certain HTML specific symbols to its coded equivalent...
Before your reply I was going to edit this line and remove the function --> "encode_html()" from the printf statement.

Code: Select all

	/* the rest of the columns... */
	printf("<td class='status%s'>%s</td>\n", status_class, status);
	printf("<td class='status%s' nowrap>%s</td>\n", status_bg_class, date_time);
	printf("<td class='status%s' nowrap>%s</td>\n", status_bg_class, state_duration);
	printf("<td class='status%s'>%d/%d</td>\n", status_bg_class, temp_status->current_attempt, temp_status->max_attempts);
	printf("<td class='status%s' valign='center'>", status_bg_class);
        ######################## THIS LINE HERE ########################
	printf("%s ", (temp_status->plugin_output == NULL) ? "" : html_encode(temp_status->plugin_output, TRUE));
        ################################################################
So again, thanks soo much for the reply, I can't believe I missed that option in the cgi.cfg config file...!

Thanks Again,
Matt
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: HTML Tags not parsing correctly in newer Nagios Install

Post by tmcdonald »

You're quite welcome. Believe me, having recompiled quite a few packages in my time for similar reasons it is *always* best to check the configs and documentation first if you are unsure of a feature. The next step after checking the configs and documentation is to check the configs and documentation again. After that, it's probably safe to go ahead and read them again. Aaaaaand then work on recompiling.

I'll be closing this thread now, but feel free to open another if you need anything in the future!
Former Nagios employee
Locked