[ntp:questions] Tool to sample/monitor an NTP server?

David J Taylor david-taylor at blueyonder.not-this-bit.nor-this.co.uk.invalid
Tue Nov 10 08:08:33 UTC 2009


> My problem is a client with several systems using a single GPS-based
> NTP server.
[]
> What I want is a client to poll the NTP server (say once per second)
> and log the time received. A simple perl script can then look for any
> large jumps in the recorded time. This will tell me if the NTP server
> is really at fault.

Philip,

The output from an ntpq -c rv is:

_________________________________________________
associd=0 status=0618 leap_none, sync_ntp, 1 event, no_sys_peer,
version="ntpd 4.2.5p231-RC-o Oct 10 11:27:54.43 (UTC-00:00) 2009  (1)",
processor="x86", system="Windows", leap=00, stratum=2, precision=-22,
rootdelay=1.788, rootdisp=4.716, refid=192.168.0.2,
reftime=cea39c83.282f8ed7  Tue, Nov 10 2009  8:02:11.156,
clock=cea39caf.47f7db7f  Tue, Nov 10 2009  8:02:55.281, peer=50788,
tc=6, mintc=3, offset=1.453, frequency=11.176, sys_jitter=0.216,
clk_jitter=0.158, clk_wander=0.019
_________________________________________________


I wrote a simple Perl script to extract jitter, and format it for MRTG, so 
you could modify that to look for "clock=".  It takes the server name as a 
parameter.

_________________________________________________

$ntp_str = `ntpq -c rv $ARGV[0]`;
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime(time);
$year = $year + 1900;
$mon = $mon + 1;
$offset = (split(/\,/,$ntp_str))[20];
$offset =~ s/\n//i;
$freq = (split(/\,/,$ntp_str))[21];
$jitter = (split(/\,/,$ntp_str))[22];
$stability = (split(/\,/,$ntp_str))[23];
$stability =~ s/\n//i;

$jitter =~ s/ jitter=//i;
$jitter = 1000.0 * $jitter;		# convert to microseconds
$jitter = int ($jitter);

print "$jitter\n";
print "0\n";
print "0\n";
print "$ARGV[0]\n";
_________________________________________________


I hope that helps.

Cheers,
David 




More information about the questions mailing list