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"
Upgraded to Nagios XI 2014R2.0: newline problem
-
sreinhardt
- -fno-stack-protector
- Posts: 4366
- Joined: Mon Nov 19, 2012 12:10 pm
Re: Upgraded to Nagios XI 2014R2.0: newline problem
You got it! Most languages intended for real string processing will do that straight away, bash not so much.
Nagios-Plugins maintainer exclusively, unless you have other C language bugs with open-source nagios projects, then I am happy to help! Please pm or use other communication to alert me to issues as I no longer track the forum.
-
Ton Verstegen
- Posts: 8
- Joined: Thu Jul 26, 2012 8:10 am
Re: Upgraded to Nagios XI 2014R2.0: newline problem
Oh yeah! That works for me, thankssreinhardt wrote:You got it! Most languages intended for real string processing will do that straight away, bash not so much.
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.
-
sreinhardt
- -fno-stack-protector
- Posts: 4366
- Joined: Mon Nov 19, 2012 12:10 pm
Re: Upgraded to Nagios XI 2014R2.0: newline problem
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.
Nagios-Plugins maintainer exclusively, unless you have other C language bugs with open-source nagios projects, then I am happy to help! Please pm or use other communication to alert me to issues as I no longer track the forum.