summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 19d459f)
raw | patch | inline | side by side (parent: 19d459f)
author | Subhendu Ghosh <sghosh@users.sourceforge.net> | |
Mon, 3 Feb 2003 15:47:21 +0000 (15:47 +0000) | ||
committer | Subhendu Ghosh <sghosh@users.sourceforge.net> | |
Mon, 3 Feb 2003 15:47:21 +0000 (15:47 +0000) |
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@280 f882894a-f735-0410-b71e-b25c423dba1c
plugins-scripts/check_ntp.pl | patch | blob | history |
index 331f85564caaeb1414f2f3c2dff6242229f33183..560a87757ee4de73d7f40cf634df3bfba98a29ba 100755 (executable)
# 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
#
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
###
-###$dispersion_error = $ERRORS{'
+###
### First, check ntpdate
###
###
while (<NTPDATE>) {
print if ($verbose);
$msg = $_ unless ($msg);
+
+ if (/stratum\s(\d+)/) {
+ $stratum = $1;
+ }
+
if (/(offset|adjust)\s+([-.\d]+)/i) {
$offset = $2;
}
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 - ";
+ }
}
}
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;
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";