2 Received: from huey2.ee.udel.edu by mail.eecis.udel.edu id aa25207;
4 Received: from copland.udel.edu by huey.udel.edu id aa16958;
6 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)
7 Received: from ngate.ngate.uni-regensburg.de (ngate.rz.uni-regensburg.de [132.199.3.13])
8 by rrzs2.rz.uni-regensburg.de (8.8.5/8.8.5) with SMTP id QAA19974
9 for <mills@udel.edu>; Wed, 10 Dec 1997 16:38:42 +0100 (MET)
10 Received: from rkdvmks1.ngate.uni-regensburg.de by ngate.ngate.uni-regensburg.de; Wed, 10 Dec 97 16:39 MET
11 Received: from rkdvmks1.ngate.uni-regensburg.de by kgate.ngate.uni-regensburg.de; Wed, 10 Dec 97 15:38 GMT
12 Received: from RKDVMKS1/SpoolDir by rkdvmks1.ngate.uni-regensburg.de (Mercury 1.32);
13 10 Dec 97 16:38:34 +0100
14 Received: from SpoolDir by RKDVMKS1 (Mercury 1.32); 10 Dec 97 16:38:06 +0100
15 From: Ulrich Windl <ulrich.windl@rz.uni-regensburg.de>
16 Organization: Universitaet Regensburg, Klinikum
18 Date: Wed, 10 Dec 1997 16:38:04 +0100
20 Content-Type: text/plain; charset=US-ASCII
21 Content-transfer-encoding: 7BIT
22 Subject: Big patch to scripts/monitoring
24 X-mailer: Pegasus Mail for Windows (v2.53/R1)
25 Message-ID: <103AB9D209F5@rkdvmks1.ngate.uni-regensburg.de>
27 Dave, there's another big patch against scripts/monitoring. The Perl
28 programs in there are rather old. As they are quite nice thogh, I
29 decided to update them for the latest version of Perl, namely 5.004.
31 I'll include the description of changes and the patch.
35 Here is a description of changes made in ntploopwatch:
37 Corrected most warnings that PERL 5.004 might emit. Corrected signal
38 handlers to make them work again. Corrected scaling (at least I
39 think). Supported case when output is sent to file or printer and
40 there is no X11 available. Fixed number of month in xlabels of the
43 Added the ability to specify printer for GNUplot other that
44 PostScript. Use hostname if $STATHOST is not given in configuration
45 file. Corrected verbosity level for some messages. Added ability to
46 specify a non-standard print command.
48 Perl 5.004_04 does no longer ignore ``-w--*-perl-*-''. Made some
49 cosmetic changes and added a timescale of 10 minutes.
51 (Other programs are functionally unchanged. lr.pl is a PERL module now.)
55 ===================================================================
56 RCS file: /home/windl/NTP/mon-REP/monitoring/README,v
57 retrieving revision 1.1.1.1
58 retrieving revision 1.2
59 diff -u -r1.1.1.1 -r1.2
60 --- README 1993/08/24 19:29:34 1.1.1.1
61 +++ README 1997/10/23 17:51:37 1.2
63 This directory contains support for monitoring the local clock of xntp daemons.
65 -WARNING: The scripts and routines contained in this directory are bete realease!
66 - Do not depend on their correct operation. They are, however, in regular
67 - use at University of Erlangen-Nuernberg. No severe problems are known
69 +WARNING: The scripts and routines contained in this directory are beta
70 + release! Do not depend on their correct operation. They are,
71 + however, in regular use at University of Erlangen-Nuernberg.
72 + No severe problems are known for this code.
74 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
75 PLEASE THINK TWICE BEFORE STARTING MONITORING REMOTE XNTP DEAMONS !!!!
76 MONITORING MAY INCREASE THE LOAD OF THE DEAMON MONITORED AND MAY
77 -INCREASE THE NETWORK LOAD SIGNIFICANTLY
78 +INCREASE THE NETWORK LOAD SIGNIFICANTLY
79 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
83 It sends a set_trap request to each server given and dumps the
84 trap messages received. It handles refresh of set_trap.
85 Currently it handles only NTP V2, however the NTP V3 servers
86 - also accept v2 requests. It will not interpret v3 system and peer
88 + also accept v2 requests. It will not interpret v3 system and
89 + peer stati correctly.
92 ntptrap [-n] [-p <port>] [-l <debug-output>] servers...
95 if a timeout occurs the next sample is tried after delay/2 seconds
97 - The script will terminate after MAX_FAIL (currently 60) consecutive errors.
98 + The script will terminate after MAX_FAIL (currently 60)
101 Errors are counted for:
103 - error on select call
104 @@ -114,10 +116,10 @@
105 command line values would be replaced by settings from the config file.
107 printer: specify printer to print plot
108 - BSD print systems semantics apply; if printer is omitted
109 - the name "ps" is used; plots are prepared using
110 - PostScript, thus the printer should best accept
112 + BSD print systems semantics apply; if printer
113 + is omitted the name "ps" is used; plots are
114 + prepared using PostScript, thus the printer
115 + should best accept postscript input
117 For the following see also the comments in loopwatch.config.SAMPLE
123 - used during conversion of ISO_DATE_TIME values specified in loopwatch
124 - config files to unix epoch values (seconds since 1970-01-01_00:00_00 UTC)
126 + used during conversion of ISO_DATE_TIME values specified in
127 + loopwatch config files to unix epoch values (seconds since
128 + 1970-01-01_00:00_00 UTC)
130 A version of this file is distributed with perl-4.x, however,
131 it has a bug related to dates crossing 1970, causing endless loops..
133 ===================================================================
134 RCS file: /home/windl/NTP/mon-REP/monitoring/lr.pl,v
135 retrieving revision 1.1.1.1
136 retrieving revision 1.4
137 diff -u -r1.1.1.1 -r1.4
138 --- lr.pl 1993/08/24 19:29:33 1.1.1.1
139 +++ lr.pl 1997/10/23 17:51:37 1.4
141 ;# Frank Kardel, Rainer Pruy
142 ;# Friedrich-Alexander Universitaet Erlangen-Nuernberg
144 +;# Copyright (c) 1997 by
145 +;# Ulrich Windl <Ulrich.Windl@rz.uni-regensburg.de>
146 +;# (Converted to a PERL 5.004 package)
148 ;#############################################################
155 @@ -23,123 +28,124 @@
159 -*lr_init = *lr'lr_init; #';# &lr_init(tag); initialize data set for tag
160 -*lr_sample = *lr'lr_sample; #';# &lr_sample(x,y,tag); enter sample
161 -*lr_Y = *lr'lr_Y; #';# &lr_Y(x,tag); compute y for given x
162 -*lr_X = *lr'lr_X; #';# &lr_X(y,tag); compute x for given y
163 -*lr_r = *lr'lr_r; #';# &lr_r(tag); regression coeffizient
164 -*lr_cov = *lr'lr_cov; #';# &lr_cov(tag); covariance
165 -*lr_A = *lr'lr_A; #';# &lr_A(tag);
166 -*lr_B = *lr'lr_B; #';# &lr_B(tag);
167 -*lr_sigma = *lr'lr_sigma; #';# &lr_sigma(tag); standard deviation
168 -*lr_mean = *lr'lr_mean; #';# &lr_mean(tag);
169 +;# init(tag); initialize data set for tag
170 +;# sample(x, y, tag); enter sample
171 +;# Y(x, tag); compute y for given x
172 +;# X(y, tag); compute x for given y
173 +;# r(tag); regression coefficient
174 +;# cov(tag); covariance
177 +;# sigma(tag); standard deviation
179 #########################
188 - *lr_n = eval "*${tag}_n";
189 - *lr_sx = eval "*${tag}_sx";
190 - *lr_sx2 = eval "*${tag}_sx2";
191 - *lr_sxy = eval "*${tag}_sxy";
192 - *lr_sy = eval "*${tag}_sy";
193 - *lr_sy2 = eval "*${tag}_sy2";
200 - &tagify($_[$[]) if defined($_[$[]);
211 + $self->{sx2} = 0.0;
212 + $self->{sxy} = 0.0;
214 + $self->{sy2} = 0.0;
220 - local($_x, $_y) = @_;
222 - &tagify($_[$[+2]) if defined($_[$[+2]);
229 - $lr_sxy += $_x * $_y;
233 + $self->{sx} += $_x;
234 + $self->{sy} += $_y;
235 + $self->{sxy} += $_x * $_y;
236 + $self->{sx2} += $_x**2;
237 + $self->{sy2} += $_y**2;
243 - &tagify($_[$[]) if defined($_[$[]);
246 - return 1 unless ($lr_n * $lr_sx2 - $lr_sx**2);
247 - return ($lr_n * $lr_sxy - $lr_sx * $lr_sy) / ($lr_n * $lr_sx2 - $lr_sx**2);
248 + return 1 unless ($self->{n} * $self->{sx2} - $self->{sx}**2);
249 + return ($self->{n} * $self->{sxy} - $self->{sx} * $self->{sy})
250 + / ($self->{n} * $self->{sx2} - $self->{sx}**2);
256 - &tagify($_[$[]) if defined($_[$[]);
259 - return ($lr_sy - &lr_B * $lr_sx) / $lr_n;
260 + return ($self->{sy} - B($self) * $self->{sx}) / $self->{n};
266 - &tagify($_[$[]) if defined($_[$[]);
269 - return &lr_A + &lr_B * $_[$[];
270 + return A($self) + B($self) * $_[$[];
276 - &tagify($_[$[]) if defined($_[$[]);
279 - return ($_[$[] - &lr_A) / &lr_B;
280 + return ($_[$[] - A($self)) / B($self);
286 - &tagify($_[$[]) if defined($_[$[]);
289 - local($s) = ($lr_n * $lr_sx2 - $lr_sx**2) * ($lr_n * $lr_sy2 - $lr_sy**2);
290 + my $s = ($self->{n} * $self->{sx2} - $self->{sx}**2)
291 + * ($self->{n} * $self->{sy2} - $self->{sy}**2);
295 - return ($lr_n * $lr_sxy - $lr_sx * $lr_sy) / sqrt($s);
296 + return ($self->{n} * $self->{sxy} - $self->{sx} * $self->{sy}) / sqrt($s);
302 - &tagify($_[$[]) if defined($_[$[]);
305 - return ($lr_sxy - $lr_sx * $lr_sy / $lr_n) / ($lr_n - 1);
306 + return ($self->{sxy} - $self->{sx} * $self->{sy} / $self->{n})
307 + / ($self->{n} - 1);
313 - &tagify($_[$[]) if defined($_[$[]);
316 - return 0 if $lr_n <= 1;
317 - return sqrt(($lr_sy2 - ($lr_sy * $lr_sy) / $lr_n) / ($lr_n));
318 + return 0 if $self->{n} <= 1;
319 + return sqrt(($self->{sy2} - ($self->{sy} * $self->{sy}) / $self->{n})
326 - &tagify($_[$[]) if defined($_[$[]);
329 - return 0 if $lr_n <= 0;
330 - return $lr_sy / $lr_n;
331 + return 0 if $self->{n} <= 0;
332 + return $self->{sy} / $self->{n};
347 + bless $self, $class;
354 ===================================================================
355 RCS file: /home/windl/NTP/mon-REP/monitoring/ntp.pl,v
356 retrieving revision 1.1.1.1
357 retrieving revision 1.3
358 diff -u -r1.1.1.1 -r1.3
359 --- ntp.pl 1993/08/24 19:29:34 1.1.1.1
360 +++ ntp.pl 1997/10/23 18:19:41 1.3
365 ;# ntp.pl,v 3.1 1993/07/06 01:09:09 jbj Exp
371 -;# first bye of packet
372 +;# first byte of packet
373 sub pkt_LI { return ($_[$[] >> 6) & 0x3; }
374 sub pkt_VN { return ($_[$[] >> 3) & 0x7; }
375 sub pkt_MODE { return ($_[$[] ) & 0x7; }
378 &getval(&psw_PSel($_[$[]),*PeerSelection);
383 &getval(&psw_PCode($_[$[]),*PeerEvent);
384 @@ -394,14 +395,14 @@
385 $lastseen = 1 if !&pkt_M($r_e_m_op);
386 if (!defined(%FRAGS))
388 - (&pkt_M($r_e_m_op) ? " more" : "")."\n";
389 + print((&pkt_M($r_e_m_op) ? " more" : "")."\n");
390 $FRAGS{$offset} = $data;
392 @FRAGS = ($status,$associd,&pkt_OP($r_e_m_op),$seq,$auth_keyid,$r_e_m_op);
396 - (&pkt_M($r_e_m_op) ? " more" : "")."\n";
397 + print((&pkt_M($r_e_m_op) ? " more" : "")."\n");
398 ;# add frag to previous - combine on the fly
399 if (defined($FRAGS{$offset}))
402 ===================================================================
403 RCS file: /home/windl/NTP/mon-REP/monitoring/ntploopstat,v
404 retrieving revision 1.1.1.1
405 retrieving revision 1.3
406 diff -u -r1.1.1.1 -r1.3
407 --- ntploopstat 1993/08/24 19:29:32 1.1.1.1
408 +++ ntploopstat 1997/11/23 19:07:12 1.3
410 -#!/local/bin/perl -w--*-perl-*-
414 ;# ntploopstat,v 3.1 1993/07/06 01:09:11 jbj Exp
417 ;# (Should have implemented &gettimeofday()..)
420 -$0 =~ s!^.*/([^/]+)$!\1!; # beautify script name
421 +$0 =~ s!^.*/([^/]+)$!$1!; # beautify script name
423 $ntpserver = 'localhost'; # default host to poll
424 $delay = 60; # default sampling rate
426 ===================================================================
427 RCS file: /home/windl/NTP/mon-REP/monitoring/ntploopwatch,v
428 retrieving revision 1.1.1.1
429 retrieving revision 1.14
430 diff -u -r1.1.1.1 -r1.14
431 --- ntploopwatch 1993/10/22 14:28:18 1.1.1.1
432 +++ ntploopwatch 1997/12/07 17:06:36 1.14
434 -#!/local/bin/perl -w--*-perl-*-
438 ;# ntploopwatch,v 3.1 1993/07/06 01:09:13 jbj Exp
441 ;# Copyright (c) 1992
442 ;# Rainer Pruy Friedrich-Alexander Universitaet Erlangen-Nuernberg
444 +;# Copyright (c) 1997
445 +;# Ulrich Windl <Ulrich.Windl@rz.uni-regensburg.de>
446 +;# (Corrections for Perl5 and other fixes)
448 ;#############################################################
449 -$0 =~ s!^.*/([^/]+)$!\1!;
450 +$0 =~ s!^.*/([^/]+)$!$1!;
451 $F = ' ' x length($0);
454 +use 5.004; # require 5.004
456 $ENV{'SHELL'} = '/bin/sh'; # use bourne shell
463 -($a,$b) if 0; # keep -w happy
467 - to watch statistics permanently:
468 + to watch statistics periodically:
469 $0 [-v[<level>]] [-c <config-file>] [-d <working-dir>]
472 to get a single print out specify also
473 - $F -P[<printer>] [-s<samples>]
474 - $F [-S <start-time>] [-E <end-time>]
475 - $F [-Y <MaxOffs>] [-y <MinOffs>]
476 + $F -P[[<term_type:>]<printer>]
477 + $F [-s<samples>] [-S <start-time>] [-E <end-time>]
478 + $F [-Y <MaxOffs>] [-y <MinOffs>]
480 If You like long option names, You can use:
485 -v +verbose[=<level>]
486 - -P +printer[=<printer>]
487 + -P +printer[=[<term_type>:]<printer>[:<print_cmd>]]
488 -s +samples[=<samples>]
494 +If <printer> is prefixed with a <term_type> and a colon, the <term_type>
495 +given is used as terminal fpr gnuplot.
496 If <printer> contains a '/' (slash character) output is directed to
497 a file of this name instead of delivered to a printer.
498 +If suffix :<print_cmd> is given, the suffix is used as the print command,
499 +and <printer> is ignored. If blanks are needed inside <term_type> or
500 +<print_cmd>, just use underscores instead.
503 ;# add directory to look for lr.pl and timelocal.pl (in front of current list)
504 unshift(@INC,"/src/NTP/v3/xntp/monitoring");
506 require "lr.pl"; # linear regresion routines
507 +my $lr_offs = new lr;
508 +my $lr_freq = new lr;
510 $MJD_1970 = 40587; # from ntp.h (V3)
511 $RecordSize = 48; # usually a line fits into 42 bytes
512 @@ -171,16 +184,20 @@
514 ;# configuration file
515 $config = "loopwatch.config" unless defined($config);
516 -($STATHOST = $config) =~ s!.*loopwatch\.config.([^/\.]*)$!\1!
517 +($STATHOST = $config) =~ s!.*loopwatch\.config.([^/\.]+)$!$1!
518 unless defined($STATHOST);
519 -($STATTAG = $STATHOST) =~ s/^([^\.\*\s]+)\..*$/\1/;
520 +if ($STATHOST eq $config) {
521 + require "hostname.pl";
522 + $STATHOST = hostname();
524 +($STATTAG = $STATHOST) =~ s/^([^\.\*\s]+)\..*$/$1/;
526 $srcprefix =~ s/\$STATHOST/$STATHOST/g;
529 -@plotcmd=("gnuplot",
530 - '-title', "Ntp loop filter statistics $STATHOST",
531 - '-name', "NtpLoopWatch_$STATTAG");
532 +@plotcmd=("gnuplot");
533 +push(@plotcmd, '-title', "NTP loop filter statistics for $STATHOST",
534 + '-name', "NtpLoopWatch_$STATTAG") unless $PrintIt;
535 $tmpfile = "/tmp/ntpstat.$$";
539 $?>>8,$? & 0xff)) if $?;
540 exit(1) if $? && defined($Plotpid) && $pid == $Plotpid;
543 -$SIG{'CHLD'} = "sigchld";
544 -$SIG{'CLD'} = "sigchld";
545 +$SIG{'CHLD'} = \&sigchld;
546 +$SIG{'CLD'} = \&sigchld;
551 defined($Plotpid) && kill('TERM',$Plotpid);
552 die("$0: received signal SIG$_[$[] - exiting\n");
554 -&abort if 0; # make -w happy - &abort IS used
555 -$SIG{'INT'} = $SIG{'HUP'} = $SIG{'QUIT'} = $SIG{'TERM'} = $SIG{'PIPE'} = "abort";
556 +$SIG{'INT'} = $SIG{'HUP'} = $SIG{'QUIT'} = $SIG{'TERM'} = $SIG{'PIPE'} = \&abort;
561 open(STDOUT,">&STDERR") ||
562 die("$0: failed to redirect STDOUT of plot command: $!\n");
564 - print STDOUT "plot command running as $$\n";
565 + print STDOUT "plot command has PID $$\n";
568 die("$0: failed to exec (@plotcmd): $!\n");
569 @@ -275,128 +290,83 @@
570 s/^([^\#]*[^\#\s]?)\s*\#.*$//;
573 - s/^\s*([^=\s]*)\s*=\s*(.*\S)\s*$/\1=\2/;
574 + s/^\s*([^=\s]*)\s*=\s*(.*\S)\s*$/$1=$2/;
576 - ($c,$v) = split(/=/,$_,2);
577 + ($c,$v) = ($1, $2);
578 print "processing \"$c=$v\"\n" if $verbose > 3;
579 - ($c eq "delay") && ($delay = $v,1) && next;
580 - ($c eq 'samples') && (!defined($PrintIt) || !defined($samples)) &&
581 - ($samples = $v,1) && next;
582 - ($c eq 'srcprefix') && (($srcprefix=$v)=~s/\$STATHOST/$STATHOST/g,1)
584 - ($c eq 'showoffs') &&
585 - ($showoffs = ($v eq 'yes' || $v eq 'y' || $v != 0),1) && next;
586 - ($c eq 'showfreq') &&
587 - ($showfreq = ($v eq 'yes' || $v eq 'y' || $v != 0),1) && next;
588 - ($c eq 'showcmpl') &&
589 - ($showcmpl = ($v eq 'yes' || $v eq 'y' || $v != 0),1) && next;
590 - ($c eq 'showoreg') &&
591 - ($showoreg = ($v eq 'yes' || $v eq 'y' || $v != 0),1) && next;
592 - ($c eq 'showfreg') &&
593 - ($showfreg = ($v eq 'yes' || $v eq 'y' || $v != 0),1) && next;
595 - ($c eq 'exit') && (unlink($tmpfile),die("$0: exit by config request\n"));
597 - ($c eq 'freqbase' ||
598 - $c eq 'cmplscale') &&
600 - if (! defined($v) || $v eq "" || $v eq 'dynamic')
602 - eval "undef(\$$c);";
606 - eval "\$$c = \$v;";
610 - ($c eq 'timebase') &&
612 - if (! defined($v) || $v eq "" || $v eq "dynamic")
618 - $timebase=&date_time_spec2seconds($v);
621 - ($c eq 'EndTime') &&
623 - next if defined($EndTime) && defined($PrintIt);
624 - if (! defined($v) || $v eq "" || $v eq "none")
630 - $EndTime=&date_time_spec2seconds($v);
633 - ($c eq 'StartTime') &&
635 - next if defined($StartTime) && defined($PrintIt);
636 - if (! defined($v) || $v eq "" || $v eq "none")
642 - $StartTime=&date_time_spec2seconds($v);
648 - next if defined($MaxY) && defined($PrintIt);
649 - if (! defined($v) || $v eq "" || $v eq "none")
661 - next if defined($MinY) && defined($PrintIt);
662 - if (! defined($v) || $v eq "" || $v eq "none")
672 - ($c eq 'deltaT') &&
674 - if (!defined($v) || $v eq "")
684 - ($c eq 'verbose') && ! defined($PrintIt) &&
686 - if (!defined($v) || $v == 0)
696 - ;# otherwise: silently ignore unrecognized config line
697 + if ($c eq "delay") {
699 + } elsif ($c eq 'samples') {
700 + $samples = $v if (!defined($PrintIt) || !defined($samples));
701 + } elsif ($c eq 'srcprefix') {
702 + ($srcprefix = $v) =~ s/\$STATHOST/$STATHOST/g;
703 + } elsif ($c eq 'showoffs') {
704 + $showoffs = ($v =~ /^yes$|^y$|^1$/);
705 + } elsif ($c eq 'showfreq') {
706 + $showfreq = ($v =~ /^yes$|^y$|^1$/);
707 + } elsif ($c eq 'showcmpl') {
708 + $showcmpl = ($v =~ /^yes$|^y$|^1$/);
709 + } elsif ($c eq 'showoreg') {
710 + $showoreg = ($v =~ /^yes$|^y$|^1$/);
711 + } elsif ($c eq 'showfreg') {
712 + $showfreg = ($v =~ /^yes$|^y$|^1$/);
713 + } elsif ($c eq 'exit') {
714 + unlink($tmpfile); die("$0: exit by config request\n");
715 + } elsif ($c eq 'freqbase' || $c eq 'cmplscale') {
716 + if (! defined($v) || $v eq "" || $v eq 'dynamic') {
717 + eval "undef(\$$c);";
719 + eval "\$$c = \$v;";
721 + } elsif ($c eq 'timebase') {
722 + if (! defined($v) || $v eq "" || $v eq "dynamic") {
725 + $timebase=&date_time_spec2seconds($v);
727 + } elsif ($c eq 'EndTime') {
728 + next if defined($EndTime) && defined($PrintIt);
729 + if (! defined($v) || $v eq "" || $v eq "none") {
732 + $EndTime=&date_time_spec2seconds($v);
734 + } elsif ($c eq 'StartTime') {
735 + next if defined($StartTime) && defined($PrintIt);
736 + if (! defined($v) || $v eq "" || $v eq "none") {
739 + $StartTime=&date_time_spec2seconds($v);
741 + } elsif ($c eq 'MaxY') {
742 + next if defined($MaxY) && defined($PrintIt);
743 + if (! defined($v) || $v eq "" || $v eq "none") {
748 + } elsif ($c eq 'MinY') {
749 + next if defined($MinY) && defined($PrintIt);
750 + if (! defined($v) || $v eq "" || $v eq "none") {
755 + } elsif ($c eq 'deltaT') {
756 + if (!defined($v) || $v eq "") {
761 + } elsif ($c eq 'verbose' && ! defined($PrintIt)) {
762 + if (!defined($v) || $v == 0) {
768 + ;# otherwise: silently ignore unrecognized config line
772 ;# set show defaults when nothing selected
773 @@ -413,16 +383,16 @@
774 print " showcmpl\t= $showcmpl\n";
775 print " showoreg\t= $showoreg\n";
776 print " showfreg\t= $showfreg\n";
777 - printf " timebase\t= %s",defined($timebase)?&ctime($timebase):"dynamic\n";
778 - printf " freqbase\t= %s\n",defined($freqbase) ?"$freqbase":"dynamic";
779 - printf " cmplscale\t= %s\n",defined($cmplscale)?"$cmplscale":"dynamic";
780 - printf " StartTime\t= %s",defined($StartTime)?&ctime($StartTime):"none\n";
781 - printf " EndTime\t= %s", defined($EndTime) ? &ctime($EndTime):"none\n";
782 - printf " MaxY\t= %s",defined($MaxY)? $MaxY :"none\n";
783 - printf " MinY\t= %s",defined($MinY)? $MinY :"none\n";
784 + printf " timebase\t= %s", defined($timebase) ? &ctime($timebase) : "dynamic\n";
785 + printf " freqbase\t= %s\n", defined($freqbase) ? "$freqbase" : "dynamic";
786 + printf " cmplscale\t= %s\n", defined($cmplscale) ? "$cmplscale" : "dynamic";
787 + printf " StartTime\t= %s", defined($StartTime) ? &ctime($StartTime) : "none\n";
788 + printf " EndTime\t= %s", defined($EndTime) ? &ctime($EndTime):"none\n";
789 + printf " MaxY\t= %s", defined($MaxY) ? $MaxY : "none\n";
790 + printf " MinY\t= %s", defined($MinY) ? $MinY : "none\n";
791 print " verbose\t= $verbose\n";
793 -print "configuration file read\n" if $verbose > 2;
794 + print "configuration file read\n" if $verbose > 2;
799 ;# number of integral seconds to get at least 12 tic marks on x axis
800 $t = int(($maxtime - $mintime) / 12 + 0.5);
801 $t = 1 unless $t; # prevent $t to be zero
803 - 60,5*60,15*60,30*60,
804 - 60*60,2*60*60,6*60*60,12*60*60,
806 + foreach $i (30, 60,
807 + 5*60, 10*60, 15*60, 30*60, 60*60,
808 + 2*60*60, 6*60*60, 12*60*60, 24*60*60, 48*60*60)
812 @@ -458,31 +427,30 @@
816 + my ($sec, $min, $hour, $mday, $mon, $year, $wday) = localtime($i);
819 ((int($i / $t) % 2) &&
820 ($s .= sprintf("'' %lf",($i - $LastTimeBase)/3600))) ||
822 ($s .= sprintf("'%d:%02d:%02d' %lf",
823 - (localtime($i))[$[+2,$[+1,$[+0],
824 - ($i - $LastTimeBase)/3600)))
825 + $hour, $min, $sec, ($i - $LastTimeBase) / 3600)))
826 || (($t <= 2*60*60) &&
827 ($s .= sprintf("'%d:%02d' %lf",
828 - (localtime($i))[$[+2,$[+1],
829 - ($i - $LastTimeBase)/3600)))
830 + $hour, $min, ($i - $LastTimeBase) / 3600)))
831 || (($t <= 12*60*60) &&
832 ($s .= sprintf("'%s %d:00' %lf",
833 - $Day[(localtime($i))[$[+6]],
834 - (localtime($i))[$[+2],
835 - ($i - $LastTimeBase)/3600)))
836 + $Day[$wday], $hour,
837 + ($i - $LastTimeBase) / 3600)))
838 || ($s .= sprintf("'%d.%d-%d:00' %lf",
839 - (localtime($i))[$[+3,$[+4,$[+2],
840 - ($i - $LastTimeBase)/3600));
841 + $mday, $mon + 1, $hour,
842 + ($i - $LastTimeBase) / 3600));
844 $doplot .= "set xtics ($s)\n";
846 chop($xts = &ctime($mintime));
847 chop($xte = &ctime($maxtime));
848 - $doplot .= "set xlabel 'Start: $xts -- Time Scale -- End: $xte'\n";
849 + $doplot .= "set xlabel 'Start: $xts -- Time Scale -- End: $xte'\n";
850 $doplot .= "set yrange [" ;
851 $doplot .= defined($MinY) ? sprintf("%lf", $MinY) : $miny;
853 @@ -518,22 +486,22 @@
855 $showoreg && $showoffs &&
856 ($doplot .= sprintf($regfmt, $c,
857 - &lr_B('offs'),&lr_A('offs'),
860 - ((&lr_A('offs')) < 0 ? '-' : '+'),
861 - &abs(&lr_A('offs')), &lr_r('offs'),
862 + $lr_offs->B(),$lr_offs->A(),
865 + (($lr_offs->A()) < 0 ? '-' : '+'),
866 + &abs($lr_offs->A()), $lr_offs->r(),
869 $showfreg && $showfreq &&
870 ($doplot .= sprintf($regfmt, $c,
871 - &lr_B('freq') * $FreqScale,
872 - (&lr_A('freq') + $minfreq) * $FreqScale - $LastFreqBase,
873 + $lr_freq->B() * $FreqScale,
874 + ($lr_freq->A() + $minfreq) * $FreqScale - $LastFreqBase,
876 - &lr_B('freq') * $FreqScale,
877 - ((&lr_A('freq') + $minfreq) * $FreqScale - $LastFreqBase) < 0 ? '-' : '+',
878 - &abs((&lr_A('freq') + $minfreq) * $FreqScale - $LastFreqBase),
880 + $lr_freq->B() * $FreqScale,
881 + (($lr_freq->A() + $minfreq) * $FreqScale - $LastFreqBase) < 0 ? '-' : '+',
882 + &abs(($lr_freq->A() + $minfreq) * $FreqScale - $LastFreqBase),
884 "[${FreqScaleInv}ppm]"),
890 print "memory allocation ready\n" if $verbose > 2;
891 - sleep(3) if $verbose > 1;
892 + sleep(3) if $verbose > 2;
894 if (index($in,"/") < $[)
897 ;# rescan directory on changes
899 $Ltime = (stat($sdir))[$[+9];
900 - </X{> if 0; # dummy line - calm down my formatter
901 local(@newfiles) = < ${in}*[0-9] >;
902 local($st_dev,$st_ino,$st_mtime,$st_size,$name,$key,$modified);
905 $F_key{$name} = $key;
908 - if (!defined($F_name{$key}) || $F_name{$key} != $name)
909 + if (!defined($F_name{$key}) || $F_name{$key} ne $name)
911 $F_name{$key} = $name;
917 - print "new data \"$name\" key: $key;\n" if $verbose > 1;
918 + print "new data \"$name\" key: $key;\n" if $verbose > 2;
919 print " size: $st_size; mtime: $st_mtime;\n"
922 $F_last{$key} = $F_first{$key} = $st_mtime;
923 $F_first{$key}--; # prevent zero divide later on
924 ;# now compute derivated attributes
928 print(" first: ",$F_first{$key},
929 - " last: ",$F_last{$key},"\n") if $verbose > 1;
930 + " last: ",$F_last{$key},"\n") if $verbose > 2;
933 ;# now reclaim memory used for files no longer referenced ...
936 ;# create list sorted by time
937 @F_files = sort {$F_first{$a} <=> $F_first{$b}; } keys(%F_name);
941 print "Resulting file list:\n";
944 print "guess start according to StartTime ($StartTime)\n"
947 - if ($fpos[$[] eq 'start')
948 + if (defined $fpos[$[] && $fpos[$[] eq 'start')
950 if (grep($_ eq $fpos[$[+1],@f))
953 $t += $F[$[+1]; # add seconds + fraction
955 ;# multiply offset by 1000 to get ms - try to avoid float op
956 - (($F[$[+2] =~ s/(\d*)\.(\d{3})(\d*)/\1\2.\3/) &&
957 + (($F[$[+2] =~ s/(\d*)\.(\d{3})(\d*)/$1$2.$3/) &&
958 $F[$[+2] =~ s/0+([\d\.])/($1 eq '.') ? '0.' : $1/e) # strip leading zeros
959 - || $F[$[+2] *= 1000;
960 + || ($F[$[+2] *= 1000);
963 ;# skip samples out of specified time range
964 @@ -1036,8 +1003,8 @@
965 print "input scanned ($l lines/",scalar(@time)," samples)\n"
975 @@ -1047,17 +1014,17 @@
976 local($freqbase) unless defined($freqbase);
977 local($cmplscale) unless defined($cmplscale);
979 - undef($mintime,$maxtime,$minoffs,$maxoffs,
980 - $minfreq,$maxfreq,$mincmpl,$maxcmpl,
982 + undef $mintime; undef $maxtime; undef $minoffs; undef $maxoffs;
983 + undef $minfreq; undef $maxfreq; undef $mincmpl; undef $maxcmpl;
984 + undef $miny; undef $maxy;
986 print "computing ranges\n" if $verbose > 2;
990 ;# @time is in ascending order (;-)
991 - $mintime = @time[$[];
992 - $maxtime = @time[$#time];
993 + $mintime = $time[$[];
994 + $maxtime = $time[$#time];
995 unless (defined($timebase))
997 local($time,@X) = (time);
998 @@ -1081,24 +1048,24 @@
999 ;# (otherwise a (shift(@a1),shift(a2)) would do),
1000 ;# I dont like to make copies of these arrays as they may be huge
1002 - &lr_sample(($time[$i]-$timebase)/3600,$offs[$