summaryrefslogtreecommitdiffstats
path: root/contrib/ntp/scripts/monitoring
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/ntp/scripts/monitoring')
-rw-r--r--contrib/ntp/scripts/monitoring/README32
-rw-r--r--contrib/ntp/scripts/monitoring/lr.pl156
-rw-r--r--contrib/ntp/scripts/monitoring/ntp.pl9
-rw-r--r--contrib/ntp/scripts/monitoring/ntploopstat5
4 files changed, 107 insertions, 95 deletions
diff --git a/contrib/ntp/scripts/monitoring/README b/contrib/ntp/scripts/monitoring/README
index fa8ad8b..f8eb0a9 100644
--- a/contrib/ntp/scripts/monitoring/README
+++ b/contrib/ntp/scripts/monitoring/README
@@ -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 @@ ntptrap:
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 @@ ntploopstat:
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 @@ ntploopwatch:
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 @@ lr.pl:
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..
diff --git a/contrib/ntp/scripts/monitoring/lr.pl b/contrib/ntp/scripts/monitoring/lr.pl
index 02c7550..7980d22 100644
--- a/contrib/ntp/scripts/monitoring/lr.pl
+++ b/contrib/ntp/scripts/monitoring/lr.pl
@@ -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
+sub init
{
- 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";
- }
+ my $self = shift;
+
+ $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_init
+sub sample($$$)
{
- &tagify($_[$[]) if defined($_[$[]);
-
- $lr_n = 0;
- $lr_sx = 0.0;
- $lr_sx2 = 0.0;
- $lr_sxy = 0.0;
- $lr_sy = 0.0;
- $lr_sy2 = 0.0;
+ my $self = shift;
+ my($_x, $_y) = @_;
+
+ ++($self->{n});
+ $self->{sx} += $_x;
+ $self->{sy} += $_y;
+ $self->{sxy} += $_x * $_y;
+ $self->{sx2} += $_x**2;
+ $self->{sy2} += $_y**2;
}
-sub lr_sample
+sub B($)
{
- local($_x, $_y) = @_;
-
- &tagify($_[$[+2]) if defined($_[$[+2]);
+ my $self = shift;
- $lr_n++;
- $lr_sx += $_x;
- $lr_sy += $_y;
- $lr_sxy += $_x * $_y;
- $lr_sx2 += $_x**2;
- $lr_sy2 += $_y**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_B
+sub A($)
{
- &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 ($self->{sy} - B($self) * $self->{sx}) / $self->{n};
}
-sub lr_A
+sub Y($$)
{
- &tagify($_[$[]) if defined($_[$[]);
+ my $self = shift;
- return ($lr_sy - &lr_B * $lr_sx) / $lr_n;
+ return A($self) + B($self) * $_[$[];
}
-sub lr_Y
+sub X($$)
{
- &tagify($_[$[]) if defined($_[$[]);
+ my $self = shift;
- return &lr_A + &lr_B * $_[$[];
+ return ($_[$[] - A($self)) / B($self);
}
-sub lr_X
+sub r($)
{
- &tagify($_[$[]) if defined($_[$[]);
+ my $self = shift;
- return ($_[$[] - &lr_A) / &lr_B;
-}
-
-sub lr_r
-{
- &tagify($_[$[]) if defined($_[$[]);
-
- 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;
diff --git a/contrib/ntp/scripts/monitoring/ntp.pl b/contrib/ntp/scripts/monitoring/ntp.pl
index ea9e69c..b23f396 100644
--- a/contrib/ntp/scripts/monitoring/ntp.pl
+++ b/contrib/ntp/scripts/monitoring/ntp.pl
@@ -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 @@ $keyid=0;
;# 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 @@ sub PeerSelection
{
&getval(&psw_PSel($_[$[]),*PeerSelection);
}
+
sub PeerEvent
{
&getval(&psw_PCode($_[$[]),*PeerEvent);
@@ -394,14 +395,14 @@ sub handle_packet
$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}))
{
diff --git a/contrib/ntp/scripts/monitoring/ntploopstat b/contrib/ntp/scripts/monitoring/ntploopstat
index 75cdff2..7583c7c 100644
--- a/contrib/ntp/scripts/monitoring/ntploopstat
+++ b/contrib/ntp/scripts/monitoring/ntploopstat
@@ -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
OpenPOWER on IntegriCloud