diff options
author | Subhendu Ghosh <sghosh@users.sourceforge.net> | 2003-10-14 02:40:31 +0000 |
---|---|---|
committer | Subhendu Ghosh <sghosh@users.sourceforge.net> | 2003-10-14 02:40:31 +0000 |
commit | 746e30719509f026c2bcda84fab22725b5e982aa (patch) | |
tree | 4a931e82764d632ef99f5af201d49f48243f8f2e | |
parent | cc80829d356b05e070969e331c85ae8bdfaa4560 (diff) | |
download | monitoring-plugins-746e30719509f026c2bcda84fab22725b5e982aa.tar.gz |
Bug 773588: added check to warn on matching # candidates only
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@744 f882894a-f735-0410-b71e-b25c423dba1c
-rwxr-xr-x | plugins-scripts/check_ntp.pl | 41 |
1 files changed, 36 insertions, 5 deletions
diff --git a/plugins-scripts/check_ntp.pl b/plugins-scripts/check_ntp.pl index 10079b69..0546761b 100755 --- a/plugins-scripts/check_ntp.pl +++ b/plugins-scripts/check_ntp.pl @@ -154,7 +154,8 @@ my $answer = undef; my $offset = undef; my $jitter = undef; my $syspeer = undef; -my $candidates = 0; +my $candidate = 0; +my @candidates; my $msg; # first line of output to print if format is invalid my $state = $ERRORS{'UNKNOWN'}; @@ -252,6 +253,9 @@ if ( $? && !$ignoreret ) { # Field 10: offset # Field 11: dispersion/jitter # +# According to bug 773588 Some solaris xntpd implementations seemto match on +# "#" even though the docs say it exceeds maximum distance. Providing patch +# here which will generate a warining. if ($have_ntpq) { @@ -264,12 +268,13 @@ if ($have_ntpq) { } # number of candidates on <host> for sys.peer if (/^(\*|\+|\#|o])/) { - ++$candidates; - print "Candiate count= $candidates\n" if ($verbose); + ++$candidate; + push (@candidates, $_); + print "Candiate count= $candidate\n" if ($verbose); } - + # match sys.peer or pps.peer - 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.]+)/) { + 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.]+)/) { $syspeer = $2; $stratum = $4; $jitter = $11; @@ -284,8 +289,34 @@ if ($have_ntpq) { $jitter_error = $ERRORS{'OK'}; } } + } close NTPQ; + + # if we did not match sys.peer or pps.peer but matched # candidates only + # generate a warning + # based on bug id 773588 + unless (defined $syspeer) { + if ($#candidates >0) { + foreach my $c (@candidates) { + $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.]+)/; + $syspeer = $2; + $stratum = $4; + $jitter = $11; + print "candidate match $c \n" if $verbose; + if ($jitter > $jcrit) { + print "Candidate match - Jitter_crit = $11 :$jcrit\n" if ($verbose); + $jitter_error = $ERRORS{'CRITICAL'}; + }elsif ($jitter > $jwarn ) { + print "Candidate match - Jitter_warn = $11 :$jwarn \n" if ($verbose); + $jitter_error = $ERRORS{'WARNING'}; + } else { + $jitter_error = $ERRORS{'WARNING'}; + } + } + + } + } } } |