[Nagiosplug-checkins] nagiosplug/plugins-scripts check_ntp.pl,1.30,1.31
Harper Mann
harpermann at users.sourceforge.net
Tue Nov 29 16:51:03 CET 2005
Update of /cvsroot/nagiosplug/nagiosplug/plugins-scripts
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17166
Modified Files:
check_ntp.pl
Log Message:
Nagiosplug bug # 1251096
check_ntp wasn't properly handing a bad exit status from the external programs it calls (ntpdate and ntpq), so jitter wasn't set. Added check of $? on close and proper error output if status from the sub program call completion is non-zero. This includes "host not found".
Index: check_ntp.pl
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins-scripts/check_ntp.pl,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -d -r1.30 -r1.31
--- check_ntp.pl 13 Oct 2005 10:20:50 -0000 1.30
+++ check_ntp.pl 30 Nov 2005 00:49:47 -0000 1.31
@@ -1,5 +1,5 @@
#!/usr/bin/perl -w
-
+#
# (c)1999 Ian Cass, Knowledge Matters Ltd.
# Read the GNU copyright stuff for all the legalese
#
@@ -200,13 +200,15 @@
###
if (!open (NTPDATE, $ntpdate . " -q $host 2>&1 |")) {
- print "Could not open ntpdate\n";
+ print "Could not open $ntpdate: $!\n";
exit $ERRORS{"UNKNOWN"};
}
+my $out;
while (<NTPDATE>) {
#print if ($verbose); # noop
$msg = $_ unless ($msg);
+ $out .= "$_ ";
if (/stratum\s(\d+)/) {
$stratum = $1;
@@ -241,8 +243,11 @@
}
}
+$out =~ s/\n//g;
+close (NTPDATE) ||
+ die $! ? "$out - Error closing $ntpdate pipe: $!"
+ : "$out - Exit status: $? from $ntpdate\n";
-close (NTPDATE);
# declare an error if we also get a non-zero return code from ntpdate
# unless already set to critical
if ( $? && !$ignoreret ) {
@@ -313,7 +318,9 @@
}
}
- close NTPQ;
+ close NTPQ ||
+ die $! ? "Error closing $ntpq pipe: $!"
+ : "Exit status: $? from $ntpq\n";
# if we did not match sys.peer or pps.peer but matched # candidates only
# generate a warning
More information about the Commits
mailing list