Page 1 of 1

$LONGSERVICEOUTPUT$ replacing newlines in emails

Posted: Thu Jul 12, 2012 2:18 pm
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

Re: $LONGSERVICEOUTPUT$ replacing newlines in emails

Posted: Thu Jul 12, 2012 3:36 pm
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

Re: $LONGSERVICEOUTPUT$ replacing newlines in emails

Posted: Thu Jul 12, 2012 4:12 pm
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.

Re: $LONGSERVICEOUTPUT$ replacing newlines in emails

Posted: Thu Jul 12, 2012 4:45 pm
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"

Re: $LONGSERVICEOUTPUT$ replacing newlines in emails

Posted: Fri Jul 13, 2012 12:43 pm
by xparrot
The "Allow HTML Tags" setting worked perfectly. Thank you so much Scott!