diff options
author | Subhendu Ghosh <sghosh@users.sourceforge.net> | 2003-02-03 15:47:21 +0000 |
---|---|---|
committer | Subhendu Ghosh <sghosh@users.sourceforge.net> | 2003-02-03 15:47:21 +0000 |
commit | 3477ec434d6ff7577f7f52498642f0ea4c0c2841 (patch) | |
tree | 6fa438fbc066c04cd21df1c1eaefca31cc3f30ac /plugins-scripts | |
parent | 19d459ffeb14c8f38b9886f11f24ea423ff6f51e (diff) | |
download | monitoring-plugins-3477ec434d6ff7577f7f52498642f0ea4c0c2841.tar.gz |
patch for desync peer and ntpdate (James Fidell)
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@280 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins-scripts')
-rwxr-xr-x | plugins-scripts/check_ntp.pl | 32 |
1 files changed, 26 insertions, 6 deletions
diff --git a/plugins-scripts/check_ntp.pl b/plugins-scripts/check_ntp.pl index 331f8556..560a8775 100755 --- a/plugins-scripts/check_ntp.pl +++ b/plugins-scripts/check_ntp.pl @@ -50,7 +50,7 @@ # Modifed to run under Embedded Perl (sghosh@users.sf.net) # - combined logic some blocks together.. # -# Todo - non-hardcoded dispersion values... +# Added ntpdate check for stratum 16 desynch peer (James Fidell) Feb 03, 2003 # @@ -111,6 +111,8 @@ if ($critical < $warning ) { exit $ERRORS{"UNKNOWN"}; } +my $stratum = -1; +my $ignoreret = 0; my $answer = undef; my $offset = undef; my $msg; # first line of output to print if format is invalid @@ -137,7 +139,7 @@ alarm($TIMEOUT); ### -###$dispersion_error = $ERRORS{' +### ### First, check ntpdate ### ### @@ -150,6 +152,11 @@ if (!open (NTPDATE, "$utils::PATH_TO_NTPDATE -q $host 2>&1 |")) { while (<NTPDATE>) { print if ($verbose); $msg = $_ unless ($msg); + + if (/stratum\s(\d+)/) { + $stratum = $1; + } + if (/(offset|adjust)\s+([-.\d]+)/i) { $offset = $2; @@ -163,8 +170,15 @@ while (<NTPDATE>) { } if (/no server suitable for synchronization found/) { - $ntpdate_error = $ERRORS{"CRITICAL"}; - $msg = "No suitable peer server found - "; + if ($stratum == 16) { + $ntpdate_error = $ERRORS{"WARNING"}; + $msg = "Desynchronized peer server found"; + $ignoreret=1; + } + else { + $ntpdate_error = $ERRORS{"CRITICAL"}; + $msg = "No suitable peer server found - "; + } } } @@ -172,7 +186,7 @@ while (<NTPDATE>) { close (NTPDATE); # declare an error if we also get a non-zero return code from ntpdate # unless already set to critical -if ( $? ) { +if ( $? && !$ignoreret ) { print "stderr = $? : $! \n" if $verbose; $ntpdate_error = $ntpdate_error == $ERRORS{"CRITICAL"} ? $ERRORS{"CRITICAL"} : $ERRORS{"UNKNOWN"} ; print "ntperr = $ntpdate_error : $!\n" if $verbose; @@ -208,7 +222,13 @@ if ($have_ntpdc) { if ($ntpdate_error != $ERRORS{'OK'}) { $state = $ntpdate_error; - $answer = $msg . "Server for ntp probably down\n"; + if ($ntpdate_error == $ERRORS{'WARNING'} ) { + $answer = $msg . "\n"; + } + else { + $answer = $msg . "Server for ntp probably down\n"; + } + if (defined($offset) && abs($offset) > $critical) { $state = $ERRORS{'CRITICAL'}; $answer = "Server Error and time difference $offset seconds greater than +/- $critical sec\n"; |