$LONGSERVICEOUTPUT$ replacing newlines in emails

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
xparrot
Posts: 3
Joined: Thu Jul 12, 2012 1:16 pm

$LONGSERVICEOUTPUT$ replacing newlines in emails

Post by xparrot »

I created a custom plugin that returns multiple lines of output. I set up my email template to use the $LONGSERVICEOUTPUT$ to output the 2nd through n lines of output. But when the output is sent via an email alert, the email contains one big string of text with the newlines converted to "\n" characters and no actual line breaks.

Is this a setting that I can turn off, or is there some way I can format it so my email will contain actual line breaks? The nagios web interface displays the data as expected including the line breaks. I've tried outputing both "\n" and "\r\n" for the line breaks from the python script but this makes no difference -- The email never contains line breaks.

We're running version 2011R2.2.

Thanks
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: $LONGSERVICEOUTPUT$ replacing newlines in emails

Post by scottwilkerson »

Because the default is to send HTML emails you could just wrap your output for this in a <pre> tag.

for example

Code: Select all

...
<pre>Output: $LONGSERVICEOUTPUT$</pre>
Alternately you could output the HTML replacing \n with <br> in the plugin
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
xparrot
Posts: 3
Joined: Thu Jul 12, 2012 1:16 pm

Re: $LONGSERVICEOUTPUT$ replacing newlines in emails

Post by xparrot »

Thanks for the quick response. The <pre> tag did not work, but the <br> tags did work after I removed the the greater and and less than signs from the illegal_macro_output_chars setting in nagios.cfg. However, now in the nagios web interface I see the <br> tags on the screen. I guess I can live with this unless you know of an easy way to fix that as well.
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: $LONGSERVICEOUTPUT$ replacing newlines in emails

Post by scottwilkerson »

I do have a fix for that one... I think...

Go to
Admin -> Manage System Config
Check the box "Allow HTML Tags in Host/Service Status"
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
xparrot
Posts: 3
Joined: Thu Jul 12, 2012 1:16 pm

Re: $LONGSERVICEOUTPUT$ replacing newlines in emails

Post by xparrot »

The "Allow HTML Tags" setting worked perfectly. Thank you so much Scott!
Locked