summaryrefslogtreecommitdiffstats
path: root/contrib/ntp/scripts
diff options
context:
space:
mode:
authorroberto <roberto@FreeBSD.org>2002-10-29 20:11:45 +0000
committerroberto <roberto@FreeBSD.org>2002-10-29 20:11:45 +0000
commit8d541346f2b91896a9ef53cafe2b81898978ccf3 (patch)
treef91b839e392e220c6339f2d08ebca38c28e2f405 /contrib/ntp/scripts
parentf77146900e35a78aaabf5f88d47b7675304c8445 (diff)
downloadFreeBSD-src-8d541346f2b91896a9ef53cafe2b81898978ccf3.zip
FreeBSD-src-8d541346f2b91896a9ef53cafe2b81898978ccf3.tar.gz
Remove files not present in 4.1.1a import.
Diffstat (limited to 'contrib/ntp/scripts')
-rw-r--r--contrib/ntp/scripts/calc_tickadj38
-rwxr-xr-xcontrib/ntp/scripts/checktime79
-rwxr-xr-xcontrib/ntp/scripts/freq_adj97
-rwxr-xr-xcontrib/ntp/scripts/ntpsweep301
-rwxr-xr-xcontrib/ntp/scripts/plot_summary.pl337
-rw-r--r--contrib/ntp/scripts/stats.ulrich.patches1003
-rw-r--r--contrib/ntp/scripts/summary.pl373
7 files changed, 0 insertions, 2228 deletions
diff --git a/contrib/ntp/scripts/calc_tickadj b/contrib/ntp/scripts/calc_tickadj
deleted file mode 100644
index f7a9f9f..0000000
--- a/contrib/ntp/scripts/calc_tickadj
+++ /dev/null
@@ -1,38 +0,0 @@
-#! /usr/local/bin/perl
-#
-# drift of 104.8576 -> +1 tick. Base of 10000 ticks.
-#
-# 970306 HMS Deal with nanoseconds. Fix sign of adjustments.
-
-$df="/etc/ntp.drift";
-# Assumes a 100Hz box with "tick" of 10000
-# Someday, we might call "tickadj" for better values...
-$base=10000; # tick: 1,000,000 / HZ
-$cvt=104.8576; # 2 ** 20 / $base
-$v1=0.;
-$v2="";
-
-if (open(DF, $df))
- {
- if ($_=<DF>)
- {
- ($v1, $v2) = split;
- }
-
- while ($v1 < 0)
- {
- $v1 += $cvt;
- $base--;
- }
-
- while ($v1 > $cvt)
- {
- $v1 -= $cvt;
- $base++;
- }
- }
-
-printf("%.3f (drift)\n", $v1);
-
-printf("%d usec; %d nsec\n", $base, ($base + ($v1/$cvt)) * 1000);
-
diff --git a/contrib/ntp/scripts/checktime b/contrib/ntp/scripts/checktime
deleted file mode 100755
index 850e2ec..0000000
--- a/contrib/ntp/scripts/checktime
+++ /dev/null
@@ -1,79 +0,0 @@
-#!/usr/local/bin/perl
-#!/usr/local/bin/perl -d
-#
-# This script compares the time of several machines with the
-# time on the local host.
-#
-# Use or modify it as you wish.
-#
-# As the original author is only expecting 14 minutes of fame,
-# leaving his name attached would be appreciated.
-#
-# R. Gary Cutbill <rgary@chrysalis.com>
-# 21 April 1999
-#
-$tol=2.0;
-$|=1;
-print "Time Check";
-
-open(HOSTS,"ypcat hosts.byaddr |"); # get a list of hosts from the yp server.
-
-while ($line=<HOSTS>) { # loop for each host getting the offset compared to localhost
- ($addr,$host,$aliases)=split(/\s+/,$line,3);
- $res=`/usr/local/bin/ntptrace -m 1 -r 1 -t 1 $host`;
- print ".";
- chop $res;
- push (@results,$res);
-}
-print "\n";
-
-
-#
-# Sort the list of hosts, and print out there offsets
-# from the local host.
-#
-@list=sort appropriately @results;
-foreach $i ( @list ) {
-
- @dargs=split(/\s+/,$i);
- if ( $dargs[1] eq "\*Timeout\*" ) {
- print "$i\n";
- chop $dargs[0];
- push(@down,$dargs[0]);
- } else {
- printf "%-25s %7s %3s %6s %10s %5s %8s %8s\n",@dargs;
- if ( ( $dargs[4] > $tol ) || ( $dargs[4] < -$tol ) ) {
- chop $dargs[0];
- push(@toofarout,$dargs[0]); }
- }
-}
-#
-# When the above list finishes, hosts that are different by +/- $tol (two seconds)
-# are in @toofarout. Hosts that are down are in @down. They are treated the same
-# way here, but you might want to do something different depending on your site.
-#
-# print a set of suggested rsh commands to run on the hosts that
-# don't have "good" time. "restartntp" is left as an excersize to the reader.
-# I usually use it to kill a running xntpd, ntpdate some server, and the start xntp
-# again.
-#
-print "\nConsider:\n";
-foreach $i ( (@down,@toofarout) ) {
- print " rsh $i sudo restartntp\n";
-}
-
-
-#
-# sort the results from the list. First by stratum, then by time deviation
-# Put hosts that didn't respond (timed out) on the bottom.
-#
-sub appropriately {
- @af=split(/\s+/,$a);
- @bf=split(/\s+/,$b);
- $aba= ($af[4]<0)?-$af[4]:$af[4];
- $abb= ($bf[4]<0)?-$bf[4]:$bf[4];
-
- ( $af[1] ne $bf[1] ) ? $bf[1] cmp $af[1] :
- ( ( $af[2] != $bf[2] ) ? ( $bf[2] <=> $af[2] ) :
- ( ( $aba != $abb ) ? ( $abb <=> $aba ) : ($af[0] cmp $bf[0] ) ) );
-}
diff --git a/contrib/ntp/scripts/freq_adj b/contrib/ntp/scripts/freq_adj
deleted file mode 100755
index 4af4316..0000000
--- a/contrib/ntp/scripts/freq_adj
+++ /dev/null
@@ -1,97 +0,0 @@
-#! /usr/bin/perl -w
-
-die "perl5 needed\n" unless ($] > 5);
-
-use Getopt::Std;
-use vars qw($opt_n);
-
-getopts('d:nt:');
-
-#chop($ncpu = `sysctl -n hw.ncpu`);
-#die "Found $ncpu CPUs; can only be run on systems with 1 CPU.\n" if ($ncpu > 1);
-
-$driftfile = "/etc/ntp.drift";
-$driftfile = $opt_d if defined($opt_d);
-
-chop($timer = `sysctl -n kern.timecounter.hardware 2> /dev/null`);
-
-$timer =~ tr/\U/\L/;
-
-if ($timer eq '') {
- open(DM, "/var/run/dmesg.boot");
- while(<DM>) {
- # Timecounter "i8254" frequency 1193182 Hz
- if (/^Timecounter "(\w+)"\s+/) {
- $timer = $1;
- last;
- }
- }
- close(DM);
-}
-
-$opt_t = $timer if !defined($opt_t);
-
-if ($timer ne '') { # $timer found...
- if ($opt_t ne '') { # - and $opt_t found
- if ($timer ne $opt_t) { # - - and they differ
- warn "You specified a $opt_t timer but I detected a $timer timer.\n";
- usage();
- exit 1;
- } else { # - - and they are the same
- ;
- }
- } else { # - but no $opt_t specified; this is OK
- ;
- }
-} else { # No $timer found...
- if ($opt_t ne '') { # - but $opt_t was specified
- $timer = $opt_t; # - - so use it.
- } else { # - and neither was $opt_t
- warn "I can't tell what timer you have. Please specify one.\n";
- usage();
- exit 1;
- }
-}
-
-open(DF, $driftfile) || die "Can't open driftfile ($driftfile): $!\n";
-while(<DF>) {
- chop;
- if (/^(-?\d+\.\d+)(\s\d)?$/) {
- $drift = $1;
- } else {
- die "Bogus value in driftfile $driftfile: <$_>\n";
- }
-}
-close(DF);
-
-print "NTP drift is <$drift>\n";
-
-# Convert from NTP's idea of PPM to a decimal equivalent
-$freq_adj = int ( $drift * ( 10 ** 6 / 2 ** 20) );
-print "normalized freq_adj is <$freq_adj>\n";
-
-$freq_adj = int ( ( $freq_adj - 1 ) / 2 );
-print "Applying freq_adj of <".-$freq_adj.">\n";
-
-$sysctl = "machdep.".$timer."_freq";
-
-chop($mach_freq = `sysctl -n $sysctl`);
-
-print "$sysctl is <$mach_freq>\n";
-
-$n_mach_freq = $mach_freq - $freq_adj;
-
-if (defined($opt_n)) {
- print "$sysctl $mach_freq -> $n_mach_freq\n";
-} else {
- print "i8254: ".`sysctl -w $sysctl=$n_mach_freq`;
-}
-
-sub usage {
- print STDERR <<EOUsage
-Usage: $0 [-d drift_file] [-n] [-t timer]
-where "drift_file" defaults to /etc/ntp.drift
-and "timer" is usually "tsc" or "i8254"
-and "-n" says "don't really change anything, just say what would happen".
-EOUsage
-}
diff --git a/contrib/ntp/scripts/ntpsweep b/contrib/ntp/scripts/ntpsweep
deleted file mode 100755
index ab2e884..0000000
--- a/contrib/ntp/scripts/ntpsweep
+++ /dev/null
@@ -1,301 +0,0 @@
-#!/usr/local/bin/perl -w
-#
-# $Id: ntpsweep,v 1.3 2000/01/15 07:37:52 stenn Exp $
-#
-# DISCLAIMER
-#
-# Copyright (C) 1999,2000 Hans Lambermont and Origin B.V.
-#
-# Permission to use, copy, modify and distribute this software and its
-# documentation for any purpose and without fee is hereby granted,
-# provided that the above copyright notice appears in all copies and
-# that both the copyright notice and this permission notice appear in
-# supporting documentation. This software is supported as is and without
-# any express or implied warranties, including, without limitation, the
-# implied warranties of merchantability and fitness for a particular
-# purpose. The name Origin B.V. must not be used to endorse or promote
-# products derived from this software without prior written permission.
-#
-# Hans Lambermont <Hans.Lambermont@nl.origin-it.com>/<H.Lambermont@chello.nl>
-# 14 Jan 2000
-
-require 5.0; # But actually tested on 5.004 ;)
-use Getopt::Long; # GetOptions()
-use strict;
-
-my $version = 1.3;
-(my $program = $0) =~ s%.*/(.+?)(.pl)?$%$1%;
-
-# Hardcoded paths/program names
-my $ntpdate = "ntpdate";
-my $ntpq = "ntpq";
-
-# no STDOUT buffering
-$| = 1;
-
-my ($help, $single_host, $showpeers, $maxlevel, $strip, $askversion);
-my $res = GetOptions("help!" => \$help,
- "host=s" => \$single_host,
- "peers!" => \$showpeers,
- "maxlevel=s" => \$maxlevel,
- "strip=s" => \$strip,
- "version!" => \$askversion);
-
-if ($askversion) {
- print("$version\n");
- exit 0;
-}
-
-if ($help || ((@ARGV != 1) && !$single_host)) {
- warn <<EOF;
-This is $program, version $version
-Copyright (C) 1999,2000 Hans Lambermont and Origin B.V. Disclaimer inside.
-
-Usage:
- $program [--help|--peers|--strip <string>|--maxlevel <level>|--version] \\
- <file>|[--host <hostname>]
-
-Description:
- $program prints per host given in <file> the NTP stratum level, the
- clock offset in seconds, the daemon version, the operating system and
- the processor. Optionally recursing through all peers.
-
-Options:
---help
- Print this short help text and exit.
---version
- Print version ($version) and exit.
-<file>
- Specify hosts file. File format is one hostname or ip number per line.
- Lines beginning with # are considered as comment.
---host <hostname>
- Speficy a single host, bypassing the need for a hosts file.
---peers
- Recursively list all peers a host synchronizes to.
- An '= ' before a peer means a loop. Recursion stops here.
---maxlevel <level>
- Traverse peers up to this level (4 is a reasonable number).
---strip <string>
- Strip <string> from hostnames.
-
-Examples:
- $program myhosts.txt --strip .foo.com
- $program --host some.host --peers --maxlevel 4
-EOF
- exit 1;
-}
-
-my $hostsfile = shift;
-my (@hosts, @known_hosts);
-my (%known_host_info, %known_host_peers);
-
-sub read_hosts()
-{
- local *HOSTS;
- open (HOSTS, $hostsfile) ||
- die "$program: FATAL: unable to read $hostsfile: $!\n";
- while (<HOSTS>) {
- next if /^\s*(#|$)/; # comment/empty
- chomp;
- push(@hosts, $_);
- }
- close(HOSTS);
-}
-
-# translate IP to hostname if possible
-sub ip2name {
- my($ip) = @_;
- my($addr, $name, $aliases, $addrtype, $length, @addrs);
- $addr = pack('C4', split(/\./, $ip));
- ($name, $aliases, $addrtype, $length, @addrs) = gethostbyaddr($addr, 2);
- if ($name) {
- # return lower case name
- return("\L$name");
- } else {
- return($ip);
- }
-}
-
-# item_in_list($item, @list): returns 1 if $item is in @list, 0 if not
-sub item_in_list {
- my($item, @list) = @_;
- my($i);
- foreach $i (@list) {
- return 1 if ($item eq $i);
- }
- return 0;
-}
-
-sub scan_host($;$;$) {
- my($host, $level, @trace) = @_;
- my $stratum = 0;
- my $offset = 0;
- my $daemonversion = "";
- my $system = "";
- my $processor = "";
- my @peers;
- my $known_host = 0;
-
- if (&item_in_list($host, @known_hosts)) {
- $known_host = 1;
- } else {
- # ntpdate part
- open(NTPDATE, "$ntpdate -bd $host 2>/dev/null |") ||
- die "Cannot open ntpdate pipe: $!\n";
- while (<NTPDATE>) {
- /^stratum\s+(\d+).*$/ && do {
- $stratum = $1;
- };
- /^offset\s+([0-9.-]+)$/ && do {
- $offset = $1;
- };
- }
- close(NTPDATE);
-
- # got answers ? If so, go on.
- if ($stratum) {
- # ntpq part
- my $ntpqparams = "-c 'rv 0 processor,system,daemon_version'";
- open(NTPQ, "$ntpq $ntpqparams $host 2>/dev/null |") ||
- die "Cannot open ntpq pipe: $!\n";
- while (<NTPQ>) {
- /daemon_version="(.*)"/ && do {
- $daemonversion = $1;
- };
- /system="([^"]*)"/ && do {
- $system = $1;
- };
- /processor="([^"]*)"/ && do {
- $processor = $1;
- };
- }
- close(NTPQ);
-
- # Shorten daemon_version string.
- $daemonversion =~ s/(;|Mon|Tue|Wed|Thu|Fri|Sat|Sun).*$//;
- $daemonversion =~ s/version=//;
- $daemonversion =~ s/(x|)ntpd //;
- $daemonversion =~ s/(\(|\))//g;
- $daemonversion =~ s/beta/b/;
- $daemonversion =~ s/multicast/mc/;
-
- # Shorten system string
- $system =~ s/UNIX\///;
- $system =~ s/RELEASE/r/;
- $system =~ s/CURRENT/c/;
-
- # Shorten processor string
- $processor =~ s/unknown//;
- }
-
- # got answers ? If so, go on.
- if ($daemonversion) {
- # ntpq again, find out the peers this time
- if ($showpeers) {
- my $ntpqparams = "-pn";
- open(NTPQ, "$ntpq $ntpqparams $host 2>/dev/null |") ||
- die "Cannot open ntpq pipe: $!\n";
- while (<NTPQ>) {
- /^No association ID's returned$/ && do {
- last;
- };
- /^ remote/ && do {
- next;
- };
- /^==/ && do {
- next;
- };
- /^( |x|\.|-|\+|#|\*|o)([^ ]+)/ && do {
- push(@peers, ip2name($2));
- next;
- };
- print "ERROR: $_";
- }
- close(NTPQ);
- }
- }
-
- # Add scanned host to known_hosts array
- push(@known_hosts, $host);
- if ($stratum) {
- $known_host_info{$host} = sprintf("%2d %9.3f %-11s %-12s %s",
- $stratum, $offset, substr($daemonversion,0,11),
- substr($system,0,12), substr($processor,0,9));
- } else {
- # Stratum level 0 is consider invalid
- $known_host_info{$host} = sprintf(" ?");
- }
- $known_host_peers{$host} = [@peers];
- }
-
- if ($stratum || $known_host) { # Valid or known host
- my $printhost = ' ' x $level . $host;
- # Shorten host string
- if ($strip) {
- $printhost =~ s/$strip//;
- }
- # append number of peers in brackets if requested and valid
- if ($showpeers && ($known_host_info{$host} ne " ?")) {
- $printhost .= " (" . @{$known_host_peers{$host}} . ")";
- }
- # Finally print complete host line
- printf("%-32s %s\n",
- substr($printhost,0,32), $known_host_info{$host});
- if ($showpeers && (eval($maxlevel ? $level < $maxlevel : 1))) {
- my $peer;
- push(@trace, $host);
- # Loop through peers
- foreach $peer (@{$known_host_peers{$host}}) {
- if (&item_in_list($peer, @trace)) {
- # we've detected a loop !
- $printhost = ' ' x ($level + 1) . "= " . $peer;
- # Shorten host string
- if ($strip) {
- $printhost =~ s/$strip//;
- }
- printf("%-32s %s\n",
- substr($printhost,0,32));
- } else {
- if (substr($peer,0,3) ne "127") {
- &scan_host($peer, $level + 1, @trace);
- }
- }
- }
- }
- } else { # We did not get answers from this host
- my $printhost = ' ' x $level . $host;
- # Shorten host string
- if ($strip) {
- $printhost =~ s/$strip//;
- }
- printf("%-32s ?\n", substr($printhost,0,32));
- }
-}
-
-sub scan_hosts()
-{
- my $host;
- for $host (@hosts) {
- my @trace;
- push(@trace, $host);
- scan_host($host, 0, @trace);
- }
-}
-
-# Main program
-
-if ($single_host) {
- push(@hosts, $single_host);
-} else {
- &read_hosts($hostsfile);
-}
-
-# Print header
-print <<EOF;
-Host st offset(s) version system processor
---------------------------------+--+---------+-----------+------------+---------
-EOF
-
-&scan_hosts();
-
-exit 0;
diff --git a/contrib/ntp/scripts/plot_summary.pl b/contrib/ntp/scripts/plot_summary.pl
deleted file mode 100755
index b0e9a4a..0000000
--- a/contrib/ntp/scripts/plot_summary.pl
+++ /dev/null
@@ -1,337 +0,0 @@
-#!/usr/bin/perl -w
-# $Id: plot_summary.pl,v 1.2 1999/12/02 01:59:05 stenn Exp $
-#
-# Use Gnuplot to display data in summary files produced by summary.pl.
-# This script requires GNUPLOT 3.7!
-#
-# Copyright (c) 1997, 1999 by Ulrich Windl <Ulrich.Windl@rz.uni-regensburg.de>
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-require 5.003; # "never tested with any other version of Perl"
-use strict;
-
-use Time::Local;
-use Getopt::Long;
-
-# parse command line
-my $summary_dir = "/tmp";
-my $identifier = "host " . `hostname`; # origin of these data
-chomp $identifier; # remove newline
-my $offset_limit = 0.128; # limit of absolute offset
-my $output_file = ""; # output file defaults to stdout
-my $output_file_number = 1; # numbering of output files
-my $gnuplot_terminal = $ENV{DISPLAY} ? "x11" : "dumb";
-my $wait_after_plot = 1;
-my @peer_list = ();
-
-my %options = ("directory|input-directory=s" => \$summary_dir,
- "identifier=s" => \$identifier,
- "offset-limit=f" => \$offset_limit,
- "output-file=s" => \$output_file,
- "peer=s@" => \@peer_list,
- "plot-term|gnuplot-term=s" => \$gnuplot_terminal,
- "wait-after-plot!" => \$wait_after_plot,
- );
-
-if ( !GetOptions(%options) )
-{
- print STDERR "valid options for $0 are:\n";
- my $opt;
- foreach $opt (sort(keys %options)) {
- print STDERR "\t--$opt\t(default is ";
- if ( ref($options{$opt}) eq "ARRAY" ) {
- print STDERR join(", ", map { "'$_'" } @{$options{$opt}});
- } else {
- print STDERR "'${$options{$opt}}'";
- }
- print STDERR ")\n";
- }
- print STDERR "\n";
- die;
-}
-
-chomp $identifier;
-die "illegal offset-limit: $offset_limit" unless $offset_limit > 0.0;
-$offset_limit *= 1e6; # scale to microseconds
-
-# return the smallest value in the given list
-sub min
-{
- my ($result, @rest) = @_;
- map { $result = $_ if ($_ < $result) } @rest;
- return($result);
-}
-
-# return the largest value in the given list
-sub max
-{
- my ($result, @rest) = @_;
- map { $result = $_ if ($_ > $result) } @rest;
- return($result);
-}
-
-# maybe open alternate output file
-sub open_output
-{
- my $file;
- if ($output_file) {
- while ( -r ($file = "$output_file$output_file_number") ) {
- ++$output_file_number;
- }
- open TOUCH, ">$file" and close TOUCH or die "$file: $!";
- print "set output \"$file\"\n";
- }
-}
-
-# make Gnuplot wait
-sub maybe_add_pause
-{
- print "pause -1 \"Press key to continue...\"\n" if $wait_after_plot;
-}
-
-# plot data from loop summary
-sub do_loop
-{
- my $fname = shift;
- my $line;
- my $out_file = "/tmp/tempdata$$";
- my $cmd_file = "/tmp/tempcmd$$";
- my ($first_day, $day_out) = ("", 0);
- my ($lower_bound, $upper_bound, $rms);
- my ($min_offs, $max_offs) = (1e9, -1e9);
- my ($min_rms, $max_rms) = (1e9, -1e9);
- open INPUT, "$fname" or die "$fname: $!";
- open OUTPUT, ">$out_file" or die "$out_file: $!";
- my @Fld;
- while (<INPUT>) {
- chop; # strip record separator
- @Fld = split;
- if ($#Fld == 0) {
-# loops.19960405
- $_ = $Fld[0]; s/.*([12]\d{3}[01]\d[0-3]\d)$/$1/;
- m/(\d{4})(\d{2})(\d{2})/;
- $line = timegm(59, 59, 23, $3, $2 - 1, $1 - 1900, 0, 0, 0);
- $line = int $line / 86400; # days relative to 1970
- $first_day = "$1-$2-$3 ($line)" unless $day_out;
- next;
- }
- if ($#Fld != 8) {
- warn "Illegal number of fields in file $fname, line $.";
- next;
- }
-# loop 216, 856106+/-874041.5, rms 117239.8, freq 67.52+/-10.335, var 4.850
- $_ = $Fld[1]; s/,/ /; $line .= " $_";
- $_ = $Fld[2]; m:(.+?)\+/-(.+),:;
- $lower_bound = $1 - $2;
- $upper_bound = $1 + $2;
- $line .= "$1 $lower_bound $upper_bound";
- $min_offs = min($min_offs, $lower_bound);
- $max_offs = max($max_offs, $upper_bound);
- $_ = $Fld[4]; s/,/ /; $rms = $_;
- $min_rms = min($min_rms, $rms);
- $max_rms = max($max_rms, $rms);
- $line .= " $rms";
- $_ = $Fld[6]; m:(.+?)\+/-(.+),:;
- $line .= " $1 " . ($1-$2) . " " . ($1+$2);
- $line .= " $Fld[8]";
- print OUTPUT "$line\n";
- $day_out = 1;
-# 9621 216 856106 -17935.5 1730147.5 117239.8 67.52 57.185 77.855 4.850
- }
- close INPUT;
- close OUTPUT or die "close failed on $out_file: $!";
- my $ylimit = "[";
- if ($min_offs < -$offset_limit) {
- $ylimit .= "-$offset_limit";
- }
- $ylimit .= ":";
- if ($max_offs > $offset_limit) {
- $ylimit .= "$offset_limit";
- }
- if ( $ylimit eq "[:" ) {
- $ylimit = "";
- } else {
- $ylimit = "[] $ylimit]";
- }
-# build command file for GNUplot
- open OUTPUT, "> $cmd_file" or die "$cmd_file: $!";
- my $oldfh = select OUTPUT;
- print "set term $gnuplot_terminal\n";
- open_output;
- print "set grid\n";
- print "set title \"Loop Summary for $identifier: " .
- "Daily mean values since $first_day\\n" .
- "(Offset limit is $offset_limit microseconds)\"\n";
- print "set ylabel \"[us]\"\n";
- print "set data style yerrorbars\n";
- print "set multiplot\n";
- print "set size 1, 0.5\n";
- print "set lmargin 8\n";
- print "set origin 0, 0.5\n";
- print "plot $ylimit \"$out_file\"" .
- " using 1:3:4:5 title \"mean offset\", ";
- print "\"$out_file\" using 1:(\$3-\$6/2) " .
- "title \"(sigma low)\" with lines, ";
- print "\"$out_file\" using 1:3 smooth bezier " .
- "title \"(Bezier med)\" with lines, ";
- print "\"$out_file\" using 1:(\$3+\$6/2) " .
- "title \"(sigma high)\" with lines\n";
- print "set ylabel \"[ppm]\"\n";
- print "set origin 0, 0.0\n";
- print "set title\n";
- print "set xlabel \"Days relative to 1970\"\n";
- print "plot \"$out_file\" using 1:7:8:9 title \"mean frequency\", ";
- print "\"$out_file\" using 1:(\$7-\$10/2) " .
- "title \"(sigma low)\" with lines, ";
- print "\"$out_file\" using 1:7 smooth bezier " .
- "title \"(Bezier med)\" with lines, ";
- print "\"$out_file\" using 1:(\$7+\$10/2) " .
- "title \"(sigma high)\" with lines\n";
- print "set nomultiplot\n";
- maybe_add_pause;
-
- $ylimit = "[";
- if ($min_rms < -$offset_limit) {
- $ylimit .= "-$offset_limit";
- }
- $ylimit .= ":";
- if ($max_rms > $offset_limit) {
- $ylimit .= "$offset_limit";
- }
- if ( $ylimit eq "[:" ) {
- $ylimit ="";
- } else {
- $ylimit = "[] $ylimit]";
- }
-
- open_output;
- print "set title \"Loop Summary for $identifier: " .
- "Standard deviation since $first_day\\n" .
- "(Offset limit is $offset_limit microseconds)\"\n";
- print "set xlabel\n";
- print "set ylabel \"[us]\"\n";
- print "set origin 0, 0.5\n";
- print "set data style linespoints\n";
- print "set multiplot\n";
- print "plot $ylimit \"$out_file\" using 1:6 title \"Offset\", ";
- print "\"$out_file\" using 1:6 smooth bezier " .
- "title \"(Bezier)\" with lines\n";
- print "set title\n";
- print "set origin 0, 0.0\n";
- print "set xlabel \"Days relative to 1970\"\n";
- print "set ylabel \"[ppm]\"\n";
- print "plot \"$out_file\" using 1:10 title \"Frequency\", ";
- print "\"$out_file\" using 1:10 smooth bezier " .
- "title \"(Bezier)\" with lines\n";
- print "set nomultiplot\n";
- maybe_add_pause;
-
- close OUTPUT or die "close failed on $cmd_file: $!";
- select $oldfh;
- print `gnuplot $cmd_file`;
- unlink $cmd_file;
- unlink $out_file;
-}
-
-# plot data form peer summary
-sub do_peer
-{
- my $fname = shift;
- my $peer = shift;
- my $out_file = "/tmp/tempdata$$";
- my $cmd_file = "/tmp/tempcmd$$";
- my $line;
- my ($first_day, $day_out) = ("", 0);
- open INPUT, "$fname" or die "$fname: $!";
- open OUTPUT, ">$out_file" or die "$out_file: $!";
- my @Fld;
- while (<INPUT>) {
- chop; # strip record separator
- @Fld = split;
- if ($#Fld == 0) {
-# peers.19960405
- $_ = $Fld[0]; s/.*([12]\d{3}[01]\d[0-3]\d)$/$1/;
- m/(\d{4})(\d{2})(\d{2})/ or next;
- $line = timegm(59, 59, 23, $3, $2 - 1, $1 - 1900, 0, 0, 0);
- $line = int $line / 86400; # days relative to 1970
- $first_day = "$1-$2-$3 ($line)" unless $day_out;
- next;
- }
- if ($#Fld != 7) {
- warn "Illegal number of fields in file $fname, line $.";
- next;
- }
- next if ($Fld[0] ne $peer);
-# ident cnt mean rms max delay dist disp
-# 127.127.8.1 38 30.972 189.867 1154.607 0.000 879.760 111.037
- $Fld[0] = $line;
- print OUTPUT join(' ', @Fld) . "\n";
-# 9969 38 30.972 189.867 1154.607 0.000 879.760 111.037
- $day_out = 1;
- }
- close INPUT;
- close OUTPUT or die "close failed on $out_file: $!";
- die "no data found for peer $peer" if !$day_out;
- open OUTPUT, "> $cmd_file" or die "$cmd_file: $!";
- my $oldfh = select OUTPUT;
- print "set term $gnuplot_terminal\n";
- open_output;
- print "set grid\n";
- print "set multiplot\n";
- print "set lmargin 8\n";
- print "set size 1, 0.34\n";
- print "set origin 0, 0.66\n";
- print "set title " .
- "\"Peer Summary for $peer on $identifier since $first_day\"\n";
- print "set data style linespoints\n";
- print "set ylabel \"[us]\"\n";
- print "plot \"$out_file\" using 1:3 title \"mean offset\", ";
- print "\"$out_file\" using 1:3 smooth bezier " .
- "title \"(Bezier)\" with lines, ";
- print "\"$out_file\" using 1:(\$3-\$7/2) " .
- "title \"(sigma low)\" with lines, ";
- print "\"$out_file\" using 1:(\$3+\$7/2) " .
- "title \"(sigma high)\" with lines\n";
- print "set title\n";
- print "set origin 0, 0.34\n";
- print "set size 1, 0.32\n";
- print "set ylabel\n";
- print "plot \"$out_file\" using 1:7 title \"dist\", ";
- print "\"$out_file\" using 1:7 smooth bezier " .
- "title \"(Bezier)\" with lines\n";
- print "set origin 0, 0.00\n";
- print "set size 1, 0.35\n";
- print "set xlabel \"Days relative to 1970\"\n";
- print "plot \"$out_file\" using 1:8 title \"disp\", ";
- print "\"$out_file\" using 1:8 smooth bezier " .
- "title \"(Bezier)\" with lines\n";
- print "set nomultiplot\n";
- maybe_add_pause;
-
- select $oldfh;
- close OUTPUT or die "close failed on $cmd_file: $!";
- print `gnuplot $cmd_file`;
- unlink $cmd_file;
- unlink $out_file;
-}
-
-
-my $loop_summary ="$summary_dir/loop_summary";
-my $peer_summary ="$summary_dir/peer_summary";
-my $clock_summary="$summary_dir/clock_summary";
-
-do_loop $loop_summary;
-map { do_peer $peer_summary, $_ } @peer_list;
diff --git a/contrib/ntp/scripts/stats.ulrich.patches b/contrib/ntp/scripts/stats.ulrich.patches
deleted file mode 100644
index fe642f6..0000000
--- a/contrib/ntp/scripts/stats.ulrich.patches
+++ /dev/null
@@ -1,1003 +0,0 @@
-
-Received: from huey2.ee.udel.edu by mail.eecis.udel.edu id aa25207;
- 10 Dec 1997 10:39 EST
-Received: from copland.udel.edu by huey.udel.edu id aa16958;
- 10 Dec 1997 10:39 EST
-Received: from rrzs2.rz.uni-regensburg.de (rrzs2.rz.uni-regensburg.de [132.199.1.2]) by copland.udel.edu (8.8.5/8.7.3) with ESMTP id KAA21293 for <mills@udel.edu>; Wed, 10 Dec 1997 10:39:12 -0500 (EST)
-Received: from ngate.ngate.uni-regensburg.de (ngate.rz.uni-regensburg.de [132.199.3.13])
- by rrzs2.rz.uni-regensburg.de (8.8.5/8.8.5) with SMTP id QAA19974
- for <mills@udel.edu>; Wed, 10 Dec 1997 16:38:42 +0100 (MET)
-Received: from rkdvmks1.ngate.uni-regensburg.de by ngate.ngate.uni-regensburg.de; Wed, 10 Dec 97 16:39 MET
-Received: from rkdvmks1.ngate.uni-regensburg.de by kgate.ngate.uni-regensburg.de; Wed, 10 Dec 97 15:38 GMT
-Received: from RKDVMKS1/SpoolDir by rkdvmks1.ngate.uni-regensburg.de (Mercury 1.32);
- 10 Dec 97 16:38:34 +0100
-Received: from SpoolDir by RKDVMKS1 (Mercury 1.32); 10 Dec 97 16:38:06 +0100
-From: Ulrich Windl <ulrich.windl@rz.uni-regensburg.de>
-Organization: Universitaet Regensburg, Klinikum
-To: mills@udel.edu
-Date: Wed, 10 Dec 1997 16:38:04 +0100
-MIME-Version: 1.0
-Content-Type: text/plain; charset=US-ASCII
-Content-transfer-encoding: 7BIT
-Subject: Big patch to scripts/monitoring
-Priority: normal
-X-mailer: Pegasus Mail for Windows (v2.53/R1)
-Message-ID: <103AB9D209F5@rkdvmks1.ngate.uni-regensburg.de>
-
-Dave, there's another big patch against scripts/monitoring. The Perl
-programs in there are rather old. As they are quite nice thogh, I
-decided to update them for the latest version of Perl, namely 5.004.
-
-I'll include the description of changes and the patch.
-
-Ulrich
-
-Here is a description of changes made in ntploopwatch:
-
-Corrected most warnings that PERL 5.004 might emit. Corrected signal
-handlers to make them work again. Corrected scaling (at least I
-think). Supported case when output is sent to file or printer and
-there is no X11 available. Fixed number of month in xlabels of the
-plot.
-
-Added the ability to specify printer for GNUplot other that
-PostScript. Use hostname if $STATHOST is not given in configuration
-file. Corrected verbosity level for some messages. Added ability to
-specify a non-standard print command.
-
-Perl 5.004_04 does no longer ignore ``-w--*-perl-*-''. Made some
-cosmetic changes and added a timescale of 10 minutes.
-
-(Other programs are functionally unchanged. lr.pl is a PERL module now.)
-
-
-Index: README
-===================================================================
-RCS file: /home/windl/NTP/mon-REP/monitoring/README,v
-retrieving revision 1.1.1.1
-retrieving revision 1.2
-diff -u -r1.1.1.1 -r1.2
---- README 1993/08/24 19:29:34 1.1.1.1
-+++ README 1997/10/23 17:51:37 1.2
-@@ -1,14 +1,14 @@
- This directory contains support for monitoring the local clock of xntp daemons.
-
--WARNING: The scripts and routines contained in this directory are bete realease!
-- Do not depend on their correct operation. They are, however, in regular
-- use at University of Erlangen-Nuernberg. No severe problems are known
-- for this code.
-+WARNING: The scripts and routines contained in this directory are beta
-+ release! Do not depend on their correct operation. They are,
-+ however, in regular use at University of Erlangen-Nuernberg.
-+ No severe problems are known for this code.
-
- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- PLEASE THINK TWICE BEFORE STARTING MONITORING REMOTE XNTP DEAMONS !!!!
- MONITORING MAY INCREASE THE LOAD OF THE DEAMON MONITORED AND MAY
--INCREASE THE NETWORK LOAD SIGNIFICANTLY
-+INCREASE THE NETWORK LOAD SIGNIFICANTLY
- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-
-@@ -23,8 +23,8 @@
- It sends a set_trap request to each server given and dumps the
- trap messages received. It handles refresh of set_trap.
- Currently it handles only NTP V2, however the NTP V3 servers
-- also accept v2 requests. It will not interpret v3 system and peer
-- stati correctly.
-+ also accept v2 requests. It will not interpret v3 system and
-+ peer stati correctly.
-
- usage:
- ntptrap [-n] [-p <port>] [-l <debug-output>] servers...
-@@ -72,7 +72,9 @@
-
- if a timeout occurs the next sample is tried after delay/2 seconds
-
-- The script will terminate after MAX_FAIL (currently 60) consecutive errors.
-+ The script will terminate after MAX_FAIL (currently 60)
-+ consecutive errors.
-+
- Errors are counted for:
- - error on send call
- - error on select call
-@@ -114,10 +116,10 @@
- command line values would be replaced by settings from the config file.
-
- printer: specify printer to print plot
-- BSD print systems semantics apply; if printer is omitted
-- the name "ps" is used; plots are prepared using
-- PostScript, thus the printer should best accept
-- postscript input
-+ BSD print systems semantics apply; if printer
-+ is omitted the name "ps" is used; plots are
-+ prepared using PostScript, thus the printer
-+ should best accept postscript input
-
- For the following see also the comments in loopwatch.config.SAMPLE
-
-@@ -139,8 +141,10 @@
- within display range
-
- timelocal.pl:
-- used during conversion of ISO_DATE_TIME values specified in loopwatch
-- config files to unix epoch values (seconds since 1970-01-01_00:00_00 UTC)
-+
-+ used during conversion of ISO_DATE_TIME values specified in
-+ loopwatch config files to unix epoch values (seconds since
-+ 1970-01-01_00:00_00 UTC)
-
- A version of this file is distributed with perl-4.x, however,
- it has a bug related to dates crossing 1970, causing endless loops..
-Index: lr.pl
-===================================================================
-RCS file: /home/windl/NTP/mon-REP/monitoring/lr.pl,v
-retrieving revision 1.1.1.1
-retrieving revision 1.4
-diff -u -r1.1.1.1 -r1.4
---- lr.pl 1993/08/24 19:29:33 1.1.1.1
-+++ lr.pl 1997/10/23 17:51:37 1.4
-@@ -9,9 +9,14 @@
- ;# Frank Kardel, Rainer Pruy
- ;# Friedrich-Alexander Universitaet Erlangen-Nuernberg
- ;#
-+;# Copyright (c) 1997 by
-+;# Ulrich Windl <Ulrich.Windl@rz.uni-regensburg.de>
-+;# (Converted to a PERL 5.004 package)
- ;#
- ;#############################################################
-
-+package lr;
-+
- ##
- ## y = A + Bx
- ##
-@@ -23,123 +28,124 @@
- ##
- ## interface
- ##
--*lr_init = *lr'lr_init; #';# &lr_init(tag); initialize data set for tag
--*lr_sample = *lr'lr_sample; #';# &lr_sample(x,y,tag); enter sample
--*lr_Y = *lr'lr_Y; #';# &lr_Y(x,tag); compute y for given x
--*lr_X = *lr'lr_X; #';# &lr_X(y,tag); compute x for given y
--*lr_r = *lr'lr_r; #';# &lr_r(tag); regression coeffizient
--*lr_cov = *lr'lr_cov; #';# &lr_cov(tag); covariance
--*lr_A = *lr'lr_A; #';# &lr_A(tag);
--*lr_B = *lr'lr_B; #';# &lr_B(tag);
--*lr_sigma = *lr'lr_sigma; #';# &lr_sigma(tag); standard deviation
--*lr_mean = *lr'lr_mean; #';# &lr_mean(tag);
-+;# init(tag); initialize data set for tag
-+;# sample(x, y, tag); enter sample
-+;# Y(x, tag); compute y for given x
-+;# X(y, tag); compute x for given y
-+;# r(tag); regression coefficient
-+;# cov(tag); covariance
-+;# A(tag);
-+;# B(tag);
-+;# sigma(tag); standard deviation
-+;# mean(tag);
- #########################
-
--package lr;
--
--sub tagify
--{
-- local($tag) = @_;
-- if (defined($tag))
-- {
-- *lr_n = eval "*${tag}_n";
-- *lr_sx = eval "*${tag}_sx";
-- *lr_sx2 = eval "*${tag}_sx2";
-- *lr_sxy = eval "*${tag}_sxy";
-- *lr_sy = eval "*${tag}_sy";
-- *lr_sy2 = eval "*${tag}_sy2";
-- }
--}
--
--sub lr_init
-+sub init
- {
-- &tagify($_[$[]) if defined($_[$[]);
-+ my $self = shift;
-
-- $lr_n = 0;
-- $lr_sx = 0.0;
-- $lr_sx2 = 0.0;
-- $lr_sxy = 0.0;
-- $lr_sy = 0.0;
-- $lr_sy2 = 0.0;
-+ $self->{n} = 0;
-+ $self->{sx} = 0.0;
-+ $self->{sx2} = 0.0;
-+ $self->{sxy} = 0.0;
-+ $self->{sy} = 0.0;
-+ $self->{sy2} = 0.0;
- }
-
--sub lr_sample
-+sub sample($$$)
- {
-- local($_x, $_y) = @_;
--
-- &tagify($_[$[+2]) if defined($_[$[+2]);
-+ my $self = shift;
-+ my($_x, $_y) = @_;
-
-- $lr_n++;
-- $lr_sx += $_x;
-- $lr_sy += $_y;
-- $lr_sxy += $_x * $_y;
-- $lr_sx2 += $_x**2;
-- $lr_sy2 += $_y**2;
-+ ++($self->{n});
-+ $self->{sx} += $_x;
-+ $self->{sy} += $_y;
-+ $self->{sxy} += $_x * $_y;
-+ $self->{sx2} += $_x**2;
-+ $self->{sy2} += $_y**2;
- }
-
--sub lr_B
-+sub B($)
- {
-- &tagify($_[$[]) if defined($_[$[]);
-+ my $self = shift;
-
-- return 1 unless ($lr_n * $lr_sx2 - $lr_sx**2);
-- return ($lr_n * $lr_sxy - $lr_sx * $lr_sy) / ($lr_n * $lr_sx2 - $lr_sx**2);
-+ return 1 unless ($self->{n} * $self->{sx2} - $self->{sx}**2);
-+ return ($self->{n} * $self->{sxy} - $self->{sx} * $self->{sy})
-+ / ($self->{n} * $self->{sx2} - $self->{sx}**2);
- }
-
--sub lr_A
-+sub A($)
- {
-- &tagify($_[$[]) if defined($_[$[]);
-+ my $self = shift;
-
-- return ($lr_sy - &lr_B * $lr_sx) / $lr_n;
-+ return ($self->{sy} - B($self) * $self->{sx}) / $self->{n};
- }
-
--sub lr_Y
-+sub Y($$)
- {
-- &tagify($_[$[]) if defined($_[$[]);
-+ my $self = shift;
-
-- return &lr_A + &lr_B * $_[$[];
-+ return A($self) + B($self) * $_[$[];
- }
-
--sub lr_X
-+sub X($$)
- {
-- &tagify($_[$[]) if defined($_[$[]);
-+ my $self = shift;
-
-- return ($_[$[] - &lr_A) / &lr_B;
-+ return ($_[$[] - A($self)) / B($self);
- }
-
--sub lr_r
-+sub r($)
- {
-- &tagify($_[$[]) if defined($_[$[]);
-+ my $self = shift;
-
-- local($s) = ($lr_n * $lr_sx2 - $lr_sx**2) * ($lr_n * $lr_sy2 - $lr_sy**2);
-+ my $s = ($self->{n} * $self->{sx2} - $self->{sx}**2)
-+ * ($self->{n} * $self->{sy2} - $self->{sy}**2);
-
- return 1 unless $s;
-
-- return ($lr_n * $lr_sxy - $lr_sx * $lr_sy) / sqrt($s);
-+ return ($self->{n} * $self->{sxy} - $self->{sx} * $self->{sy}) / sqrt($s);
- }
-
--sub lr_cov
-+sub cov($)
- {
-- &tagify($_[$[]) if defined($_[$[]);
-+ my $self = shift;
-
-- return ($lr_sxy - $lr_sx * $lr_sy / $lr_n) / ($lr_n - 1);
-+ return ($self->{sxy} - $self->{sx} * $self->{sy} / $self->{n})
-+ / ($self->{n} - 1);
- }
-
--sub lr_sigma
-+sub sigma($)
- {
-- &tagify($_[$[]) if defined($_[$[]);
-+ my $self = shift;
-
-- return 0 if $lr_n <= 1;
-- return sqrt(($lr_sy2 - ($lr_sy * $lr_sy) / $lr_n) / ($lr_n));
-+ return 0 if $self->{n} <= 1;
-+ return sqrt(($self->{sy2} - ($self->{sy} * $self->{sy}) / $self->{n})
-+ / ($self->{n}));
- }
-
--sub lr_mean
-+sub mean($)
- {
-- &tagify($_[$[]) if defined($_[$[]);
-+ my $self = shift;
-
-- return 0 if $lr_n <= 0;
-- return $lr_sy / $lr_n;
-+ return 0 if $self->{n} <= 0;
-+ return $self->{sy} / $self->{n};
- }
-
--&lr_init();
-+sub new
-+{
-+ my $class = shift;
-+ my $self = {
-+ (n => undef,
-+ sx => undef,
-+ sx2 => undef,
-+ sxy => undef,
-+ sy => undef,
-+ sy2 => undef)
-+ };
-+ bless $self, $class;
-+ init($self);
-+ return $self;
-+}
-
- 1;
-Index: ntp.pl
-===================================================================
-RCS file: /home/windl/NTP/mon-REP/monitoring/ntp.pl,v
-retrieving revision 1.1.1.1
-retrieving revision 1.3
-diff -u -r1.1.1.1 -r1.3
---- ntp.pl 1993/08/24 19:29:34 1.1.1.1
-+++ ntp.pl 1997/10/23 18:19:41 1.3
-@@ -1,4 +1,4 @@
--#!/local/bin/perl
-+#!/usr/bin/perl -w
- ;#
- ;# ntp.pl,v 3.1 1993/07/06 01:09:09 jbj Exp
- ;#
-@@ -43,7 +43,7 @@
- ;# N key
- ;# N2 checksum
-
--;# first bye of packet
-+;# first byte of packet
- sub pkt_LI { return ($_[$[] >> 6) & 0x3; }
- sub pkt_VN { return ($_[$[] >> 3) & 0x7; }
- sub pkt_MODE { return ($_[$[] ) & 0x7; }
-@@ -223,6 +223,7 @@
- {
- &getval(&psw_PSel($_[$[]),*PeerSelection);
- }
-+
- sub PeerEvent
- {
- &getval(&psw_PCode($_[$[]),*PeerEvent);
-@@ -394,14 +395,14 @@
- $lastseen = 1 if !&pkt_M($r_e_m_op);
- if (!defined(%FRAGS))
- {
-- (&pkt_M($r_e_m_op) ? " more" : "")."\n";
-+ print((&pkt_M($r_e_m_op) ? " more" : "")."\n");
- $FRAGS{$offset} = $data;
- ;# save other info
- @FRAGS = ($status,$associd,&pkt_OP($r_e_m_op),$seq,$auth_keyid,$r_e_m_op);
- }
- else
- {
-- (&pkt_M($r_e_m_op) ? " more" : "")."\n";
-+ print((&pkt_M($r_e_m_op) ? " more" : "")."\n");
- ;# add frag to previous - combine on the fly
- if (defined($FRAGS{$offset}))
- {
-Index: ntploopstat
-===================================================================
-RCS file: /home/windl/NTP/mon-REP/monitoring/ntploopstat,v
-retrieving revision 1.1.1.1
-retrieving revision 1.3
-diff -u -r1.1.1.1 -r1.3
---- ntploopstat 1993/08/24 19:29:32 1.1.1.1
-+++ ntploopstat 1997/11/23 19:07:12 1.3
-@@ -1,4 +1,5 @@
--#!/local/bin/perl -w--*-perl-*-
-+#!/usr/bin/perl -w
-+# --*-perl-*-
- ;#
- ;# ntploopstat,v 3.1 1993/07/06 01:09:11 jbj Exp
- ;#
-@@ -22,7 +23,7 @@
- ;# (Should have implemented &gettimeofday()..)
- ;#
-
--$0 =~ s!^.*/([^/]+)$!\1!; # beautify script name
-+$0 =~ s!^.*/([^/]+)$!$1!; # beautify script name
-
- $ntpserver = 'localhost'; # default host to poll
- $delay = 60; # default sampling rate
-Index: ntploopwatch
-===================================================================
-RCS file: /home/windl/NTP/mon-REP/monitoring/ntploopwatch,v
-retrieving revision 1.1.1.1
-retrieving revision 1.14
-diff -u -r1.1.1.1 -r1.14
---- ntploopwatch 1993/10/22 14:28:18 1.1.1.1
-+++ ntploopwatch 1997/12/07 17:06:36 1.14
-@@ -1,4 +1,5 @@
--#!/local/bin/perl -w--*-perl-*-
-+#!/usr/bin/perl -w
-+#--*-perl-*-
- ;#
- ;# ntploopwatch,v 3.1 1993/07/06 01:09:13 jbj Exp
- ;#
-@@ -9,12 +10,17 @@
- ;# Copyright (c) 1992
- ;# Rainer Pruy Friedrich-Alexander Universitaet Erlangen-Nuernberg
- ;#
-+;# Copyright (c) 1997
-+;# Ulrich Windl <Ulrich.Windl@rz.uni-regensburg.de>
-+;# (Corrections for Perl5 and other fixes)
- ;#
- ;#############################################################
--$0 =~ s!^.*/([^/]+)$!\1!;
-+$0 =~ s!^.*/([^/]+)$!$1!;
- $F = ' ' x length($0);
- $|=1;
-
-+use 5.004; # require 5.004
-+
- $ENV{'SHELL'} = '/bin/sh'; # use bourne shell
-
- undef($config);
-@@ -23,17 +29,17 @@
- undef($samples);
- undef($StartTime);
- undef($EndTime);
--($a,$b) if 0; # keep -w happy
-+
- $usage = <<"E-O-P";
- usage:
-- to watch statistics permanently:
-+ to watch statistics periodically:
- $0 [-v[<level>]] [-c <config-file>] [-d <working-dir>]
- $F [-h <hostname>]
-
- to get a single print out specify also
-- $F -P[<printer>] [-s<samples>]
-- $F [-S <start-time>] [-E <end-time>]
-- $F [-Y <MaxOffs>] [-y <MinOffs>]
-+ $F -P[[<term_type:>]<printer>]
-+ $F [-s<samples>] [-S <start-time>] [-E <end-time>]
-+ $F [-Y <MaxOffs>] [-y <MinOffs>]
-
- If You like long option names, You can use:
- -help
-@@ -41,21 +47,28 @@
- -d +directory
- -h +host
- -v +verbose[=<level>]
-- -P +printer[=<printer>]
-+ -P +printer[=[<term_type>:]<printer>[:<print_cmd>]]
- -s +samples[=<samples>]
- -S +starttime
- -E +endtime
- -Y +maxy
- -y +miny
-
-+If <printer> is prefixed with a <term_type> and a colon, the <term_type>
-+given is used as terminal fpr gnuplot.
- If <printer> contains a '/' (slash character) output is directed to
- a file of this name instead of delivered to a printer.
-+If suffix :<print_cmd> is given, the suffix is used as the print command,
-+and <printer> is ignored. If blanks are needed inside <term_type> or
-+<print_cmd>, just use underscores instead.
- E-O-P
-
- ;# add directory to look for lr.pl and timelocal.pl (in front of current list)
- unshift(@INC,"/src/NTP/v3/xntp/monitoring");
-
- require "lr.pl"; # linear regresion routines
-+my $lr_offs = new lr;
-+my $lr_freq = new lr;
-
- $MJD_1970 = 40587; # from ntp.h (V3)
- $RecordSize = 48; # usually a line fits into 42 bytes
-@@ -171,16 +184,20 @@
-
- ;# configuration file
- $config = "loopwatch.config" unless defined($config);
--($STATHOST = $config) =~ s!.*loopwatch\.config.([^/\.]*)$!\1!
-+($STATHOST = $config) =~ s!.*loopwatch\.config.([^/\.]+)$!$1!
- unless defined($STATHOST);
--($STATTAG = $STATHOST) =~ s/^([^\.\*\s]+)\..*$/\1/;
-+if ($STATHOST eq $config) {
-+ require "hostname.pl";
-+ $STATHOST = hostname();
-+}
-+($STATTAG = $STATHOST) =~ s/^([^\.\*\s]+)\..*$/$1/;
-
- $srcprefix =~ s/\$STATHOST/$STATHOST/g;
-
- ;# plot command
--@plotcmd=("gnuplot",
-- '-title', "Ntp loop filter statistics $STATHOST",
-- '-name', "NtpLoopWatch_$STATTAG");
-+@plotcmd=("gnuplot");
-+push(@plotcmd, '-title', "NTP loop filter statistics for $STATHOST",
-+ '-name', "NtpLoopWatch_$STATTAG") unless $PrintIt;
- $tmpfile = "/tmp/ntpstat.$$";
-
- ;# other variables
-@@ -211,9 +228,8 @@
- $?>>8,$? & 0xff)) if $?;
- exit(1) if $? && defined($Plotpid) && $pid == $Plotpid;
- }
--&sigchld if 0;
--$SIG{'CHLD'} = "sigchld";
--$SIG{'CLD'} = "sigchld";
-+$SIG{'CHLD'} = \&sigchld;
-+$SIG{'CLD'} = \&sigchld;
-
- sub abort
- {
-@@ -221,8 +237,7 @@
- defined($Plotpid) && kill('TERM',$Plotpid);
- die("$0: received signal SIG$_[$[] - exiting\n");
- }
--&abort if 0; # make -w happy - &abort IS used
--$SIG{'INT'} = $SIG{'HUP'} = $SIG{'QUIT'} = $SIG{'TERM'} = $SIG{'PIPE'} = "abort";
-+$SIG{'INT'} = $SIG{'HUP'} = $SIG{'QUIT'} = $SIG{'TERM'} = $SIG{'PIPE'} = \&abort;
-
- ;#
- sub abs
-@@ -248,7 +263,7 @@
- open(STDOUT,">&STDERR") ||
- die("$0: failed to redirect STDOUT of plot command: $!\n");
-
-- print STDOUT "plot command running as $$\n";
-+ print STDOUT "plot command has PID $$\n";
-
- exec @plotcmd;
- die("$0: failed to exec (@plotcmd): $!\n");
-@@ -275,128 +290,83 @@
- s/^([^\#]*[^\#\s]?)\s*\#.*$//;
- next if /^\s*$/;
-
-- s/^\s*([^=\s]*)\s*=\s*(.*\S)\s*$/\1=\2/;
-+ s/^\s*([^=\s]*)\s*=\s*(.*\S)\s*$/$1=$2/;
-
-- ($c,$v) = split(/=/,$_,2);
-+ ($c,$v) = ($1, $2);
- print "processing \"$c=$v\"\n" if $verbose > 3;
-- ($c eq "delay") && ($delay = $v,1) && next;
-- ($c eq 'samples') && (!defined($PrintIt) || !defined($samples)) &&
-- ($samples = $v,1) && next;
-- ($c eq 'srcprefix') && (($srcprefix=$v)=~s/\$STATHOST/$STATHOST/g,1)
-- && next;
-- ($c eq 'showoffs') &&
-- ($showoffs = ($v eq 'yes' || $v eq 'y' || $v != 0),1) && next;
-- ($c eq 'showfreq') &&
-- ($showfreq = ($v eq 'yes' || $v eq 'y' || $v != 0),1) && next;
-- ($c eq 'showcmpl') &&
-- ($showcmpl = ($v eq 'yes' || $v eq 'y' || $v != 0),1) && next;
-- ($c eq 'showoreg') &&
-- ($showoreg = ($v eq 'yes' || $v eq 'y' || $v != 0),1) && next;
-- ($c eq 'showfreg') &&
-- ($showfreg = ($v eq 'yes' || $v eq 'y' || $v != 0),1) && next;
--
-- ($c eq 'exit') && (unlink($tmpfile),die("$0: exit by config request\n"));
--
-- ($c eq 'freqbase' ||
-- $c eq 'cmplscale') &&
-- do {
-- if (! defined($v) || $v eq "" || $v eq 'dynamic')
-- {
-- eval "undef(\$$c);";
-- }
-- else
-- {
-- eval "\$$c = \$v;";
-- }
-- next;
-- };
-- ($c eq 'timebase') &&
-- do {
-- if (! defined($v) || $v eq "" || $v eq "dynamic")
-- {
-- undef($timebase);
-- }
-- else
-- {
-- $timebase=&date_time_spec2seconds($v);
-- }
-- };
-- ($c eq 'EndTime') &&
-- do {
-- next if defined($EndTime) && defined($PrintIt);
-- if (! defined($v) || $v eq "" || $v eq "none")
-- {
-- undef($EndTime);
-- }
-- else
-- {
-- $EndTime=&date_time_spec2seconds($v);
-- }
-- };
-- ($c eq 'StartTime') &&
-- do {
-- next if defined($StartTime) && defined($PrintIt);
-- if (! defined($v) || $v eq "" || $v eq "none")
-- {
-- undef($StartTime);
-- }
-- else
-- {
-- $StartTime=&date_time_spec2seconds($v);
-- }
-- };
--
-- ($c eq 'MaxY') &&
-- do {
-- next if defined($MaxY) && defined($PrintIt);
-- if (! defined($v) || $v eq "" || $v eq "none")
-- {
-- undef($MaxY);
-- }
-- else
-- {
-- $MaxY=$v;
-- }
-- };
--
-- ($c eq 'MinY') &&
-- do {
-- next if defined($MinY) && defined($PrintIt);
-- if (! defined($v) || $v eq "" || $v eq "none")
-- {
-- undef($MinY);
-- }
-- else
-- {
-- $MinY=$v;
-- }
-- };
--
-- ($c eq 'deltaT') &&
-- do {
-- if (!defined($v) || $v eq "")
-- {
-- undef($deltaT);
-- }
-- else
-- {
-- $deltaT = $v;
-- }
-- next;
-- };
-- ($c eq 'verbose') && ! defined($PrintIt) &&
-- do {
-- if (!defined($v) || $v == 0)
-- {
-- $verbose = 0;
-- }
-- else
-- {
-- $verbose = $v;
-- }
-- next;
-- };
-- ;# otherwise: silently ignore unrecognized config line
-+ if ($c eq "delay") {
-+ $delay = $v;
-+ } elsif ($c eq 'samples') {
-+ $samples = $v if (!defined($PrintIt) || !defined($samples));
-+ } elsif ($c eq 'srcprefix') {
-+ ($srcprefix = $v) =~ s/\$STATHOST/$STATHOST/g;
-+ } elsif ($c eq 'showoffs') {
-+ $showoffs = ($v =~ /^yes$|^y$|^1$/);
-+ } elsif ($c eq 'showfreq') {
-+ $showfreq = ($v =~ /^yes$|^y$|^1$/);
-+ } elsif ($c eq 'showcmpl') {
-+ $showcmpl = ($v =~ /^yes$|^y$|^1$/);
-+ } elsif ($c eq 'showoreg') {
-+ $showoreg = ($v =~ /^yes$|^y$|^1$/);
-+ } elsif ($c eq 'showfreg') {
-+ $showfreg = ($v =~ /^yes$|^y$|^1$/);
-+ } elsif ($c eq 'exit') {
-+ unlink($tmpfile); die("$0: exit by config request\n");
-+ } elsif ($c eq 'freqbase' || $c eq 'cmplscale') {
-+ if (! defined($v) || $v eq "" || $v eq 'dynamic') {
-+ eval "undef(\$$c);";
-+ } else {
-+ eval "\$$c = \$v;";
-+ }
-+ } elsif ($c eq 'timebase') {
-+ if (! defined($v) || $v eq "" || $v eq "dynamic") {
-+ undef($timebase);
-+ } else {
-+ $timebase=&date_time_spec2seconds($v);
-+ }
-+ } elsif ($c eq 'EndTime') {
-+ next if defined($EndTime) && defined($PrintIt);
-+ if (! defined($v) || $v eq "" || $v eq "none") {
-+ undef($EndTime);
-+ } else {
-+ $EndTime=&date_time_spec2seconds($v);
-+ }
-+ } elsif ($c eq 'StartTime') {
-+ next if defined($StartTime) && defined($PrintIt);
-+ if (! defined($v) || $v eq "" || $v eq "none") {
-+ undef($StartTime);
-+ } else {
-+ $StartTime=&date_time_spec2seconds($v);
-+ }
-+ } elsif ($c eq 'MaxY') {
-+ next if defined($MaxY) && defined($PrintIt);
-+ if (! defined($v) || $v eq "" || $v eq "none") {
-+ undef($MaxY);
-+ } else {
-+ $MaxY=$v;
-+ }
-+ } elsif ($c eq 'MinY') {
-+ next if defined($MinY) && defined($PrintIt);
-+ if (! defined($v) || $v eq "" || $v eq "none") {
-+ undef($MinY);
-+ } else {
-+ $MinY=$v;
-+ }
-+ } elsif ($c eq 'deltaT') {
-+ if (!defined($v) || $v eq "") {
-+ undef($deltaT);
-+ } else {
-+ $deltaT = $v;
-+ }
-+ } elsif ($c eq 'verbose' && ! defined($PrintIt)) {
-+ if (!defined($v) || $v == 0) {
-+ $verbose = 0;
-+ } else {
-+ $verbose = $v;
-+ }
-+ } else {
-+ ;# otherwise: silently ignore unrecognized config line
-+ }
- }
- close(CF);
- ;# set show defaults when nothing selected
-@@ -413,16 +383,16 @@
- print " showcmpl\t= $showcmpl\n";
- print " showoreg\t= $showoreg\n";
- print " showfreg\t= $showfreg\n";
-- printf " timebase\t= %s",defined($timebase)?&ctime($timebase):"dynamic\n";
-- printf " freqbase\t= %s\n",defined($freqbase) ?"$freqbase":"dynamic";
-- printf " cmplscale\t= %s\n",defined($cmplscale)?"$cmplscale":"dynamic";
-- printf " StartTime\t= %s",defined($StartTime)?&ctime($StartTime):"none\n";
-- printf " EndTime\t= %s", defined($EndTime) ? &ctime($EndTime):"none\n";
-- printf " MaxY\t= %s",defined($MaxY)? $MaxY :"none\n";
-- printf " MinY\t= %s",defined($MinY)? $MinY :"none\n";
-+ printf " timebase\t= %s", defined($timebase) ? &ctime($timebase) : "dynamic\n";
-+ printf " freqbase\t= %s\n", defined($freqbase) ? "$freqbase" : "dynamic";
-+ printf " cmplscale\t= %s\n", defined($cmplscale) ? "$cmplscale" : "dynamic";
-+ printf " StartTime\t= %s", defined($StartTime) ? &ctime($StartTime) : "none\n";
-+ printf " EndTime\t= %s", defined($EndTime) ? &ctime($EndTime):"none\n";
-+ printf " MaxY\t= %s", defined($MaxY) ? $MaxY : "none\n";
-+ printf " MinY\t= %s", defined($MinY) ? $MinY : "none\n";
- print " verbose\t= $verbose\n";
- }
--print "configuration file read\n" if $verbose > 2;
-+ print "configuration file read\n" if $verbose > 2;
- }
-
- sub make_doplot
-@@ -443,10 +413,9 @@
- ;# number of integral seconds to get at least 12 tic marks on x axis
- $t = int(($maxtime - $mintime) / 12 + 0.5);
- $t = 1 unless $t; # prevent $t to be zero
-- foreach $i (30,
-- 60,5*60,15*60,30*60,
-- 60*60,2*60*60,6*60*60,12*60*60,
-- 24*60*60,48*60*60)
-+ foreach $i (30, 60,
-+ 5*60, 10*60, 15*60, 30*60, 60*60,
-+ 2*60*60, 6*60*60, 12*60*60, 24*60*60, 48*60*60)
- {
- last if $t < $i;
- $t = $t - ($t % $i);
-@@ -458,31 +427,30 @@
- $i <= $maxtime + $t;
- $i += $t, $c=",")
- {
-+ my ($sec, $min, $hour, $mday, $mon, $year, $wday) = localtime($i);
-+
- $s .= $c;
- ((int($i / $t) % 2) &&
- ($s .= sprintf("'' %lf",($i - $LastTimeBase)/3600))) ||
- (($t <= 60) &&
- ($s .= sprintf("'%d:%02d:%02d' %lf",
-- (localtime($i))[$[+2,$[+1,$[+0],
-- ($i - $LastTimeBase)/3600)))
-+ $hour, $min, $sec, ($i - $LastTimeBase) / 3600)))
- || (($t <= 2*60*60) &&
- ($s .= sprintf("'%d:%02d' %lf",
-- (localtime($i))[$[+2,$[+1],
-- ($i - $LastTimeBase)/3600)))
-+ $hour, $min, ($i - $LastTimeBase) / 3600)))
- || (($t <= 12*60*60) &&
- ($s .= sprintf("'%s %d:00' %lf",
-- $Day[(localtime($i))[$[+6]],
-- (localtime($i))[$[+2],
-- ($i - $LastTimeBase)/3600)))
-+ $Day[$wday], $hour,
-+ ($i - $LastTimeBase) / 3600)))
- || ($s .= sprintf("'%d.%d-%d:00' %lf",
-- (localtime($i))[$[+3,$[+4,$[+2],
-- ($i - $LastTimeBase)/3600));
-+ $mday, $mon + 1, $hour,
-+ ($i - $LastTimeBase) / 3600));
- }
- $doplot .= "set xtics ($s)\n";
-
- chop($xts = &ctime($mintime));
- chop($xte = &ctime($maxtime));
-- $doplot .= "set xlabel 'Start: $xts -- Time Scale -- End: $xte'\n";
-+ $doplot .= "set xlabel 'Start: $xts -- Time Scale -- End: $xte'\n";
- $doplot .= "set yrange [" ;
- $doplot .= defined($MinY) ? sprintf("%lf", $MinY) : $miny;
- $doplot .= ':';
-@@ -518,22 +486,22 @@
- $c = ",");
- $showoreg && $showoffs &&
- ($doplot .= sprintf($regfmt, $c,
-- &lr_B('offs'),&lr_A('offs'),
-- "offset ",
-- &lr_B('offs'),
-- ((&lr_A('offs')) < 0 ? '-' : '+'),
-- &abs(&lr_A('offs')), &lr_r('offs'),
-+ $lr_offs->B(),$lr_offs->A(),
-+ "offset",
-+ $lr_offs->B(),
-+ (($lr_offs->A()) < 0 ? '-' : '+'),
-+ &abs($lr_offs->A()), $lr_offs->r(),
- "[ms]"),
- $c = ",");
- $showfreg && $showfreq &&
- ($doplot .= sprintf($regfmt, $c,
-- &lr_B('freq') * $FreqScale,
-- (&lr_A('freq') + $minfreq) * $FreqScale - $LastFreqBase,
-+ $lr_freq->B() * $FreqScale,
-+ ($lr_freq->A() + $minfreq) * $FreqScale - $LastFreqBase,
- "frequency",
-- &lr_B('freq') * $FreqScale,
-- ((&lr_A('freq') + $minfreq) * $FreqScale - $LastFreqBase) < 0 ? '-' : '+',
-- &abs((&lr_A('freq') + $minfreq) * $FreqScale - $LastFreqBase),
-- &lr_r('freq'),
-+ $lr_freq->B() * $FreqScale,
-+ (($lr_freq->A() + $minfreq) * $FreqScale - $LastFreqBase) < 0 ? '-' : '+',
-+ &abs(($lr_freq->A() + $minfreq) * $FreqScale - $LastFreqBase),
-+ $lr_freq->r(),
- "[${FreqScaleInv}ppm]"),
- $c = ",");
- $doplot .= "\n";
-@@ -583,7 +551,7 @@
- $#loffset = $[ - 1;
- $#filekey = $[ - 1;
- print "memory allocation ready\n" if $verbose > 2;
-- sleep(3) if $verbose > 1;
-+ sleep(3) if $verbose > 2;
-
- if (index($in,"/") < $[)
- {
-@@ -606,7 +574,6 @@
- ;# rescan directory on changes
- $Lsdir = $sdir;
- $Ltime = (stat($sdir))[$[+9];
-- </X{> if 0; # dummy line - calm down my formatter
- local(@newfiles) = < ${in}*[0-9] >;
- local($st_dev,$st_ino,$st_mtime,$st_size,$name,$key,$modified);
-
-@@ -626,7 +593,7 @@
- $F_key{$name} = $key;
- $modified++;
- }
-- if (!defined($F_name{$key}) || $F_name{$key} != $name)
-+ if (!defined($F_name{$key}) || $F_name{$key} ne $name)
- {
- $F_name{$key} = $name;
- $modified++;
-@@ -643,9 +610,9 @@
- }
- if ($modified)
- {
-- print "new data \"$name\" key: $key;\n" if $verbose > 1;
-+ print "new data \"$name\" key: $key;\n" if $verbose > 2;
- print " size: $st_size; mtime: $st_mtime;\n"
-- if $verbose > 1;
-+ if $verbose > 2;
- $F_last{$key} = $F_first{$key} = $st_mtime;
- $F_first{$key}--; # prevent zero divide later on
- ;# now compute derivated attributes
-@@ -692,7 +659,7 @@
- }
- close(IN);
- print(" first: ",$F_first{$key},
-- " last: ",$F_last{$key},"\n") if $verbose > 1;
-+ " last: ",$F_last{$key},"\n") if $verbose > 2;
- }
- }
- ;# now reclaim memory used for files no longer referenced ...
-@@ -739,7 +706,7 @@
- }
- ;# create list sorted by time
- @F_files = sort {$F_first{$a} <=> $F_first{$b}; } keys(%F_name);
-- if ($verbose > 1)
-+ if ($verbose > 2)
- {
- print "Resulting file list:\n";
- foreach (@F_files)
-@@ -797,7 +764,7 @@
- print "guess start according to StartTime ($StartTime)\n"
- if $verbose > 3;
-
-- if ($fpos[$[] eq 'start')
-+ if (defined $fpos[$[] && $fpos[$[] eq 'start')
- {
- if (grep($_ eq $fpos[$[+1],@f))
- {
-@@ -1001,9 +968,9 @@
- $t += $F[$[+1]; # add seconds + fraction
-
- ;# multiply offset by 1000 to get ms - try to avoid float op
-- (($F[$[+2] =~ s/(\d*)\.(\d{3})(\d*)/\1\2.\3/) &&
-+ (($F[$[+2] =~ s/(\d*)\.(\d{3})(\d*)/$1$2.$3/) &&
- $F[$[+2] =~ s/0+([\d\.])/($1 eq '.') ? '0.' : $1/e) # strip leading zeros
-- || $F[$[+2] *= 1000;
-+ || ($F[$[+2] *= 1000);
-
-
- ;# skip samples out of specified time range
-@@ -1036,8 +1003,8 @@
- print "input scanned ($l lines/",scalar(@time)," samples)\n"
- if $verbose > 1;
-
-- &lr_init('offs');
-- &lr_init('freq');
-+ $lr_offs->init();
-+ $lr_freq->init();
-
- if (@time)
- {
-@@ -1047,17 +1014,17 @@
- local($freqbase) unless defined($freqbase);
- local($cmplscale) unless defined($cmplscale);
-
-- undef($mintime,$maxtime,$minoffs,$maxoffs,
-- $minfreq,$maxfreq,$mincmpl,$maxcmpl,
-- $miny,$maxy);
-+ undef $mintime; undef $maxtime; undef $minoffs; undef $maxoffs;
-+ undef $minfreq; undef $maxfreq; undef $mincmpl; undef $maxcmpl;
-+ undef $miny; undef $maxy;
-
- print "computing ranges\n" if $verbose > 2;
-
- $LastCnt = @time;
-
- ;# @time is in ascending order (;-)
-- $mintime = @time[$[];
-- $maxtime = @time[$#time];
-+ $mintime = $time[$[];
-+ $maxtime = $time[$#time];
- unless (defined($timebase))
- {
- local($time,@X) = (time);
-@@ -1081,24 +1048,24 @@
- ;# (otherwise a (shift(@a1),shift(a2)) would do),
- ;# I dont like to make copies of these arrays as they may be huge
- $i = $[;
-- &lr_sample(($time[$i]-$timebase)/3600,$offs[$
-
diff --git a/contrib/ntp/scripts/summary.pl b/contrib/ntp/scripts/summary.pl
deleted file mode 100644
index 7145579..0000000
--- a/contrib/ntp/scripts/summary.pl
+++ /dev/null
@@ -1,373 +0,0 @@
-#!/usr/bin/perl -w
-# $Id: summary.pl,v 1.2 1999/12/02 01:59:07 stenn Exp $
-# Perl version of (summary.sh, loop.awk, peer.awk):
-# Create summaries from xntpd's loop and peer statistics.
-#
-# Copyright (c) 1997, 1999 by Ulrich Windl <Ulrich.Windl@rz.uni-regensburg.de>
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-require 5.003; # "never tested with any other version of Perl"
-use strict;
-
-use Getopt::Long;
-
-my $log_date_pattern = '[12]\d{3}[01]\d[0-3]\d';
-my $statsdir = "/var/log/ntp"; # directory with input files
-my $outputdir = "/tmp"; # directory for output files
-my $skip_time_steps = 3600.0; # ignore time offsets larger that this
-my $startdate = "19700101"; # first data file to use (YYYYMMDD)
-my $enddate=`date -u +%Y%m%d`; chomp $enddate; --$enddate;
-my $peer_dist_limit = 400.0;
-
-my %options = ("directory|input-directory=s" => \$statsdir,
- "output-directory=s" => \$outputdir,
- "skip-time-steps:f" => \$skip_time_steps,
- "start-date=s" => \$startdate,
- "end-date=s" => \$enddate,
- "peer-dist-limit=f" => \$peer_dist_limit);
-
-if ( !GetOptions(%options) )
-{
- print STDERR "valid options for $0 are:\n";
- my $opt;
- foreach $opt (sort(keys %options)) {
- print STDERR "\t--$opt\t(default is ";
- if ( ref($options{$opt}) eq "ARRAY" ) {
- print STDERR join(", ", map { "'$_'" } @{$options{$opt}});
- } else {
- print STDERR "'${$options{$opt}}'";
- }
- print STDERR ")\n";
- }
- print STDERR "\n";
- die;
-}
-
-# check possibly current values of options
-die "$statsdir: no such directory" unless (-d $statsdir);
-die "$outputdir: no such directory" unless (-d $outputdir);
-die "$skip_time_steps: skip-time-steps must be positive"
- unless ($skip_time_steps >= 0.0);
-die "$startdate: invalid start date|$`|$&|$'"
- unless ($startdate =~ m/.*$log_date_pattern$/);
-die "$enddate: invalid end date"
- unless ($enddate =~ m/.*$log_date_pattern$/);
-
-$skip_time_steps = 0.128 if ($skip_time_steps == 0);
-
-sub min
-{
- my ($result, @rest) = @_;
- map { $result = $_ if ($_ < $result) } @rest;
- return($result);
-}
-
-sub max
-{
- my ($result, @rest) = @_;
- map { $result = $_ if ($_ > $result) } @rest;
- return($result);
-}
-
-# calculate mean, range, and standard deviation for offset and frequency
-sub do_loop
-{
- my ($directory, $fname, $out_file) = @_;
- print "$directory/$fname\n";
- open INPUT, "$directory/$fname" or warn "can't open $directory/$fname: $!";
- open OUTPUT, ">>$out_file" or die "can't open $out_file: $!";
- print OUTPUT "$fname\n";
- my ($loop_tmax, $loop_fmax) = (-1e9, -1e9);
- my ($loop_tmin, $loop_fmin) = (1e9, 1e9);
- my ($loop_time_rms, $loop_freq_rms) = (0, 0);
- my $loop_count = 0;
- my $loop_time = 0;
- my $loop_freq = 0;
- my ($freq, $offs);
- my @Fld;
- while (<INPUT>) {
- chop; # strip record separator
- @Fld = split;
- next if ($#Fld < 4);
-#NTPv3: 50529 74356.259 -0.000112 16.1230 8
-#NTPv3: day, sec.msec, offset, drift_comp, sys_poll
-#NTPv4: 51333 54734.582 0.000001648 16.981964 0.000001094 0.020938 6
-#NTPv4: day, sec.msec, offset, drift_comp, sys_error, clock_stabil, sys_poll
- if ($Fld[2] > $skip_time_steps || $Fld[2] < -$skip_time_steps) {
- warn "ignoring loop offset $Fld[2] (file $fname, line $.)\n";
- next
- }
- $loop_count++;
- ($offs, $freq) = ($Fld[2], $Fld[3]);
- $loop_tmax = max($loop_tmax, $offs);
- $loop_tmin = min($loop_tmin, $offs);
- $loop_fmax = max($loop_fmax, $freq);
- $loop_fmin = min($loop_fmin, $freq);
- $loop_time += $offs;
- $loop_time_rms += $offs * $offs;
- $loop_freq += $freq;
- $loop_freq_rms += $freq * $freq;
- }
- close INPUT;
- if ($loop_count > 1) {
- $loop_time /= $loop_count;
- $loop_time_rms = $loop_time_rms / $loop_count - $loop_time * $loop_time;
- if ($loop_time_rms < 0) {
- warn "loop_time_rms: $loop_time_rms < 0";
- $loop_time_rms = 0;
- }
- $loop_time_rms = sqrt($loop_time_rms);
- $loop_freq /= $loop_count;
- $loop_freq_rms = $loop_freq_rms / $loop_count - $loop_freq * $loop_freq;
- if ($loop_freq_rms < 0) {
- warn "loop_freq_rms: $loop_freq_rms < 0";
- $loop_freq_rms = 0;
- }
- $loop_freq_rms = sqrt($loop_freq_rms);
- printf OUTPUT
- ("loop %d, %.0f+/-%.1f, rms %.1f, freq %.2f+/-%0.3f, var %.3f\n",
- $loop_count, ($loop_tmax + $loop_tmin) / 2 * 1e6,
- ($loop_tmax - $loop_tmin) / 2 * 1e6, $loop_time_rms * 1e6,
- ($loop_fmax + $loop_fmin) / 2, ($loop_fmax - $loop_fmin) / 2,
- $loop_freq_rms);
- }
- else {
- warn "no valid lines in $directory/$fname";
- }
- close OUTPUT
-}
-
-# calculate mean, standard deviation, maximum offset, mean dispersion,
-# and maximum distance for each peer
-sub do_peer
-{
- my ($directory, $fname, $out_file) = @_;
- print "$directory/$fname\n";
- open INPUT, "$directory/$fname" or warn "can't open $directory/$fname: $!";
- open OUTPUT, ">>$out_file" or die "can't open $out_file: $!";
- print OUTPUT "$fname\n";
-# we toss out all distances greater than one second on the assumption the
-# peer is in initial acquisition
- my ($n, $MAXDISTANCE) = (0, 1.0);
- my %peer_time;
- my %peer_time_rms;
- my %peer_count;
- my %peer_delay;
- my %peer_disp;
- my %peer_dist;
- my %peer_ident;
- my %peer_tmin;
- my %peer_tmax;
- my @Fld;
- my ($i, $j);
- my ($dist, $offs);
- while (<INPUT>) {
- chop; # strip record separator
- @Fld = split;
- next if ($#Fld < 6);
-#NTPv3: 50529 83316.249 127.127.8.1 9674 0.008628 0.00000 0.00700
-#NTPv3: day, sec.msec, addr, status, offset, delay, dispersion
-#NTPv4: 51333 56042.037 127.127.8.1 94f5 -0.000014657 0.000000000 0.000000000 0.000013214
-#NTPv4: day, sec.msec, addr, status, offset, delay, dispersion, skew
-
- $dist = $Fld[6] + $Fld[5] / 2;
- next if ($dist > $MAXDISTANCE);
- $offs = $Fld[4];
- if ($offs > $skip_time_steps || $offs < -$skip_time_steps) {
- warn "ignoring peer offset $offs (file $fname, line $.)\n";
- next
- }
- $i = $n;
- for ($j = 0; $j < $n; $j++) {
- if ($Fld[2] eq $peer_ident{$j}) {
- $i = $j; # peer found
- last;
- }
- }
- if ($i == $n) { # add new peer
- $peer_ident{$i} = $Fld[2];
- $peer_tmax{$i} = $peer_dist{$i} = -1e9;
- $peer_tmin{$i} = 1e9;
- $peer_time{$i} = $peer_time_rms{$i} = 0;
- $peer_delay{$i} = $peer_disp{$i} = 0;
- $peer_count{$i} = 0;
- $n++;
- }
- $peer_count{$i}++;
- $peer_tmax{$i} = max($peer_tmax{$i}, $offs);
- $peer_tmin{$i} = min($peer_tmin{$i}, $offs);
- $peer_dist{$i} = max($peer_dist{$i}, $dist);
- $peer_time{$i} += $offs;
- $peer_time_rms{$i} += $offs * $offs;
- $peer_delay{$i} += $Fld[5];
- $peer_disp{$i} += $Fld[6];
- }
- close INPUT;
- print OUTPUT
-" ident cnt mean rms max delay dist disp\n";
- print OUTPUT
-"==========================================================================\n";
- my @lines = ();
- for ($i = 0; $i < $n; $i++) {
- next if $peer_count{$i} < 2;
- $peer_time{$i} /= $peer_count{$i};
- eval { $peer_time_rms{$i} = sqrt($peer_time_rms{$i} / $peer_count{$i} -
- $peer_time{$i} * $peer_time{$i}); };
- $peer_time_rms{$i} = 0, warn $@ if $@;
- $peer_delay{$i} /= $peer_count{$i};
- $peer_disp{$i} /= $peer_count{$i};
- $peer_tmax{$i} = $peer_tmax{$i} - $peer_time{$i};
- $peer_tmin{$i} = $peer_time{$i} - $peer_tmin{$i};
- if ($peer_tmin{$i} > $peer_tmax{$i}) { # can this happen at all?
- $peer_tmax{$i} = $peer_tmin{$i};
- }
- push @lines, sprintf
- "%-15s %4d %8.3f %8.3f %8.3f %8.3f %8.3f %8.3f\n",
- $peer_ident{$i}, $peer_count{$i}, $peer_time{$i} * 1e3,
- $peer_time_rms{$i} * 1e3, $peer_tmax{$i} * 1e3,
- $peer_delay{$i} * 1e3, $peer_dist{$i} * 1e3, $peer_disp{$i} * 1e3;
- }
- print OUTPUT sort @lines;
- close OUTPUT;
-}
-
-sub do_clock
-{
- my ($directory, $fname, $out_file) = @_;
- print "$directory/$fname\n";
- open INPUT, "$directory/$fname";
- open OUTPUT, ">>$out_file" or die "can't open $out_file: $!";
- print OUTPUT "$fname\n";
- close INPUT;
- close OUTPUT;
-}
-
-sub peer_summary
-{
- my $in_file = shift;
- my ($i, $j, $n);
- my (%peer_ident, %peer_count, %peer_mean, %peer_var, %peer_max);
- my (%peer_1, %peer_2, %peer_3, %peer_4);
- my $dist;
- my $max;
- open INPUT, "<$in_file" or die "can't open $in_file: $!";
- my @Fld;
- $n = 0;
- while (<INPUT>) {
- chop; # strip record separator
- @Fld = split;
- next if ($#Fld < 7 || $Fld[0] eq 'ident');
- $i = $n;
- for ($j = 0; $j < $n; $j++) {
- if ($Fld[0] eq $peer_ident{$j}) {
- $i = $j;
- last; # peer found
- }
- }
- if ($i == $n) { # add new peer
- $peer_count{$i} = $peer_mean{$i} = $peer_var{$i} = 0;
- $peer_max{$i} = 0;
- $peer_1{$i} = $peer_2{$i} = $peer_3{$i} = $peer_4{$i} = 0;
- $peer_ident{$i} = $Fld[0];
- ++$n;
- }
- $dist = $Fld[6] - $Fld[5] / 2;
- if ($dist < $peer_dist_limit) {
- $peer_count{$i}++;
- $peer_mean{$i} += $Fld[2];
- $peer_var{$i} += $Fld[3] * $Fld[3];
- $max = $Fld[4];
- $peer_max{$i} = max($peer_max{$i}, $max);
- if ($max > 1) {
- $peer_1{$i}++;
- if ($max > 5) {
- $peer_2{$i}++;
- if ($max > 10) {
- $peer_3{$i}++;
- if ($max > 50) {
- $peer_4{$i}++;
- }
- }
- }
- }
- }
- else {
- warn "dist exceeds limit: $dist (file $in_file, line $.)\n";
- }
- }
- close INPUT;
- my @lines = ();
- print
- " host days mean rms max >1 >5 >10 >50\n";
- print
- "==================================================================\n";
- for ($i = 0; $i < $n; $i++) {
- next if ($peer_count{$i} < 2);
- $peer_mean{$i} /= $peer_count{$i};
- eval { $peer_var{$i} = sqrt($peer_var{$i} / $peer_count{$i} -
- $peer_mean{$i} * $peer_mean{$i}); };
- $peer_var{$i} = 0, warn $@ if $@;
- push @lines, sprintf
- "%-15s %3d %9.3f% 9.3f %9.3f %3d %3d %3d %3d\n",
- $peer_ident{$i}, $peer_count{$i}, $peer_mean{$i}, $peer_var{$i},
- $peer_max{$i}, $peer_1{$i}, $peer_2{$i}, $peer_3{$i}, $peer_4{$i};
- }
- print sort @lines;
-}
-
-my $loop_summary="$outputdir/loop_summary";
-my $peer_summary="$outputdir/peer_summary";
-my $clock_summary="$outputdir/clock_summary";
-my (@loopfiles, @peerfiles, @clockfiles);
-
-print STDERR "Creating summaries from $statsdir ($startdate to $enddate)\n";
-
-opendir SDIR, $statsdir or die "directory ${statsdir}: $!";
-rewinddir SDIR;
-@loopfiles=sort grep /loop.*$log_date_pattern/, readdir SDIR;
-rewinddir SDIR;
-@peerfiles=sort grep /peer.*$log_date_pattern/, readdir SDIR;
-rewinddir SDIR;
-@clockfiles=sort grep /clock.*$log_date_pattern/, readdir SDIR;
-closedir SDIR;
-
-# remove old summary files
-map { unlink $_ if -f $_ } ($loop_summary, $peer_summary, $clock_summary);
-
-my $date;
-map {
- $date = $_; $date =~ s/.*($log_date_pattern)$/$1/;
- if ($date ge $startdate && $date le $enddate) {
- do_loop $statsdir, $_, $loop_summary;
- }
-} @loopfiles;
-
-map {
- $date = $_; $date =~ s/.*($log_date_pattern)$/$1/;
- if ($date ge $startdate && $date le $enddate) {
- do_peer $statsdir, $_, $peer_summary;
- }
-} @peerfiles;
-
-map {
- $date = $_; $date =~ s/.*($log_date_pattern)$/$1/;
- if ($date ge $startdate && $date le $enddate) {
- do_clock $statsdir, $_, $clock_summary;
- }
-} @clockfiles;
-
-print STDERR "Creating peer summary with limit $peer_dist_limit\n";
-peer_summary $peer_summary if (-f $peer_summary);
OpenPOWER on IntegriCloud