summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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 e844327..d4175f6 100755
--- a/plugins-scripts/check_ntp.pl
+++ b/plugins-scripts/check_ntp.pl
@@ -1,5 +1,5 @@
1#!/usr/bin/perl -w 1#!/usr/bin/perl -w
2 2#
3# (c)1999 Ian Cass, Knowledge Matters Ltd. 3# (c)1999 Ian Cass, Knowledge Matters Ltd.
4# Read the GNU copyright stuff for all the legalese 4# Read the GNU copyright stuff for all the legalese
5# 5#
@@ -200,13 +200,15 @@ elsif ($ipv6) {
200### 200###
201 201
202if (!open (NTPDATE, $ntpdate . " -q $host 2>&1 |")) { 202if (!open (NTPDATE, $ntpdate . " -q $host 2>&1 |")) {
203 print "Could not open ntpdate\n"; 203 print "Could not open $ntpdate: $!\n";
204 exit $ERRORS{"UNKNOWN"}; 204 exit $ERRORS{"UNKNOWN"};
205} 205}
206 206
207my $out;
207while (<NTPDATE>) { 208while (<NTPDATE>) {
208 #print if ($verbose); # noop 209 #print if ($verbose); # noop
209 $msg = $_ unless ($msg); 210 $msg = $_ unless ($msg);
211 $out .= "$_ ";
210 212
211 if (/stratum\s(\d+)/) { 213 if (/stratum\s(\d+)/) {
212 $stratum = $1; 214 $stratum = $1;
@@ -241,8 +243,11 @@ while (<NTPDATE>) {
241 } 243 }
242 244
243} 245}
246$out =~ s/\n//g;
247close (NTPDATE) ||
248 die $! ? "$out - Error closing $ntpdate pipe: $!"
249 : "$out - Exit status: $? from $ntpdate\n";
244 250
245close (NTPDATE);
246# declare an error if we also get a non-zero return code from ntpdate 251# declare an error if we also get a non-zero return code from ntpdate
247# unless already set to critical 252# unless already set to critical
248if ( $? && !$ignoreret ) { 253if ( $? && !$ignoreret ) {
@@ -313,7 +318,9 @@ if ($have_ntpq) {
313 } 318 }
314 319
315 } 320 }
316 close NTPQ; 321 close NTPQ ||
322 die $! ? "Error closing $ntpq pipe: $!"
323 : "Exit status: $? from $ntpq\n";
317 324
318 # if we did not match sys.peer or pps.peer but matched # candidates only 325 # if we did not match sys.peer or pps.peer but matched # candidates only
319 # generate a warning 326 # generate a warning