[ntp:questions] Peer Review of ntpq -c rv

Alby VA albyva at empire.org
Wed Mar 7 16:06:15 UTC 2012


On Mar 7, 9:50 am, "David J Taylor" <david-
tay... at blueyonder.co.uk.invalid> wrote:
> "Alby VA" <alb... at empire.org> wrote in message
>
> news:d2d5cf76-b61e-4e58-800b-a1c27a63dc92 at hs8g2000vbb.googlegroups.com...
>
>
>
>
>
>
>
>
>
>
>
> > I'm looking to get a little feedback on if the following output of my
> > Sure GPS / FreeBSD
> > setup looks like its running smoothly and keeping time correctly.
>
> > assID=0 status=0115 leap_none, sync_atomic, 1 event,
> > event_clock_reset,
> > version="ntpd 4.2.... at 1.2349-o Mon Feb 20 22:00:33 UTC 2012 (1)",
> > processor="amd64", system="FreeBSD/9.0-RELEASE", leap=00, stratum=1,
> > precision=-19, rootdelay=0.000, rootdisp=0.269, refid=PPS,
> > reftime=d301d22f.dc1393c2  Wed, Mar  7 2012  7:25:19.859,
> > clock=d301d230.cc08bad9  Wed, Mar  7 2012  7:25:20.797, peer=41909,
> > tc=4, mintc=3, offset=-0.034, frequency=-25.214, sys_jitter=0.002,
> > clk_jitter=0.002, clk_wander=0.001
>
> > Here are my website graphs/stats I've been keeping since day 1.
>
> > NTP Clock Offset:http://godzilla.empire.org:9999/
> > NTP Offset from UTC:http://godzilla.empire.org:9999/godzilla_ntp-b.html
>
> For comparison, a GPS 18 LVC feeding a FreeBSD 8.2 system, which is /only/
> doing NTP service:
>
>  http://www.satsignal.eu/mrtg/pixie_ntp.html
>
> Offsets in the few microseconds region, whereas yours are at the
> millisecond level, which seems to be a large factor out.  Any chance your
> "NTP Clock Offset" graph is mislabeled?  In case it's any help:
>
> ________________________________________________
> associd=0 status=0419 leap_none, sync_uhf_radio, 1 event, leap_armed,
> version="ntpd 4.2.7p... at 1.2483 Fri Feb 10 06:04:36 UTC 2012 (1)",
> processor="i386", system="FreeBSD/8.2-RELEASE-p6", leap=00, stratum=1,
> precision=-19, rootdelay=0.000, rootdisp=1.060, refid=PPS,
> reftime=d301f2ab.e61f80cb  Wed, Mar  7 2012 14:43:55.898,
> clock=d301f2b0.389c6063  Wed, Mar  7 2012 14:44:00.221, peer=8406, tc=4,
> mintc=3, offset=0.000, frequency=28.159, sys_jitter=0.002,
> clk_jitter=0.002, clk_wander=0.002, tai=34, leapsec=201207010000,
> expire=201212280000
> ________________________________________________
>
> For comparison, my Windows PCs connected to Sure boxes are PCs Feenix and
> Alta, and I would expect them to be rather worse than Free BSD.  Graphs
> here:
>
>  http://www.satsignal.eu/mrtg/performance_ntp.php
>
> (Before anyone asks, PCs Stamsund and Bacchus are connected to GPS 18x and
> GPS 18 LVCs, and Bacchus does a disk defrag every Wednesday morning which
> takes 100% of the CPU, and rather disturbs the timekeeping!)
>
> Cheers,
> David





 You might be right. It could be mislabeled. I pretty much did a Cut-
Paste from some website for my MRTG setup. Here is what I have listed.


# NTP Clock Offset
Target[ntpoff]: `/var/log/ntp/ntpstat.pl`
XSize[ntpoff]: 600
YSize[ntpoff]: 150
Options[ntpoff]: gauge,growright,nopercent
Title[ntpoff]: NTP Clock Offset
MaxBytes[ntpoff]: 20480000
PageTop[ntpoff]: <H1>NTP Clock Offset</H1>
LegendO[ntpoff]: Negative Drift
LegendI[ntpoff]: Positive Drift
Legend2[ntpoff]: Negative Drift
Legend1[ntpoff]: Positive Drift
YLegend[ntpoff]: drift msecs
ShortLegend[ntpoff]: &nbsp;msecs
Colours[ntpoff]:
DKBLUE#61A0DF,DKBLUE#0000DD,DARKGREEN#006600,VIOLET#FF00FF
#
#
#
Target[godzilla_ntp-b]: `perl /var/log/ntp/GetNTP3000usec.pl godzilla`
MaxBytes[godzilla_ntp-b]: 5990
MaxBytes2[godzilla_ntp-b]: 3000
Unscaled[godzilla_ntp-b]: dwmy
Title[godzilla_ntp-b]: NTP statistics for Godzilla - offset from UTC
Options[godzilla_ntp-b]: integer, gauge, nopercent, growright
YLegend[godzilla_ntp-b]: offset + 3ms
kMG[godzilla_ntp-b]: ,ms,,,,
ShortLegend[godzilla_ntp-b]: µs
LegendI[godzilla_ntp-b]:
LegendO[godzilla_ntp-b]: offset + 3000µs:&nbsp;
Legend1[godzilla_ntp-b]: n/a
Legend2[godzilla_ntp-b]: time offset in µs, with 3000µs offset added
to ensure it's positive.
PageTop[godzilla_ntp-b]: <H1>NTP -- Godzilla</H1>
#
#
#
#
#



#ntpstat.pl
#
#!/usr/bin/perl
#
# I want to see how far the clock is off on average from the network
# sources.
#
# Output:
#    line 1 - positive offset #
#    line 2 - negative offset #
#

$count = "0";
$offset = "0";

foreach (`ntpq -pn`)
{
   ($remote,$ref,$st,$t,$w,$p,$reach,$delay,$o,$d) = split;
   if ( $remote ne
"==============================================================================" )
{
   if ( $remote ne "remote" ) {

   $count = $count + "1";
   $offset = $offset + $o;

   } }
}


# Now we will get the average and print the output

$average = int( $offset / $count );

if ( $average > 0 ) {

      print "$average \n";
      print "0 \n";

      } else {

      $average = int( $average * -1 );
      print "0 \n";
      print "$average \n";

      }

#
#
#
#
#
#GetNTP3000usec.pl
#
#
#Version for ref-clock-synced sources, displays +/- 3ms
#
#One oddity here is that when specifying 6000 (s) as the maximum
#value for the graph, MRTG seemed to set a value slightly greater
#than the 6ms I wanted, so I had to set the maximum to 5990.  This
#had the unfortunate effect that when the offset exceeded 6000, the
#last value less than 6000 was plotted, rather than the 6000 limit.
#Hence I changed the Perl script to limit the positive value it
#returned to 5985 in an attempt to ensure that values over the limit
#are displayed as such.
#
$ntp_str = `ntpq -c rv $ARGV[0]`;
$val = (split(/\,/,$ntp_str))[20];
$val =~ s/offset=//i;
$val = 1000.0 * $val;    # convert to microseconds
$report = int ($val + 3000);
# limit negative value to 0
if ($report < 0) {
  $report = 0;
}
# limit positive value to just under 6000
if ($report > 5985) {
  $report = 5985;
}
print "0\n";
print "$report\n";
print "0\n";
print "$ARGV[0]\n";



More information about the questions mailing list