[Nagiosplug-devel] Setting the check_ntp error codes
Adams, Gavin
gadams at promisant.com
Fri May 24 13:57:04 CEST 2002
Hi all,
$ntpdate_error and $dispersion_error are set to UNKNOWN values (3) prior
to any checks from the new utils.pm:
my $state = $ERRORS{'UNKNOWN'};
my $ntpdate_error = $ERRORS{'UNKNOWN'};
my $dispersion_error = $ERRORS{'UNKNOWN'};
Followed by the parsing the ntpdate and ntpdc values.
Then there is the check to see what $ntpdate_error should be set to:
# only declare an error if we also get a non-zero return code from
ntpdate
$ntpdate_error = ($? >> 8) || $ntpdate_error;
With $? Being the return code the ntpdate command. For a valid response,
$? will bit-shift to 0, hence, short-circuiting and setting
$ntpdate_error to 3. This causes the return value checks to fail with
"server probably down message".
Does it make sense to do the following:
while (<NTPDATE>) {
print if ($verbose);
$msg = $_ unless ($msg);
if (/(offset|adjust)\s+([-.\d]+)/i) {
$offset = $2;
$ntpdate_error = $offset ? $ERRORS{"OK"} : \
$ERRORS{"UNKNOWN"}; # add this line in
last;
}
}
This works for valid NTP servers, and returns a warning value if the
server isn't available or is not running the NTP service.
Regards,
--- Gavin Adams
Promisant (USA) Inc.
O: +1.404.262.7321 M: +1.404.213.5539
More information about the Devel
mailing list