Changes to the check_ntp perl-script

Johan Nilsson johan.nilsson at axis.se
Fri Apr 28 07:32:52 CEST 2006


Hi,

Excuse me if this is an old issue, but I am a newbie on this list.

In the course of upgrading Nagios from 1.3 to 2.1 on a
Debian/GNU-machine, I saw a problem with the check_ntp perl-script.
The plugin returns "UNKNOWN" if the ntp-server replies to the
ntpdate-request, but the ntpq-request times out. 
The exact error-message is "Use of uninitialized value in division (/)
at ./check_ntp line 431.", but on the next row the plugin reports the
status of the ntp-server.

I've made a small patch to check_ntp to be able to get rid of this
error-message, and to get the plugin to work for one of our servers.
Please let me know if this is the wrong forum for this......

Here's the patch:

--- check_ntp   2006-04-28 07:19:01.546010471 +0200
+++ check_ntp.modified  2006-04-28 07:02:45.236824995 +0200
@@ -56,6 +56,10 @@
 # changed ntpdc to ntpq - jitter/dispersion is in milliseconds
 #
 # Patch for for regex for stratum1 refid.
+#
+# Script modified 2006 April 28 by Johan Nilsson
(johan.nilsson at axis.com)
+#      o Modified script to handle case when ntpdate reports time, but
ntpq times out
+#
 
 require 5.004;
 use POSIX;
@@ -427,8 +431,11 @@
 
 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");
+               if ( defined($jitter) ) {
+                       print ("NTP $key: $answer|offset=$offset,
jitter=" . $jitter/1000 .     ",peer_stratum=$stratum\n");
+               } else { 
+                       print ("NTP $key: $answer");
+               };
                last;
        }
 }

Best regards

Johan Nilsson 
Senior Network- and UNIX systems administrator
AXIS Communications AB
E-mail: johan.nilsson <at> axis.com
www.axis.com
 


-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid0709&bid&3057&dat1642




More information about the Developers mailing list