summaryrefslogtreecommitdiffstats
path: root/plugins-scripts
diff options
context:
space:
mode:
Diffstat (limited to 'plugins-scripts')
-rwxr-xr-xplugins-scripts/check_ntp.pl41
1 files changed, 36 insertions, 5 deletions
diff --git a/plugins-scripts/check_ntp.pl b/plugins-scripts/check_ntp.pl
index 10079b6..0546761 100755
--- a/plugins-scripts/check_ntp.pl
+++ b/plugins-scripts/check_ntp.pl
@@ -154,7 +154,8 @@ my $answer = undef;
154my $offset = undef; 154my $offset = undef;
155my $jitter = undef; 155my $jitter = undef;
156my $syspeer = undef; 156my $syspeer = undef;
157my $candidates = 0; 157my $candidate = 0;
158my @candidates;
158my $msg; # first line of output to print if format is invalid 159my $msg; # first line of output to print if format is invalid
159 160
160my $state = $ERRORS{'UNKNOWN'}; 161my $state = $ERRORS{'UNKNOWN'};
@@ -252,6 +253,9 @@ if ( $? && !$ignoreret ) {
252# Field 10: offset 253# Field 10: offset
253# Field 11: dispersion/jitter 254# Field 11: dispersion/jitter
254# 255#
256# According to bug 773588 Some solaris xntpd implementations seemto match on
257# "#" even though the docs say it exceeds maximum distance. Providing patch
258# here which will generate a warining.
255 259
256if ($have_ntpq) { 260if ($have_ntpq) {
257 261
@@ -264,12 +268,13 @@ if ($have_ntpq) {
264 } 268 }
265 # number of candidates on <host> for sys.peer 269 # number of candidates on <host> for sys.peer
266 if (/^(\*|\+|\#|o])/) { 270 if (/^(\*|\+|\#|o])/) {
267 ++$candidates; 271 ++$candidate;
268 print "Candiate count= $candidates\n" if ($verbose); 272 push (@candidates, $_);
273 print "Candiate count= $candidate\n" if ($verbose);
269 } 274 }
270 275
271 # match sys.peer or pps.peer 276 # match sys.peer or pps.peer
272 if (/^(\*|o)([-0-9.\s]+)\s+([-0-9A-Za-z.]+)\s+([-0-9.]+)\s+([lumb]+)\s+([-0-9m.]+)\s+([-0-9.]+)\s+([-0-9.]+)\s+([-0-9.]+)\s+([-0-9.]+)\s+([-0-9.]+)/) { 277 if (/^(\*|o)([-0-9.\s]+)\s+([-0-9A-Za-z.]+)\s+([-0-9.]+)\s+([lumb-]+)\s+([-0-9m.]+)\s+([-0-9.]+)\s+([-0-9.]+)\s+([-0-9.]+)\s+([-0-9.]+)\s+([-0-9.]+)/) {
273 $syspeer = $2; 278 $syspeer = $2;
274 $stratum = $4; 279 $stratum = $4;
275 $jitter = $11; 280 $jitter = $11;
@@ -284,8 +289,34 @@ if ($have_ntpq) {
284 $jitter_error = $ERRORS{'OK'}; 289 $jitter_error = $ERRORS{'OK'};
285 } 290 }
286 } 291 }
292
287 } 293 }
288 close NTPQ; 294 close NTPQ;
295
296 # if we did not match sys.peer or pps.peer but matched # candidates only
297 # generate a warning
298 # based on bug id 773588
299 unless (defined $syspeer) {
300 if ($#candidates >0) {
301 foreach my $c (@candidates) {
302 $c =~ /^(#)([-0-9.\s]+)\s+([-0-9A-Za-z.]+)\s+([-0-9.]+)\s+([lumb-]+)\s+([-0-9m.]+)\s+([-0-9.]+)\s+([-0-9.]+)\s+([-0-9.]+)\s+([-0-9.]+)\s+([-0-9.]+)/;
303 $syspeer = $2;
304 $stratum = $4;
305 $jitter = $11;
306 print "candidate match $c \n" if $verbose;
307 if ($jitter > $jcrit) {
308 print "Candidate match - Jitter_crit = $11 :$jcrit\n" if ($verbose);
309 $jitter_error = $ERRORS{'CRITICAL'};
310 }elsif ($jitter > $jwarn ) {
311 print "Candidate match - Jitter_warn = $11 :$jwarn \n" if ($verbose);
312 $jitter_error = $ERRORS{'WARNING'};
313 } else {
314 $jitter_error = $ERRORS{'WARNING'};
315 }
316 }
317
318 }
319 }
289 } 320 }
290} 321}
291 322