[Nagiosplug-devel] [ nagiosplug-Patches-992583 ] regex fix for check_ntp

SourceForge.net noreply at sourceforge.net
Wed Aug 18 13:45:03 CEST 2004


Patches item #992583, was opened at 2004-07-16 22:46
Message generated for change (Comment added) made by tonvoon
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=397599&aid=992583&group_id=29880

Category: Bugfix
Group: None
>Status: Closed
Resolution: None
Priority: 5
Submitted By: Nayden Naydenov (naidd)
>Assigned to: Ton Voon (tonvoon)
Summary: regex fix for check_ntp

Initial Comment:
The check_ntp plugin included with nagios-plugins-1.3.1
has a problem parsing the output from various ntp
servers.  Here is an example:

./check_ntp -H clock
Use of uninitialized value in concatenation (.) or
string at ./123 line 308.
NTP UNKNOWN: Jitter  too high

And here is the verbose output:

./check_ntp -H clock -v
server 192.168.2.222, stratum 1, offset -0.000741,
delay 0.03159
ntperr = 0
16 Jul 17:36:37 ntpdate[12099]: adjust time server
192.168.2.222 offset -0.000741 sec
ntperr = 0
     remote           refid      st t when poll reach 
 delay   offset  jitter
==============================================================================
*127.127.1.0     .GPS.            0 -   11   64  377  
 0.000    0.000   0.000
Candiate count= 1
 192.168.2.255   0.0.0.0         16 u    -   64    0  
 0.000    0.000   0.000
 192.168.3.255   0.0.0.0         16 u    -   64    0  
 0.000    0.000   0.000
 192.168.6.255   0.0.0.0         16 u    -   64    0  
 0.000    0.000   0.000
 192.168.9.255   0.0.0.0         16 u    -   64    0  
 0.000    0.000   0.000
Use of uninitialized value in concatenation (.) or
string at ./123 line 308.
NTP UNKNOWN: Jitter  too high

As you can see, the "t" (peer type) field in the first
table row is "-", and the script is only expecting to
see "l", "u", "m", or "b".  Changing the following
regular expression (line 265) fixes the problem (notice
the extra "-"):

BEFORE:
# match sys.peer or pps.peer
                        if
(/^(\*|o)([-0-9.\s]+)\s+([-0-9A-Za-z.]+)\s+([-0-9.]+)\s+([lumb]+)\s+([-0-9m.]+)\s+([-0-9.]+)\s+([-0-9.]+)\s+([-0-9.]+)\s+([-0-9.]+)\s+([-0-9.]+)/)
{

AFTER:
# match sys.peer or pps.peer
                        if
(/^(\*|o)([-0-9.\s]+)\s+([-0-9A-Za-z.]+)\s+([-0-9.]+)\s+([lumb-]+)\s+([-0-9m.]+)\s+([-0-9.]+)\s+([-0-9.]+)\s+([-0-9.]+)\s+([-0-9.]+)\s+([-0-9.]+)/)
{

Finally, here is the brief output after the change:

./check_ntp -H clock
NTP OK: Offset -0.000771 secs, jitter 0.000 msec, peer
is stratum 0

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

>Comment By: Ton Voon (tonvoon)
Date: 2004-08-18 21:44

Message:
Logged In: YES 
user_id=664364

Nayden, Thanks for the report. This appears to be fixed in 1.18 of 
check_ntp.pl.

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

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




More information about the Devel mailing list