summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xplugins-scripts/check_ntp.pl33
1 files changed, 18 insertions, 15 deletions
diff --git a/plugins-scripts/check_ntp.pl b/plugins-scripts/check_ntp.pl
index 5a3c44d..2215fbd 100755
--- a/plugins-scripts/check_ntp.pl
+++ b/plugins-scripts/check_ntp.pl
@@ -52,7 +52,9 @@
52# 52#
53# Added ntpdate check for stratum 16 desynch peer (James Fidell) Feb 03, 2003 53# Added ntpdate check for stratum 16 desynch peer (James Fidell) Feb 03, 2003
54# 54#
55 55# ntpdate - offset is in seconds
56# changed ntpdc to ntpq - jitter/dispersion is in milliseconds
57#
56 58
57require 5.004; 59require 5.004;
58use POSIX; 60use POSIX;
@@ -71,11 +73,12 @@ $ENV{'PATH'}='';
71$ENV{'BASH_ENV'}=''; 73$ENV{'BASH_ENV'}='';
72$ENV{'ENV'}=''; 74$ENV{'ENV'}='';
73 75
74# defaults in millisec 76# defaults in sec
75my $DEFAULT_OFFSET_WARN = 60000; 77my $DEFAULT_OFFSET_WARN = 60; # 1 minute
76my $DEFAULT_OFFSET_CRIT = 120000; 78my $DEFAULT_OFFSET_CRIT = 120; # 2 minutes
77my $DEFAULT_JITTER_WARN = 5000; 79# default in millisec
78my $DEFAULT_JITTER_CRIT = 10000; 80my $DEFAULT_JITTER_WARN = 5000; # 5 sec
81my $DEFAULT_JITTER_CRIT = 10000; # 10 sec
79 82
80Getopt::Long::Configure('bundling'); 83Getopt::Long::Configure('bundling');
81GetOptions 84GetOptions
@@ -291,9 +294,9 @@ if ($ntpdate_error != $ERRORS{'OK'}) {
291 $answer = "Jitter $jitter too high\n"; 294 $answer = "Jitter $jitter too high\n";
292 if (defined($offset) && abs($offset) > $ocrit) { 295 if (defined($offset) && abs($offset) > $ocrit) {
293 $state = $ERRORS{'CRITICAL'}; 296 $state = $ERRORS{'CRITICAL'};
294 $answer = "Jitter error and offset $offset msec > +/- $ocrit msec\n"; 297 $answer = "Jitter error and offset $offset sec > +/- $ocrit sec\n";
295 } elsif (defined($offset) && abs($offset) > $owarn) { 298 } elsif (defined($offset) && abs($offset) > $owarn) {
296 $answer = "Jitter error and offset $offset msec > +/- $owarn msec\n"; 299 $answer = "Jitter error and offset $offset sec > +/- $owarn sec\n";
297 } elsif (defined($jitter) && abs($jitter) > $jcrit) { 300 } elsif (defined($jitter) && abs($jitter) > $jcrit) {
298 $answer = "Jitter error and jitter $jitter msec > +/- $jcrit msec\n"; 301 $answer = "Jitter error and jitter $jitter msec > +/- $jcrit msec\n";
299 } elsif (defined($jitter) && abs($jitter) > $jwarn) { 302 } elsif (defined($jitter) && abs($jitter) > $jwarn) {
@@ -303,20 +306,20 @@ if ($ntpdate_error != $ERRORS{'OK'}) {
303} else { # no errors from ntpdate or ntpq 306} else { # no errors from ntpdate or ntpq
304 if (abs($offset) > $ocrit) { 307 if (abs($offset) > $ocrit) {
305 $state = $ERRORS{'CRITICAL'}; 308 $state = $ERRORS{'CRITICAL'};
306 $answer = "Offset $offset msec > +/- $ocrit msec, jitter $jitter msec\n"; 309 $answer = "Offset $offset msec > +/- $ocrit sec, jitter $jitter msec\n";
307 } elsif (abs($jitter) > $jcrit ) { 310 } elsif (abs($jitter) > $jcrit ) {
308 $state = $ERRORS{'CRITICAL'}; 311 $state = $ERRORS{'CRITICAL'};
309 $answer = "Jitter $jitter msec> +/- $jcrit msec, offset $offset msec \n"; 312 $answer = "Jitter $jitter msec> +/- $jcrit msec, offset $offset sec \n";
310 } elsif (abs($offset) > $owarn) { 313 } elsif (abs($offset) > $owarn) {
311 $state = $ERRORS{'WARNING'}; 314 $state = $ERRORS{'WARNING'};
312 $answer = "Offset $offset msec > +/- $owarn msec, jitter $jitter msec\n"; 315 $answer = "Offset $offset msec > +/- $owarn sec, jitter $jitter msec\n";
313 } elsif (abs($jitter) > $jwarn ) { 316 } elsif (abs($jitter) > $jwarn ) {
314 $state = $ERRORS{'WARNING'}; 317 $state = $ERRORS{'WARNING'};
315 $answer = "Jitter $jitter msec> +/- $jwarn msec, offset $offset msec \n"; 318 $answer = "Jitter $jitter msec> +/- $jwarn msec, offset $offset sec \n";
316 319
317 } else { 320 } else {
318 $state = $ERRORS{'OK'}; 321 $state = $ERRORS{'OK'};
319 $answer = "Offset $offset msecs, jitter $jitter msec\n"; 322 $answer = "Offset $offset secs, jitter $jitter msec\n";
320 } 323 }
321 324
322# else { # no offset defined 325# else { # no offset defined
@@ -351,9 +354,9 @@ sub print_help () {
351Checks the local timestamp offset versus <host> with ntpdate 354Checks the local timestamp offset versus <host> with ntpdate
352Checks the jitter/dispersion of clock signal between <host> and its sys.peer with ntpq\n 355Checks the jitter/dispersion of clock signal between <host> and its sys.peer with ntpq\n
353-w ( --warning) 356-w ( --warning)
354 Clock offset in milliseconds at which a warning message will be generated.\n Defaults to $DEFAULT_OFFSET_WARN. 357 Clock offset in seconds at which a warning message will be generated.\n Defaults to $DEFAULT_OFFSET_WARN.
355-c (--critical) 358-c (--critical)
356 Clock offset in milliseconds at which a critical message will be generated.\n Defaults to $DEFAULT_OFFSET_CRIT. 359 Clock offset in seconds at which a critical message will be generated.\n Defaults to $DEFAULT_OFFSET_CRIT.
357-j (--jwarn) 360-j (--jwarn)
358 Clock jitter in milliseconds at which a warning message will be generated.\n Defaults to $DEFAULT_JITTER_WARN. 361 Clock jitter in milliseconds at which a warning message will be generated.\n Defaults to $DEFAULT_JITTER_WARN.
359-k (--jcrit) 362-k (--jcrit)