xref: /freebsd/contrib/ntp/scripts/stats/summary.sh (revision 0fca6ea1d4eea4c934cfff25ac9ee8ad6fe95583)
1#!/bin/sh
2#
3# Script to summarize ipeerstats, loopstats and clockstats files
4#
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.
8#
9DATE=`date +20%y%m%d`
10S=/usr/local/bin/S
11SIN=S.in
12SOUT=S.out
13LOOP=loop_summary
14PEER=peer_summary
15CLOCK=clock_summary
16
17rm -f $SIN $SOUT
18
19#
20# Summarize loopstats files
21#
22for 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
34		fi
35	fi
36done
37
38#
39# Summarize peerstats files
40#
41for 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
48	fi
49done
50
51#
52# Summarize clockstats files
53#
54for 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
65		fi
66		rm -f $f
67	fi
68done
69
70#
71# Process clockstat files with S and generate PostScript plots
72#
73for 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
82			fi
83		fi
84	done
85done
86if [ -f $SIN ]; then
87	$S BATCH $SIN $SOUT
88fi
89