[Nagiosplug-devel] [ nagiosplug-Bugs-1251096 ] check_ntp perl warnings

SourceForge.net noreply at sourceforge.net
Thu Nov 17 17:47:16 CET 2005


Bugs item #1251096, was opened at 2005-08-03 16:49
Message generated for change (Comment added) made by fischaz
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=397597&aid=1251096&group_id=29880

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Parsing problem
Group: Release (specify)
Status: Open
Resolution: None
Priority: 5
Submitted By: Peter Pramberger (peterpramb)
Assigned to: Nobody/Anonymous (nobody)
Summary: check_ntp perl warnings

Initial Comment:
Using check_ntp.pl from plugins 1.4.1 produces some
warnings if the checked host is not reachable or
responding before timeout. These warnings produce an
UNKNOWN state in Nagios.

See the attached patch for clarification.

----------------------------------------------------------------------

Comment By: Johan Fischer (fischaz)
Date: 2005-11-18 02:46

Message:
Logged In: YES 
user_id=459934

Below patch (that I can't seem to be able to attach)

diff -Naur
nagios-plugins-1.4.2.orig/plugins-scripts/check_ntp.pl
nagios-plugins-1.4.2/plugins-scripts/check_ntp.pl
--- nagios-plugins-1.4.2.orig/plugins-scripts/check_ntp.pl
2005-05-26 00:05:41.000000000 +1000
+++ nagios-plugins-1.4.2/plugins-scripts/check_ntp.pl
2005-11-18 12:39:07.000000000 +1100
@@ -309,7 +309,6 @@
 				}
 			} else {
 				print "No match!\n" if $verbose;
-				$jitter = '(not parsed)';
 			}
 			
 		}
@@ -365,7 +364,7 @@
 
 } elsif ($have_ntpq && $jitter_error != $ERRORS{'OK'}) {
 	$state = $jitter_error;
-	$answer = "Jitter $jitter too high";
+	$answer = 'Jitter ' . ((defined $jitter) ? $jitter : '-')
. ' too high';
 	if (defined($offset) && abs($offset) > $ocrit) {
 		$state = $ERRORS{'CRITICAL'};
 		$answer = "Jitter error and offset $offset sec > +/-
$ocrit sec";
@@ -401,13 +400,13 @@
 	if (abs($offset) > $ocrit) {
 		$state = $ERRORS{'CRITICAL'};
 		$answer = "Offset $offset sec > +/- $ocrit sec, jitter
$jitter msec";
-	} elsif (abs($jitter) > $jcrit ) {
+	} elsif (defined($jitter) && abs($jitter) > $jcrit ) {
 		$state = $ERRORS{'CRITICAL'};
 		$answer = "Jitter $jitter msec> +/- $jcrit msec, offset
$offset sec";
 	} elsif (abs($offset) > $owarn) {
 		$state = $ERRORS{'WARNING'};
 		$answer = "Offset $offset sec > +/- $owarn sec, jitter
$jitter msec";
-	} elsif (abs($jitter) > $jwarn ) {
+	} elsif (defined($jitter) && abs($jitter) > $jwarn ) {
 		$state = $ERRORS{'WARNING'};
 		$answer = "Jitter $jitter msec> +/- $jwarn msec, offset
$offset sec";
 
@@ -421,7 +420,7 @@
 foreach my $key (keys %ERRORS) {
 	if ($state==$ERRORS{$key}) {
 #		print ("NTP $key: $answer");
-		print ("NTP $key: $answer|offset=$offset, jitter=" .
$jitter/1000 .	",peer_stratum=$stratum\n");
+		print ("NTP $key: $answer|offset=$offset, jitter=" .
((defined $jitter) ? $jitter/1000 : '-') .
",peer_stratum=$stratum\n");
 		last;
 	}
 }


----------------------------------------------------------------------

Comment By: Johan Fischer (fischaz)
Date: 2005-11-18 02:45

Message:
Logged In: YES 
user_id=459934

The attached patch is wrong. It will override the value of
the jitter.

Basically the jitter is defined as undef at the begginning,
then should be overriden for each server with selected by
the regex. It should not be touched otherwise.

On the other side, more tests need to be done to see if
jitter is defined (and in that case, it will be a numeric)
and print it.

So it means more test at the end of the script to parse the
results.


----------------------------------------------------------------------

Comment By: Charles Bueche (cbueche)
Date: 2005-10-27 10:30

Message:
Logged In: YES 
user_id=299377

duplicate with 1267741

----------------------------------------------------------------------

Comment By: Ade Rixon (aderixon)
Date: 2005-10-21 12:12

Message:
Logged In: YES 
user_id=145082

This is still a problem in 1.4.2, can someone review before
next release, please? The warning is:

Argument "(not parsed)" isn't numeric in abs at ./check_ntp
line 401.

...Caused by assigning a string value ('(not parsed)') to
$jitter.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=397597&aid=1251096&group_id=29880




More information about the Devel mailing list