empty lines in plug-in output

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
[email protected]
Posts: 1
Joined: Mon Jun 13, 2016 11:22 am

empty lines in plug-in output

Post by [email protected] »

Hi all,

I recently moved from Nagios 3 to 4 and the first thing I noticed was that empty lines are translated to "\n".

So this test plugin

Code: Select all

#!/bin/sh
echo TEST
echo line 1
echo line 2
echo
echo line 4
exit 0
produces this output

Code: Select all

TEST
line 1
line 2
\nline 4
I couldn't find anything online about this behaviour. Is this a bug or a feature and if the latter can it be turned off?

Thanks,
Eli
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: empty lines in plug-in output

Post by rkennedy »

I spoke with one of our developers, and he informed me that it shouldn't be converting a new line to \n. Could you file an issue for this on our GitHub? https://github.com/NagiosEnterprises/nagioscore/issues
Former Nagios Employee
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: empty lines in plug-in output

Post by tmcdonald »

Confirmed on 4.1.1
Former Nagios employee
User avatar
eloyd
Cool Title Here
Posts: 2190
Joined: Thu Sep 27, 2012 9:14 am
Location: Rochester, NY
Contact:

Re: empty lines in plug-in output

Post by eloyd »

I'm slow today. Can someone tell me how this matters? I thought plugins should only be outputting one line anyway?
Image
Eric Loyd • http://everwatch.global • 844.240.EVER • @EricLoyd
I'm a Nagios Fanatic! • Join our public Nagios Discord Server!
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: empty lines in plug-in output

Post by tmcdonald »

Should, but it is not required:
Starting with version 3, Nagios will process plugins' multiline output, which should be formatted as:

SERVICE STATUS: First line of output | First part of performance data
Any number of subsequent lines of output, but note that buffers
may have a limited size | Second part of performance data, which
may have continuation lines, too
https://nagios-plugins.org/doc/guidelines.html#AEN33

I can think of good reasons why multi-line output might be needed (multiple disk/mount checks in one service (ugly but sometimes desired), event logs that return the log contents, a service which writes out the lyrics to Another Brick In The Wall, etc.) but in general I agree with the one-line thing. The issue here is that it appears to be showing a literal \n as two characters, instead of converting to <br />[/icode for display] or something. I vaguely recall an option to define this behavior, but I might be thinking of the CGI config option to allow HTML tags.

At any rate, C dev confirm buggy behavior so it'll be addressed. If we don't hear from OP I'll be filing this on their behalf.
Former Nagios employee
User avatar
eloyd
Cool Title Here
Posts: 2190
Joined: Thu Sep 27, 2012 9:14 am
Location: Rochester, NY
Contact:

Re: empty lines in plug-in output

Post by eloyd »

Thanks. I'll have to go look at that. I'm especially interested in seeing what happens with multi-line perf data.
Image
Eric Loyd • http://everwatch.global • 844.240.EVER • @EricLoyd
I'm a Nagios Fanatic! • Join our public Nagios Discord Server!
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: empty lines in plug-in output

Post by tmcdonald »

I'll get this filed tomorrow, and update accordingly!

Update: Ran into some more pressing matters, but it looks like someone beat me to it: https://github.com/NagiosEnterprises/na ... issues/137
Former Nagios employee
Locked