[Nagiosplug-checkins] CVS: nagiosplug/plugins-scripts check_ntp.pl,1.9,1.10
Subhendu Ghosh
sghosh at users.sourceforge.net
Mon Feb 3 07:55:50 CET 2003
Update of /cvsroot/nagiosplug/nagiosplug/plugins-scripts
In directory sc8-pr-cvs1:/tmp/cvs-serv31042
Modified Files:
check_ntp.pl
Log Message:
patch for desync peer and ntpdate (James Fidell)
Index: check_ntp.pl
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins-scripts/check_ntp.pl,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -r1.9 -r1.10
*** check_ntp.pl 28 Oct 2002 13:05:07 -0000 1.9
--- check_ntp.pl 3 Feb 2003 15:47:21 -0000 1.10
***************
*** 51,55 ****
# - combined logic some blocks together..
#
! # Todo - non-hardcoded dispersion values...
#
--- 51,55 ----
# - combined logic some blocks together..
#
! # Added ntpdate check for stratum 16 desynch peer (James Fidell) Feb 03, 2003
#
***************
*** 112,115 ****
--- 112,117 ----
}
+ my $stratum = -1;
+ my $ignoreret = 0;
my $answer = undef;
my $offset = undef;
***************
*** 138,142 ****
###
! ###$dispersion_error = $ERRORS{'
### First, check ntpdate
###
--- 140,144 ----
###
! ###
### First, check ntpdate
###
***************
*** 151,154 ****
--- 153,161 ----
print if ($verbose);
$msg = $_ unless ($msg);
+
+ if (/stratum\s(\d+)/) {
+ $stratum = $1;
+ }
+
if (/(offset|adjust)\s+([-.\d]+)/i) {
$offset = $2;
***************
*** 164,169 ****
if (/no server suitable for synchronization found/) {
! $ntpdate_error = $ERRORS{"CRITICAL"};
! $msg = "No suitable peer server found - ";
}
--- 171,183 ----
if (/no server suitable for synchronization 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 - ";
! }
}
***************
*** 173,177 ****
# declare an error if we also get a non-zero return code from ntpdate
# unless already set to critical
! if ( $? ) {
print "stderr = $? : $! \n" if $verbose;
$ntpdate_error = $ntpdate_error == $ERRORS{"CRITICAL"} ? $ERRORS{"CRITICAL"} : $ERRORS{"UNKNOWN"} ;
--- 187,191 ----
# declare an error if we also get a non-zero return code from ntpdate
# unless already set to critical
! if ( $? && !$ignoreret ) {
print "stderr = $? : $! \n" if $verbose;
$ntpdate_error = $ntpdate_error == $ERRORS{"CRITICAL"} ? $ERRORS{"CRITICAL"} : $ERRORS{"UNKNOWN"} ;
***************
*** 209,213 ****
if ($ntpdate_error != $ERRORS{'OK'}) {
$state = $ntpdate_error;
! $answer = $msg . "Server for ntp probably down\n";
if (defined($offset) && abs($offset) > $critical) {
$state = $ERRORS{'CRITICAL'};
--- 223,233 ----
if ($ntpdate_error != $ERRORS{'OK'}) {
$state = $ntpdate_error;
! 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'};
More information about the Commits
mailing list