Patch for Plugin "No Output"

bobi at netshel.net bobi at netshel.net
Wed Oct 25 00:08:18 CEST 2006


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?

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.

3. If it gets nothing from stderr as well, then it finally returns
everyone's favorite diagnostic: "(No output!)"

You know, we should really change that diagnostic to: "(No output!  Have a
nice day!)"


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.

If you use the patch, then pfopen.c should be added to the "base"
directory and pfopen.h should be added to the "include" directory.  Both
patch files (for "Makefile.in" and "checks.c",) are applied to those file
in the "base" directory.



Regards,
Bob Ingraham
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: checks.c.diff
URL: <https://www.monitoring-lists.org/archive/developers/attachments/20061024/5b36839e/attachment.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: Makefile.in.diff
URL: <https://www.monitoring-lists.org/archive/developers/attachments/20061024/5b36839e/attachment-0001.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: pfopen.c
URL: <https://www.monitoring-lists.org/archive/developers/attachments/20061024/5b36839e/attachment.c>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: pfopen.h
URL: <https://www.monitoring-lists.org/archive/developers/attachments/20061024/5b36839e/attachment.h>
-------------- next part --------------
-------------------------------------------------------------------------
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
-------------- next part --------------
_______________________________________________
Nagios-devel mailing list
Nagios-devel at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-devel


More information about the Developers mailing list