xref: /freebsd/contrib/ntp/scripts/stats/summary.sh (revision 224ba2bd37e182b64f7d78defef8a6cacaad3415)
1c0b746e5SOllivier Robert#!/bin/sh
2c0b746e5SOllivier Robert#
3c0b746e5SOllivier Robert# Script to summarize ipeerstats, loopstats and clockstats files
4c0b746e5SOllivier Robert#
5c0b746e5SOllivier Robert# This script can be run from a cron job once per day, week or month. It
6c0b746e5SOllivier Robert# runs the file-specific summary script and appends the summary data to
7c0b746e5SOllivier Robert# designated files.
8c0b746e5SOllivier Robert#
9224ba2bdSOllivier RobertDATE=`date +20%y%m%d`
10c0b746e5SOllivier RobertS=/usr/local/bin/S
11c0b746e5SOllivier RobertSIN=S.in
12c0b746e5SOllivier RobertSOUT=S.out
13c0b746e5SOllivier RobertLOOP=loop_summary
14c0b746e5SOllivier RobertPEER=peer_summary
15c0b746e5SOllivier RobertCLOCK=clock_summary
16c0b746e5SOllivier Robert
17c0b746e5SOllivier Robertrm -f $SIN $SOUT
18c0b746e5SOllivier Robert
19c0b746e5SOllivier Robert#
20c0b746e5SOllivier Robert# Summarize loopstats files
21c0b746e5SOllivier Robert#
22c0b746e5SOllivier Robertfor f in loopstats.[12][0-9][0-9][0-9][0-1][0-9][0-3][0-9]; do
23c0b746e5SOllivier Robert	d=`echo $f | cut -f2 -d.`
24c0b746e5SOllivier Robert	if [ -f $f ] && [ $DATE != $d ]; then
25c0b746e5SOllivier Robert		echo " " >>$LOOP
26c0b746e5SOllivier Robert		echo $f >>$LOOP
27c0b746e5SOllivier Robert		awk -f loop.awk $f >>$LOOP
28c0b746e5SOllivier Robert		if [ -f $S ]; then
29c0b746e5SOllivier Robert			echo "file1<-"\"${f}\" >>$SIN
30c0b746e5SOllivier Robert			echo "source("\""loop.S"\"")" >>$SIN
31c0b746e5SOllivier Robert			echo "unix("\""rm ${f}"\"")" >>$SIN
32c0b746e5SOllivier Robert		else
33c0b746e5SOllivier Robert			rm -f $f
34c0b746e5SOllivier Robert		fi
35c0b746e5SOllivier Robert	fi
36c0b746e5SOllivier Robertdone
37c0b746e5SOllivier Robert
38c0b746e5SOllivier Robert#
39c0b746e5SOllivier Robert# Summarize peerstats files
40c0b746e5SOllivier Robert#
41c0b746e5SOllivier Robertfor f in peerstats.199[4-9][0-1][0-9][0-3][0-9]; do
42c0b746e5SOllivier Robert	d=`echo $f | cut -f2 -d.`
43c0b746e5SOllivier Robert	if [ -f $f ] && [ $DATE != $d ]; then
44c0b746e5SOllivier Robert		echo " " >>$PEER
45c0b746e5SOllivier Robert		echo $f >>$PEER
46c0b746e5SOllivier Robert		awk -f peer.awk $f >>$PEER
47c0b746e5SOllivier Robert		rm -f $f
48c0b746e5SOllivier Robert	fi
49c0b746e5SOllivier Robertdone
50c0b746e5SOllivier Robert
51c0b746e5SOllivier Robert#
52c0b746e5SOllivier Robert# Summarize clockstats files
53c0b746e5SOllivier Robert#
54c0b746e5SOllivier Robertfor f in clockstats.199[4-9][0-1][0-9][0-3][0-9]; do
55c0b746e5SOllivier Robert	d=`echo $f | cut -f2 -d.`
56c0b746e5SOllivier Robert	if [ -f $f ] && [ $DATE != $d ]; then
57c0b746e5SOllivier Robert		echo " " >>$CLOCK
58c0b746e5SOllivier Robert		echo $f >>$CLOCK
59c0b746e5SOllivier Robert		awk -f clock.awk $f >>$CLOCK
60c0b746e5SOllivier Robert		if [ -f /dev/gps[0-9] ]; then
61c0b746e5SOllivier Robert			awk -f itf.awk $f >itf.$d
62c0b746e5SOllivier Robert			awk -f etf.awk $f >etf.$d
63c0b746e5SOllivier Robert			awk -f ensemble.awk $f >ensemble.$d
64c0b746e5SOllivier Robert			awk -f tdata.awk $f >tdata.$d
65c0b746e5SOllivier Robert		fi
66c0b746e5SOllivier Robert		rm -f $f
67c0b746e5SOllivier Robert	fi
68c0b746e5SOllivier Robertdone
69c0b746e5SOllivier Robert
70c0b746e5SOllivier Robert#
71c0b746e5SOllivier Robert# Process clockstat files with S and generate PostScript plots
72c0b746e5SOllivier Robert#
73c0b746e5SOllivier Robertfor f in itf etf ensemble tdata; do
74c0b746e5SOllivier Robert	for d in ${f}.199[4-9][0-1][0-9][0-3][0-9]; do
75c0b746e5SOllivier Robert		if [ -f $d ]; then
76c0b746e5SOllivier Robert			if [ -f $S ]; then
77c0b746e5SOllivier Robert				echo "file1<-"\"${d}\" >>$SIN
78c0b746e5SOllivier Robert				echo "source("\"${f}.S\"")" >>$SIN
79c0b746e5SOllivier Robert				echo "unix("\""rm ${d}"\"")" >>$SIN
80c0b746e5SOllivier Robert			else
81c0b746e5SOllivier Robert				rm -f $d
82c0b746e5SOllivier Robert			fi
83c0b746e5SOllivier Robert		fi
84c0b746e5SOllivier Robert	done
85c0b746e5SOllivier Robertdone
86c0b746e5SOllivier Robertif [ -f $SIN ]; then
87c0b746e5SOllivier Robert	$S BATCH $SIN $SOUT
88c0b746e5SOllivier Robertfi
89