Page 2 of 2

Re: Upgraded to Nagios XI 2014R2.0: newline problem

Posted: Tue Jan 06, 2015 2:18 pm
by jwelch
Ah, now that makes sense. In perl, the comand:
print "sum|x=1\nThis is line1\nThis is line2\nThis is line3\n"
will produce multiline output.
Perl will change the occurrences of "\n" to newline characters,
but bash won't by default. Some of the plugin output parsing was
re-written in 4.0x so most likely that's why it broke your scripts
after the XI update.

I had to look at the man page for echo to see what the -e parameter that
sreinhardt suggested would do. That will probably work for you.

"-e enable interpretation of backslash escapes"

Re: Upgraded to Nagios XI 2014R2.0: newline problem

Posted: Tue Jan 06, 2015 3:51 pm
by sreinhardt
You got it! Most languages intended for real string processing will do that straight away, bash not so much.

Re: Upgraded to Nagios XI 2014R2.0: newline problem

Posted: Wed Jan 07, 2015 8:17 am
by Ton Verstegen
sreinhardt wrote:You got it! Most languages intended for real string processing will do that straight away, bash not so much.
Oh yeah! That works for me, thanks 8-)
Didnt know this about bash and the -e option.

Now I wonder how its possible that it was formatted ok before. Why did the behaviour change by the Nagios-upgrade?
I don't understand ...

Thnx for helping here.

Ton
ps. I also like jwelch's remark about using <pre>..</pre>. Thnx.

Re: Upgraded to Nagios XI 2014R2.0: newline problem

Posted: Wed Jan 07, 2015 5:12 pm
by sreinhardt
Honestly, I'm not 100% sure when it would have changed to cause this. However there was a previous bug that effected newlines in status output that could be somewhat related, however that was patched to return to the core 3.5 functionality, so it wouldn't quite seem to fit. If core 3.5 was replacing \n with actual newlines, I hate to say it, but I would consider that the bug, as core should not really be modifying data fed to it.