|
|
Using MRTG to monitor NTPI suggest first installing MRTG and become familiar with how
to install and configure it on your own system. You can then add to the
MRTG configuration to include timekeeping monitoring and a whole lot more.
The following commands would typically live in your C:\mrtg\bin\ directory.
I have also used MRTG for computer
performance measurement, and for a satellite data service signal
level and error rate monitoring. Using fixed scaling and bipolar displayVersion for Internet-synced sources, displays +/- 100msYou need a command-line program to extract the output from an NTP query command. As MRTG requires Perl, I wrote this program in Perl as well:
To test whether this is working, get a command prompt, CD to C:\mrtg\bin\, and enter the command: perl GetNTP.pl pc-name pc-name can be this PC, or another one on your network. You would expect to get back a four-line response: 0 109 0 0 IPv6 noteIf you are running version 4.2.4 or earlier of ntp, and you have Windows Vista, Windows-7 or later installed, it's possible that you have both IPv4 and IPv6 working on your network. The IPv6 is started automatically on these later operating systems. I found that under these circumstances, using the ntpq <local-pc-name> didn't work, possibly because the ntpd wasn't binding to both the IPv4 and IPv6 addresses (this is still under investigation). To get this to work properly, I found that you could either:
Adding a "zero" line in the middle of the graphBy making the MaxBytes and MaxBytes2 values different, you can get MaxBytes
plotted as a red dotted line on the graph, nicely indicating the nominal value if you make MaxBytes half MaxBytes2.
So for a 100ms offset from zero
for example, you could change the lines as shown below.
Here is a sample of the output, click on the graph for more examples:
Version for ref-clock-synced sources, displays +/- 3msOne 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.
Note the MaxBytes and MaxBytes2 values below, for a +/-3ms offset from zero as shown below:
Here is a sample of the output, click on the graph for more examples:
Version for ref-clock sources, displays +/- 20µs.In February 2006, I added a simple stratum 1 server, and added a different version of the Perl script to cover the more limited range of +/-20 microseconds (displayed as 0..40µs). By July 2006, the GPS was failing more often (tree leaf growth?), so I modified the script to limit on both positive and negative excursions (as without the GPS the server could be hundreds of microseconds out).
This script was later modified for rather less accurate
Windows-based ref-clock systems, so that a swing of +/- 500µs could be
displayed on a scale of 0..1000µs .
|
| File: GetNTPoffset.pl |
|---|
# Expects node name as a parameter
# Returns 1st value for positive offsets, second value for negative
# Returns microseconds of offset
$ntp_str = `ntpq -c rv $ARGV[0]`; # execute "ntpq -c rv <node>"
$val = (split(/\,/,$ntp_str))[20]; # get the offset string
$val =~ s/offset=//i; # remove the "offset="
$val = int (1000 * $val); # convert to microseconds
$nval = $val; # prepare the negative value
if ($val < 0){
$nval = -$nval; # make the value positive
$val = 0; # ensure zero return for the positive
} else {
$nval = 0; # ensure zero return for the negative
}
print "$nval\n"; # return four numbers, incoming
print "$val\n"; # outgoing
print "0\n";
print "$ARGV[0]\n";
|
| File: narvik-ntp-p.inc |
|---|
#--------------------------------------------------------------- # PC Narvik - timekeeping #--------------------------------------------------------------- Target[narvik_ntp-p]: `perl GetNTPoffset.pl narvik` MaxBytes[narvik_ntp-p]: 100000 Title[narvik_ntp-p]: NTP statistics for Narvik - offset from UTC Options[narvik_ntp-p]: integer, gauge, nopercent, growright Colours[narvik_ntp-p]: BLUE#0033FF, RED#FF0000, BLUE#0033FF, RED#FF0000, YLegend[narvik_ntp-p]: offset +/- us ShortLegend[narvik_ntp-p]: µs LegendI[narvik_ntp-p]: offset µs (-): LegendO[narvik_ntp-p]: offset µs (+): Legend1[narvik_ntp-p]: Time offset in µs (-) Legend2[narvik_ntp-p]: Time offset in µs (+) PageTop[narvik_ntp-p]: <H1>NTP -- PC Narvik</H1> |
Here is a sample of this format of output:
Here is my earlier information on the topic - a text file.
|
|