[Nagios-devel] Bugfix: Parsing of Long Plugin Output for Async Host Checks

Jochen Bern Jochen.Bern at LINworks.de
Fri Dec 3 19:56:12 UTC 2010


Async host check results get parsed differently from sync host and
service check results:

# grep -n parse_check_output nagios-3.2.3/*/*.c
nagios-3.2.3/base/checks.c:1024: parse_check_output(...,TRUE,TRUE);
nagios-3.2.3/base/checks.c:2730: parse_check_output(...,TRUE,TRUE);
nagios-3.2.3/base/checks.c:3313: parse_check_output(...,FALSE,TRUE);
nagios-3.2.3/base/utils.c:2685:int parse_check_output(..., int
escape_newlines_please, int newlines_are_escaped){

In 3.2.3, this causes the long output to be stored in the status.dat
with *actual* line breaks, while the same plugin output fed into a
service check has its line breaks changed to "\n":

# ../libexec/check_icmp_plus -H 127.0.0.1
OK - 127.0.0.1: rta 0,039ms, lost 0%|rta=0,039ms;200,000;500,000;0;
pl=0%;40;80;; rtmax=0,078ms;;;; rtmin=0,028ms;;;;
Long Output Zeile 1
Long Output Zeile 2

# grep 'Long Output' ../var/spool/status.dat
        long_plugin_output=Long Output Zeile 1
Long Output Zeile 2
        long_plugin_output=Long Output Zeile 1\nLong Output Zeile 2\n

extinfo.cgi, in turn, would read long_plugin_output= only up to the
first line break, thus missing the subsequent lines of the long output
entirely. (I'm also under the impression that restarting Nagios caused
the orphaned second line to simply *vanish* from status.dat until the
next check, but I didn't doublecheck.)

Note that in 3.2.2 and earlier, an independent bug in utils.c::2833
> http://nagios.cvs.sourceforge.net/viewvc/nagios/nagios/base/utils.c?r1=1.249&r2=1.250
prevented the parameter value from actually taking effect.

Simply changing the parameters to (...,TRUE,TRUE) fixes this.

Kind regards,
								J. Bern
-- 
Jochen Bern, Systemingenieur --- LINworks GmbH <http://www.LINworks.de/>
Postfach 100121, 64201 Darmstadt | Robert-Koch-Str. 9, 64331 Weiterstadt
PGP (1024D/4096g) FP = D18B 41B1 16C0 11BA 7F8C DCF7 E1D5 FAF4 444E 1C27
Tel. +49 6151 9067-231, Zentr. -0, Fax -299 - Amtsg. Darmstadt HRB 85202
Unternehmenssitz Weiterstadt, Geschäftsführer Metin Dogan, Oliver Michel
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: nagios-3.2.3-HostCheckParseFix-patch.txt
URL: <http://lists.nagios.com/pipermail/nagios-devel/attachments/20101203/319cd5c8/attachment.txt>


More information about the Nagios-devel mailing list