summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: a079822)
raw | patch | inline | side by side (parent: a079822)
author | Harper Mann <harpermann@users.sourceforge.net> | |
Wed, 30 Nov 2005 00:49:47 +0000 (00:49 +0000) | ||
committer | Harper Mann <harpermann@users.sourceforge.net> | |
Wed, 30 Nov 2005 00:49:47 +0000 (00:49 +0000) |
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".
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1291 f882894a-f735-0410-b71e-b25c423dba1c
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1291 f882894a-f735-0410-b71e-b25c423dba1c
plugins-scripts/check_ntp.pl | patch | blob | history |
index e844327b226ebb215f3a08e5999c48d1513974bd..d4175f64da8a5361f44d388034ecf0e6feefa8fe 100755 (executable)
#!/usr/bin/perl -w
-
+#
# (c)1999 Ian Cass, Knowledge Matters Ltd.
# Read the GNU copyright stuff for all the legalese
#
###
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;
}
}
+$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 ) {
}
}
- 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