Boston Linux & Unix (BLU) Home | Calendar | Mail Lists | List Archives | Desktop SIG | Hardware Hacking SIG
Wiki | Flickr | PicasaWeb | Video | Maps & Directions | Installfests | Keysignings
Linux Cafe | Meeting Notes | Blog | Linux Links | Bling | About BLU

BLU Discuss list archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

monitoring NTP

Dan Ritter wrote:
> You need your monitor to parse the output of 
> ntpq -n -c rv $host
> and compare to local time.


So you mean parsing the time string out of:

reftime=cdf8176a.fdf3a0c5  Fri, Jul  3 2009  1:36:42.991, poll=6,
clock=cdf81781.889e625e  Fri, Jul  3 2009  1:37:05.533, state=4,
offset=-11.510, frequency=-19.803, jitter=8.887, noise=5.759,

My first thought was the use offset, but that appears to be the offset 
between the remote server and its upstream peer.

The HTML documentation lists the variables, but never really defines 
their meaning. I guess they defer to the RFC, which does define them.

Looks like it may be easier to just use Net::NTP in Perl, if it's going 
to require a script anyway, and and that approach reduces dependency on 
the code being monitored (technically ntpq is separate from ntpd).

For example, this will report the offset between the local machine and a 
specified server:

use Net::NTP;
my $SERVER = '';
my %response = get_ntp_response($SERVER);
printf "Offset: %.5f s\n", $response{'Transmit Timestamp'} - time;

I'll extend that to compare the delta to a threshold, and log a critical 
error through syslog if it is exceeded. Then set the script up to run 
occasionally from cron.


Tom Metro
Venture Logic, Newton, MA, USA
"Enterprise solutions through open source."
Professional Profile:

BLU is a member of BostonUserGroups
BLU is a member of BostonUserGroups
We also thank MIT for the use of their facilities.

Valid HTML 4.01! Valid CSS!

Boston Linux & Unix /