Article 6967 of comp.protocols.time.ntp:
From: Markus Fix <fix@inm.de>
Newsgroups: comp.protocols.time.ntp
Subject: Re: NTP server summary via CGI/WWW?
Date: Thu, 20 Aug 1998 17:58:31 +0200
Organization: INM,Frankfurt/Main,Germany
Lines: 92
Message-ID: <35DC47A7.3C7EAEDE@inm.de>
References: <6rckv5$9fo$1@infiniti.nss.harris.com>
NNTP-Posting-Host: isis.inm.de
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
X-Trace: riegeler.inm.de 903628711 21760 195.20.81.3 (20 Aug 1998 15:58:31 GMT)
X-Complaints-To: news@inm.de
NNTP-Posting-Date: 20 Aug 1998 15:58:31 GMT
X-Mailer: Mozilla 4.04 [en] (X11; U; IRIX 6.2 IP22)
Path: news1.meer.net!nntp2.ba.best.com!news1.best.com!su-news-hub1.bbnplanet.com!cpk-news-hub1.bbnplanet.com!news.bbnplanet.com!news-fra.maz.net!news.omnilink.net!news.inm.de!not-for-mail
Xref: news1.meer.net comp.protocols.time.ntp:6967

Alan Sparks wrote:
> 
> A quick question -- does anyone know of a Perl or C program that can be used
> in a CGI environment, to basically show a nice summary view of an NTP server
> status, such as peering relationships and loop stats (basically, a cook of
> the ntpq outputs)?

You can do more than that. At our site we use mrtg
(http://ee-staff.ethz.ch/~oetiker/webtools/mrtg/mrtg.html)
to graph the output of "ntpq -p" and "xntpdc -c sysinfo".
This way you get a long time view of the health of you clock.
Below you'll find the trivial perl script to fetch the data
for mrtg.

-fix

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

#!/usr/local/bin/perl
#
# File: /usr/local/admin/mrtg/gettimestats
#
# This perl script snarfs the output of nptq -p and prints the
# dispersion values of our DCF clock and PPS signal plus the 
# timestamp to stdout.
# The typical output of ntpq -p at our site looks like this:
#
#      remote           refid      st t when poll reach   delay  
offset    disp
#==============================================================================
# LOCAL(0)        LOCAL(0)        10 l   11   64  377     0.00   
0.000   10.01
#oATOM_PPS(0)     .PPS.            0 l   12   64  377     0.00   
0.098    0.05
#+GENERIC(1)      .DCFa.           0 l    8   64  377     0.00   
0.116    0.05
#
# To use this with mrtg
(http://ee-staff.ethz.ch/~oetiker/webtools/mrtg/mrtg.html)
# put the following into your mrtg.cfg file:
#
#-------- Time on Timeserver ---------------------------------------
#Target[time]: `/usr/local/admin/mrtg/gettimestats`
#MaxBytes[time]: 1600
#AbsMax[time]: 1600
#Options[time]: growright,gauge,noinfo,nopercent
#Title[time]:  Timeserver Statistics 
#PageTop[time]: <H1>Timeserver Statistics</H1>
#XSize[time]: 600
#Supress[time]: my
#YSize[time]: 100
#WithPeak[time]: dwmy
#YLegend[time]: us Dispersion
#ShortLegend[time]: us
#LegendI[time]: &nbsp;PPS:
#LegendO[time]: &nbsp;DCF:
#Legend1[time]: PPS Dispersion in MicroSeconds (10E-6)
#Legend2[time]: DCF Dispersion in MicroSeconds (10E-6)
#Legend3[time]: Maximum 5 Minute PPS Dispersion in MicroSeconds (10E-6)
#Legend4[time]: Maximum 5 Minute DCF Dispersion in MicroSeconds (10E-6)

open GET_STAT, "/usr/local/bin/ntpq -p timeserver |"
               or die "can't fork: $!";

local $SIG{PIPE} = sub { die "spooler pipe broke"};


while(<GET_STAT>){
        @fields=split(/ /,$line);
        if (/ATOM_PPS/){
                $a=$_;
                @feld=split(/\s+/,$a);
                $PPS=$feld[9]*1000;
        }
        if (/GENERIC/){
                $a=$_;
                @feld=split(/\s+/,$a);
                $DCF=$feld[9]*1000;
        }
}
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)= localtime(time);
print "$PPS\n";
print "$DCF\n";
print "$hour:$min:$sec\n";
close GET_STAT or die "bad ntpq output: $! $?";

-------------------------------------------------------------------------
-- 
Markus Fix (networks & security)	INM
fix@inm.de (PGP key on request)		Daimlerstrasse 32
http://www.inm.de/people/fix/		60314 Frankfurt a.M.,Germany
********** The best defense against logic is ignorance. ************


