aboutsummaryrefslogtreecommitdiff
path: root/plugins-scripts/check_ntp.pl
diff options
context:
space:
mode:
authorGravatar Harper Mann <harpermann@users.sourceforge.net> 2005-11-30 00:49:47 +0000
committerGravatar Harper Mann <harpermann@users.sourceforge.net> 2005-11-30 00:49:47 +0000
commite5b45d0e143bd3dbfb870cbe9fd33977db1a2b19 (patch)
treec5ff93e7a2e329f934431089b8af9d13500b0535 /plugins-scripts/check_ntp.pl
parenta0798228587ee211dfec887f88b25c55ddd16ecb (diff)
downloadmonitoring-plugins-e5b45d0e143bd3dbfb870cbe9fd33977db1a2b19.tar.gz
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". git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1291 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins-scripts/check_ntp.pl')
-rwxr-xr-xplugins-scripts/check_ntp.pl15
1 files changed, 11 insertions, 4 deletions
diff --git a/plugins-scripts/check_ntp.pl b/plugins-scripts/check_ntp.pl
index e844327b..d4175f64 100755
--- a/plugins-scripts/check_ntp.pl
+++ b/plugins-scripts/check_ntp.pl
@@ -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 @@ elsif ($ipv6) {
###
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 @@ while (<NTPDATE>) {
}
}
+$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 @@ if ($have_ntpq) {
}
}
- 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