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
$LONGSERVICEOUTPUT$ replacing newlines in emails
-
scottwilkerson
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: $LONGSERVICEOUTPUT$ replacing newlines in emails
Because the default is to send HTML emails you could just wrap your output for this in a <pre> tag.
for example
Alternately you could output the HTML replacing \n with <br> in the plugin
for example
Code: Select all
...
<pre>Output: $LONGSERVICEOUTPUT$</pre>Re: $LONGSERVICEOUTPUT$ replacing newlines in emails
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
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"
Go to
Admin -> Manage System Config
Check the box "Allow HTML Tags in Host/Service Status"
Re: $LONGSERVICEOUTPUT$ replacing newlines in emails
The "Allow HTML Tags" setting worked perfectly. Thank you so much Scott!