Lines Matching +full:scaled +full:- +full:sync

1 #!/usr/bin/perl -w
2 ;# --*-perl-*--
4 ;# /src/NTP/ntp4-dev/scripts/monitoring/ntploopwatch,v 4.7 2004/11/14 16:11:05 kardel RELEASE_20050…
7 ;# - show statistics periodically using gnuplot
8 ;# - or print a single plot
10 ;# Copyright (c) 1992-1998
11 ;# Rainer Pruy, Friedrich-Alexander Universit�t Erlangen-N�rnberg
27 ($a,$b) if 0; # keep -w happy
28 $usage = <<"E-O-P";
31 $0 [-v[<level>]] [-c <config-file>] [-d <working-dir>]
32 $F [-h <hostname>]
35 $F -P[<printer>] [-s<samples>]
36 $F [-S <start-time>] [-E <end-time>]
37 $F [-Y <MaxOffs>] [-y <MinOffs>]
40 -help
41 -c +config
42 -d +directory
43 -h +host
44 -v +verbose[=<level>]
45 -P +printer[=<printer>]
46 -s +samples[=<samples>]
47 -S +starttime
48 -E +endtime
49 -Y +maxy
50 -y +miny
54 E-O-P
77 } # ' re-sync emacs fontification
83 print @ctime'DoW if 0; # ' re-sync emacs fontification
106 (/^[+-]help$/) && die($usage);
108 (/^-c$/ || /^\+config$/) &&
111 (/^-d$/ || /^\+directory$/) &&
114 (/^-h$/ || /^\+host$/) &&
117 (/^-v(\d*)$/ || /^\+verbose=?(\d*)$/) &&
120 (/^-P(\S*)$/ || /^\+[Pp]rinter=?(\S*)$/) &&
123 (/^-s(\d*)$/ || /^\+samples=?(\d*)$/) &&
126 (/^-S$/ || /^\+[Ss]tart[Tt]ime$/) &&
129 (/^-E$/ || /^\+[Ee]nd[Tt]ime$/) &&
132 (/^-Y$/ || /^\+[Mm]ax[Yy]$/) &&
135 (/^-y$/ || /^\+[Mm]in[Yy]$/) &&
185 '-title', "Ntp loop filter statistics $STATHOST",
186 '-name', "NtpLoopWatch_$STATTAG");
225 die("$0: received signal SIG$_[$[] - exiting\n");
227 &abort if 0; # make -w happy - &abort IS used
233 ($_[$[] < 0) ? -($_[$[]) : $_[$[];
241 return 1 if ($v =~ /^[0-9]*$/) && ($v != 0);
250 $Plotpid = open(PLOT,"|-");
282 (warn("$0: failed to read \"$config\" - using old settings ($!)\n"),
457 $t = int(($maxtime - $mintime) / 12 + 0.5);
465 $t = $t - ($t % $i);
470 for ($c="", $i = $mintime - ($mintime % $t);
476 ($s .= sprintf("'' %lf",($i - $LastTimeBase)/3600))) ||
480 ($i - $LastTimeBase)/3600)))
484 ($i - $LastTimeBase)/3600)))
489 ($i - $LastTimeBase)/3600)))
490 || ($s .= sprintf("'%d.%d-%d:00' %lf",
492 ($i - $LastTimeBase)/3600));
498 $doplot .= "set xlabel 'Start: $xts -- Time Scale -- End: $xte'\n";
531 ? " - $LastFreqBaseString"
533 $minfreq * $FreqScale - $LastFreqBase,
534 $maxfreq * $FreqScale - $LastFreqBase,
539 $lo->B(),$lo->A(),
541 $lo->B(),
542 (($lo->A()) < 0 ? '-' : '+'),
543 &abs($lo->A()), $lo->r(),
548 $lf->B() * $FreqScale,
549 ($lf->A() + $minfreq) * $FreqScale - $LastFreqBase,
551 $lf->B() * $FreqScale,
552 (($lf->A() + $minfreq) * $FreqScale - $LastFreqBase) < 0 ? '-' : '+',
553 &abs(($lf->A() + $minfreq) * $FreqScale - $LastFreqBase),
554 $lf->r(),
581 $l = ($EndTime-$StartTime) -$[+1 +1; # worst case: 1 sample per second
596 $#break = $[ - 1;
597 $#time = $[ - 1;
598 $#offs = $[ - 1;
599 $#freq = $[ - 1;
600 $#cmpl = $[ - 1;
601 $#loffset = $[ - 1;
602 $#filekey = $[ - 1;
619 $Ltime = -1 if ! defined($Ltime);
630 </X{> if 0; # dummy line - calm down my formatter
631 local(@newfiles) = < ${in}*[0-9] >;
671 $F_first{$key}--; # prevent zero divide later on
684 $t = ($F[$[] - $MJD_1970) * 24 * 60 * 60;
692 ($st_size > 4*$RecordSize) ? $st_size - 4*$RecordSize : 0,
699 $t = ($F[$[] - $MJD_1970) * 24 * 60 * 60;
782 ;# open output file - will be input for plotcmd
847 (($StartTime - $F_first{$f[$[]})/
848 ($F_last{$f[$[]} - $F_first{$f[$[]})));
850 ? 0 : $fpos[$[+2] - 2 * $RecordSize;
887 (($EndTime - $F_first{$x[$[]}) /
888 ($F_last{$x[$[]} - $F_first{$x[$[]})));
890 $c -= $s - 1;
895 $fpos[$[+2] = ($c >=-2) ? 0 : (-$c - 2) * $RecordSize;
910 $c -= $s - 1;
914 $fpos[$[+2] = ($c>-2) ? 0 : (-$c - 2) * $RecordSize;
955 $c -= $s - 1;
959 $fpos[$[+2] = ($c>-2) ? 0 : (-$c - 2) * $RecordSize;
966 print "no starting point yet - using start of data\n"
1022 $t = ($F[$[] - $MJD_1970) * 24 * 60 * 60;
1025 ;# multiply offset by 1000 to get ms - try to avoid float op
1041 push(@break, (defined($lastT) && ($t - $lastT > $deltaT)));
1044 push(@loffset, tell(IN) - length($_));
1084 ;# @time is in ascending order (;-)
1093 $timebase = $time - ((($X[$[+2]*60)+$X[$[+1])*60+$X[$[]);
1106 ;# but I have to proccess two arrays in sync, non-destructively
1110 $lo->sample(($time[$i]-$timebase)/3600,$offs[$i]),$i++
1113 ($minoffs == $maxoffs) && ($minoffs -= 0.1,$maxoffs += 0.1);
1115 $i = $lo->sigma();
1116 $m = $lo->mean();
1120 if (($maxoffs - $minoffs) > $MinClip)
1123 $miny = (($m - $minoffs) <= ($f * $i))
1124 ? $minoffs : ($m - $f * $i);
1126 $maxy = (($maxoffs - $m) <= ($f * $i))
1134 ($maxy-$miny) == 0 &&
1136 = (($maxoffs - $minoffs) > 0)
1137 ? ($maxoffs,$minoffs) : ($MinClip,-$MinClip));
1156 $lf->sample(($time[$i]-$timebase)/3600,$freq[$i]-$minfreq),
1160 $i = $lf->sigma();
1161 $m = $lf->mean() + $minfreq;
1168 ($maxfreq - $minfreq)
1169 ? ($maxy - $miny) / ($maxfreq - $minfreq) : 1;
1179 $FreqScale = 10 ** int(log($s)/log(10) - 0.9999);
1185 $freqbase -= ($maxy + $miny) / 2; #$lf->mean();
1189 $s = -12;
1190 $s = int(log(($maxfreq-$minfreq)*$FreqScale)/log(10))-1
1191 unless ($maxfreq-$minfreq) < 1e-12;
1201 if (($maxfreq - $minfreq) > $MinClip)
1205 $miny = (($freqbase - $minfreq) <= ($f * $i))
1206 ? ($minfreq-$freqbase) : (- $f * $i);
1208 $maxy = (($maxfreq - $freqbase) <= ($f * $i))
1209 ? ($maxfreq-$freqbase) : ($f * $i);
1213 $miny = $minfreq - $freqbase;
1214 $maxy = $maxfreq - $freqbase;
1216 ($maxy - $miny) == 0 &&
1218 (($maxfreq - $minfreq) > 0)
1219 ? ($maxfreq-$freqbase,$minfreq-$freqbase) : (0.5,-0.5));
1224 print("frequency min clipped from ",$minfreq-$freqbase,
1226 if $verbose > 2 && $miny != ($minfreq - $freqbase);
1227 print("frequency max clipped from ",$maxfreq-$freqbase,
1229 if $verbose > 2 && $maxy != ($maxfreq - $freqbase);
1232 sprintf("%g",$freqbase >= 0 ? $freqbase : -$freqbase);
1256 $cmplscale = $cmp == $maxy ? 1 : -1;
1270 $miny = $mincmpl ? 0 : -$MinClip;
1288 ($LastFreqBase >= 0 ? "+" : "-"),
1290 print OUT ("# compliance is scaled by $LastCmplScale\n");
1295 (shift(@time) - $LastTimeBase)/3600,
1297 shift(@freq) * $FreqScale - $LastFreqBase,
1306 $lo->sample(0,1);
1307 $lo->sample(1,1);
1308 $lf->sample(0,2);
1309 $lf->sample(1,2);
1318 $miny = -$MinClip;
1333 else # found to few lines - next time start search earlier in file
1348 $noff = $loffset[$[] - ($cnt - @loffset + 1) * $RecordSize;
1372 $noff = $fpos[$[+2] - $RecordSize * ($cnt - @loffset + 1);
1380 ;# first file - and not enough samples
1398 $noff -= $cnt - @loffset;
1410 return 0 if @loffset <= 1 || ($loffset[$#loffset] - $loffset[$[]) <= 1;
1412 ;# EOF - 1.1 * avg(line) * $cnt
1414 - $cnt * 11 * (($loffset[$#loffset] - $loffset[$[]) / @loffset) / 10;
1419 $Ltime = -1 if ! defined($Ltime);
1435 print PLOT "set output '| lpr -P$PrintIt -h'\n";
1453 my $lo = lr->new();
1454 my $lf = lr->new();
1461 print "command for plot sub process:\n$doplot----\n" if $verbose > 3;
1494 ;# YYYY-MM-DD_HH:MM:SS.ms
1509 if (s/^(\d{4})(-|$)//)
1513 warn("$0: can not handle years before 1970 - year $1 ignored\n");
1518 warn("$0: can not handle years past 2070 - year $1 ignored\n");
1524 ;# - interpreted 70 .. 99,00 .. 69
1533 if (s/^(\d{1,2})(-|$)//)
1537 $mon = $1 - 1;
1645 return $rtime + ($sec - int($sec))
1649 + ($sec - int($sec));