Expand PMF_FN_* macros.
[netbsd-mini2440.git] / dist / ntp / scripts / stats / summary.sh
blobdffdb0b1569f8b00b28dbacd16d8822536490b81
1 #!/bin/sh
3 # Script to summarize ipeerstats, loopstats and clockstats files
5 # This script can be run from a cron job once per day, week or month. It
6 # runs the file-specific summary script and appends the summary data to
7 # designated files.
9 DATE=`date +20%y%m%d`
10 S=/usr/local/bin/S
11 SIN=S.in
12 SOUT=S.out
13 LOOP=loop_summary
14 PEER=peer_summary
15 CLOCK=clock_summary
17 rm -f $SIN $SOUT
20 # Summarize loopstats files
22 for f in loopstats.[12][0-9][0-9][0-9][0-1][0-9][0-3][0-9]; do
23 d=`echo $f | cut -f2 -d.`
24 if [ -f $f ] && [ $DATE != $d ]; then
25 echo " " >>$LOOP
26 echo $f >>$LOOP
27 awk -f loop.awk $f >>$LOOP
28 if [ -f $S ]; then
29 echo "file1<-"\"${f}\" >>$SIN
30 echo "source("\""loop.S"\"")" >>$SIN
31 echo "unix("\""rm ${f}"\"")" >>$SIN
32 else
33 rm -f $f
36 done
39 # Summarize peerstats files
41 for f in peerstats.199[4-9][0-1][0-9][0-3][0-9]; do
42 d=`echo $f | cut -f2 -d.`
43 if [ -f $f ] && [ $DATE != $d ]; then
44 echo " " >>$PEER
45 echo $f >>$PEER
46 awk -f peer.awk $f >>$PEER
47 rm -f $f
49 done
52 # Summarize clockstats files
54 for f in clockstats.199[4-9][0-1][0-9][0-3][0-9]; do
55 d=`echo $f | cut -f2 -d.`
56 if [ -f $f ] && [ $DATE != $d ]; then
57 echo " " >>$CLOCK
58 echo $f >>$CLOCK
59 awk -f clock.awk $f >>$CLOCK
60 if [ -f /dev/gps[0-9] ]; then
61 awk -f itf.awk $f >itf.$d
62 awk -f etf.awk $f >etf.$d
63 awk -f ensemble.awk $f >ensemble.$d
64 awk -f tdata.awk $f >tdata.$d
66 rm -f $f
68 done
71 # Process clockstat files with S and generate PostScript plots
73 for f in itf etf ensemble tdata; do
74 for d in ${f}.199[4-9][0-1][0-9][0-3][0-9]; do
75 if [ -f $d ]; then
76 if [ -f $S ]; then
77 echo "file1<-"\"${d}\" >>$SIN
78 echo "source("\"${f}.S\"")" >>$SIN
79 echo "unix("\""rm ${d}"\"")" >>$SIN
80 else
81 rm -f $d
84 done
85 done
86 if [ -f $SIN ]; then
87 $S BATCH $SIN $SOUT