[Nagios-devel] Changes to the check_ntp perl-script
Posted: Thu Apr 27, 2006 9:33 pm
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.=20
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
([email protected])
+# o Modified script to handle case when ntpdate reports time, but
ntpq times out
+#
=20
require 5.004;
use POSIX;
@@ -427,8 +431,11 @@
=20
foreach my $key (keys %ERRORS) {
if ($state=3D=3D$ERRORS{$key}) {
-# print ("NTP $key: $answer");
- print ("NTP $key: $answer|offset=3D$offset, jitter=3D" .
$jitter/1000 . ",peer_stratum=3D$stratum\n");
+ if ( defined($jitter) ) {
+ print ("NTP $key: $answer|offset=3D$offset,
jitter=3D" . $jitter/1000 . ",peer_stratum=3D$stratum\n");
+ } else {=20
+ print ("NTP $key: $answer");
+ };
last;
}
}
Best regards
Johan Nilsson=20
Senior Network- and UNIX systems administrator
AXIS Communications AB
E-mail: johan.nilsson axis.com
www.axis.com
=20
This post was automatically imported from historical nagios-devel mailing list archives
Original poster: [email protected]
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.=20
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
([email protected])
+# o Modified script to handle case when ntpdate reports time, but
ntpq times out
+#
=20
require 5.004;
use POSIX;
@@ -427,8 +431,11 @@
=20
foreach my $key (keys %ERRORS) {
if ($state=3D=3D$ERRORS{$key}) {
-# print ("NTP $key: $answer");
- print ("NTP $key: $answer|offset=3D$offset, jitter=3D" .
$jitter/1000 . ",peer_stratum=3D$stratum\n");
+ if ( defined($jitter) ) {
+ print ("NTP $key: $answer|offset=3D$offset,
jitter=3D" . $jitter/1000 . ",peer_stratum=3D$stratum\n");
+ } else {=20
+ print ("NTP $key: $answer");
+ };
last;
}
}
Best regards
Johan Nilsson=20
Senior Network- and UNIX systems administrator
AXIS Communications AB
E-mail: johan.nilsson axis.com
www.axis.com
=20
This post was automatically imported from historical nagios-devel mailing list archives
Original poster: [email protected]