Patch for Plugin "No Output"

Andreas Ericsson ae at op5.se
Wed Oct 25 10:45:13 CEST 2006


bobi at netshel.net 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                   andreas.ericsson at op5.se
OP5 AB                             www.op5.se
Tel: +46 8-230225                  Fax: +46 8-230231

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642




More information about the Developers mailing list