Re: [Nagios-devel] Patch for Plugin "No 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
Guest

Re: [Nagios-devel] Patch for Plugin "No Output"

Post by Guest »

[email protected] wrote:
> Hi All,
>
> Like everyone else, we've had our fair share of mysterious plugin "(No
> output!)" messages.
>
> Sometimes this error is due to the plugin failing and only writing
> diagnostics to stderr (and nothing is written to stdout.)
>
> Also, as everyone knows, Nagios only reads the first line of
> newline-terminated output from a plugin and throws the rest away. But,
> what if the first line is just a new-line and the good stuff is on a
> subsequent line?
>
> Yes, I know - fix your plugin to output only to the first line.
>
> But being a lazy programmer, I am thinking, why not just have Nagios be a
> little more forgiving and inquisitive and keep searching stdout until it
> finds the first non-empty line? Is that so bad? Or is it a feature?
>

It's a feature. Nice patch, btw, but I've got a couple of issues with
it, detailed below.

> Well, you can be the judge.
>
> Anyway, I put together this patch for checks.c - it modifies the plugin
> output handling logic in the following manner:
>
> 1. As usual, it reads plugin output from stdout.
>
> However, if the first line is empty, it keeps reading until it gets a
> non-empty line or EOF.
>
> If it gets a non-empty line, then that first non-empty line becomes the
> plugin output.
>
> 2. However, if it really gets no output from stdout (i.e., nothing or all
> empty lines,) then it reads the plugin's stderr and returns the first
> non-empty line it finds.
>

It would be nice if it could tell that this output comes from stderr
instead of just printing it out. That's a minor point though and I'm
sure it doesn't make any real difference anywhere.

>
> Anyway, I'd be very interested in any alternate suggestions, good
> comments, insightful observations or even witty reparte'.
>
> BTW, in order to provide the ability to read both stdout and stderr from a
> plugin sub-process, I've written my own version of the standard C popen(3)
> function called pfopen(). I did this because this is the problem with the
> standard popen(3) function - it only return stdout to the parent process,
> which may only give you half the story since it ignores all potentially
> usefull diagnostic info from the stderr of the child process.
>

True that. The plugins have something similar, called runcmd which
executes and fetches all output on both stderr and stdout of the command
being run.

All in all, nice patch :)

--
Andreas Ericsson [email protected]
OP5 AB www.op5.se
Tel: +46 8-230225 Fax: +46 8-230231





This post was automatically imported from historical nagios-devel mailing list archives
Original poster: [email protected]
Locked