aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/do-xntp
blob: 0da4e1ed6bce070a00dcfa361174861aa8be5d8c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
#!/bin/sh

RRD_BIN=/usr/bin
RRDPAGE=/var/www/time.mattrude.com/rrd
SCRIPTS=/var/www/time.mattrude.com/scripts
STATUS=/var/www/time.mattrude.com/status

#rsync -a ${RRDPAGE}/twyla.mattrude.com-clients.rrd twyla:${RRDPAGE}/twyla-client.rrd
#rsync -a ${RRDPAGE}/samantha.mattrude.com-clients.rrd samantha:${RRDPAGE}/samantha-client.rrd
${RRD_BIN}/rrdupdate ${RRDPAGE}/kirby.mattrude.com-clients.rrd N:`${SCRIPTS}/do-ntp-client-update`
rsync -a twyla:${RRDPAGE}/twyla-client.rrd ${RRDPAGE}/twyla.mattrude.com-clients.rrd
rsync -a samantha:${RRDPAGE}/samantha-client.rrd ${RRDPAGE}/samantha.mattrude.com-clients.rrd
sleep 1

cd ${RRDPAGE}
if [ ! $? ]; then exit 1; fi

for X in `cat list-of-systems`
do
	sh ${SCRIPTS}/do-ntp-rrdstats ${X}
	if [ ! $? ]; then exit 1; fi

	${RRD_BIN}/rrdtool graph --imgformat=PNG ${STATUS}/${X}/daily-ntp-clients-small.png \
		--width=296 --height=111 --start=-86400 --end=-300 --lower-limit=0 -r \
		--title="${X}" \
		--vertical-label='Active Clients' \
		DEF:a="${RRDPAGE}/${X}-clients.rrd":clients:LAST \
		AREA:a#002A97FF:"" \
		GPRINT:a:LAST:"Now\:%8.2lf %s" \
		GPRINT:a:AVERAGE:"Avg\:%8.2lf %s" \
		GPRINT:a:MAX:"Max\:%8.2lf %s\n" > /dev/null

	${RRD_BIN}/rrdtool graph --imgformat PNG ${STATUS}/${X}/daily-ntp-clients.png \
		--width=650 --height=200 --start=-86400 --end=-300 \
		--title="${X} - Number of Active Clients" \
		--vertical-label='Number of Clients' \
		DEF:a="${RRDPAGE}/${X}-clients.rrd":clients:LAST \
		DEF:b="${RRDPAGE}/${X}-clients.rrd":abusive:LAST \
		AREA:a#002A97FF:"Clients:" \
		GPRINT:a:LAST:"Current\:%8.2lf %s" \
		GPRINT:a:AVERAGE:"Average\:%8.2lf %s" \
		GPRINT:a:MIN:"Minimum\:%8.2lf %s" \
		GPRINT:a:MAX:"Maximum\:%8.2lf %s\n" \
		AREA:b#F51D30FF:"Abusive:" \
		GPRINT:b:LAST:" Current\:%8.2lf %s" \
		GPRINT:b:AVERAGE:"Average\:%8.2lf %s" \
		GPRINT:b:MIN:"Minimum\:%8.2lf %s" \
		GPRINT:b:MAX:"Maximum\:%8.2lf %s\n" > /dev/null

	${RRD_BIN}/rrdtool graph --imgformat PNG ${STATUS}/${X}/weekly-ntp-clients.png \
		--width=650 --height=200 --start=-691200 --end=-300 \
		--title="${X} - Number of Active Clients" \
		--vertical-label='Number of Clients' \
		DEF:a="${RRDPAGE}/${X}-clients.rrd":clients:LAST \
		DEF:b="${RRDPAGE}/${X}-clients.rrd":abusive:LAST \
		AREA:a#002A97FF:"Clients:" \
		GPRINT:a:LAST:"Current\:%8.2lf %s" \
		GPRINT:a:AVERAGE:"Average\:%8.2lf %s" \
		GPRINT:a:MIN:"Minimum\:%8.2lf %s" \
		GPRINT:a:MAX:"Maximum\:%8.2lf %s\n" \
		AREA:b#F51D30FF:"Abusive:" \
		GPRINT:b:LAST:" Current\:%8.2lf %s" \
		GPRINT:b:AVERAGE:"Average\:%8.2lf %s" \
		GPRINT:b:MIN:"Minimum\:%8.2lf %s" \
		GPRINT:b:MAX:"Maximum\:%8.2lf %s\n" > /dev/null

	${RRD_BIN}/rrdtool graph --imgformat PNG ${STATUS}/${X}/monthly-ntp-clients.png \
		--width=650 --height=200 --start=-2629744 --end=-300 \
		--title="${X} - Number of Active Clients" \
		--vertical-label='Number of Clients' \
		DEF:a="${RRDPAGE}/${X}-clients.rrd":clients:LAST \
		DEF:b="${RRDPAGE}/${X}-clients.rrd":abusive:LAST \
		AREA:a#002A97FF:"Clients:" \
		GPRINT:a:LAST:"Current\:%8.2lf %s" \
		GPRINT:a:AVERAGE:"Average\:%8.2lf %s" \
		GPRINT:a:MIN:"Minimum\:%8.2lf %s" \
		GPRINT:a:MAX:"Maximum\:%8.2lf %s\n" \
		AREA:b#F51D30FF:"Abusive:" \
		GPRINT:b:LAST:" Current\:%8.2lf %s" \
		GPRINT:b:AVERAGE:"Average\:%8.2lf %s" \
		GPRINT:b:MIN:"Minimum\:%8.2lf %s" \
		GPRINT:b:MAX:"Maximum\:%8.2lf %s\n" > /dev/null

	${RRD_BIN}/rrdtool graph --imgformat PNG ${STATUS}/${X}/yearly-ntp-clients.png \
		--width=650 --height=200 --start=-31556926 --end=-300 \
		--title="${X} - Number of Active Clients" \
		--vertical-label='Number of Clients' \
		DEF:a="${RRDPAGE}/${X}-clients.rrd":clients:LAST \
		DEF:b="${RRDPAGE}/${X}-clients.rrd":abusive:LAST \
		AREA:a#002A97FF:"Clients:" \
		GPRINT:a:LAST:"Current\:%8.2lf %s" \
		GPRINT:a:AVERAGE:"Average\:%8.2lf %s" \
		GPRINT:a:MIN:"Minimum\:%8.2lf %s" \
		GPRINT:a:MAX:"Maximum\:%8.2lf %s\n" \
		AREA:b#F51D30FF:"Abusive:" \
		GPRINT:b:LAST:" Current\:%8.2lf %s" \
		GPRINT:b:AVERAGE:"Average\:%8.2lf %s" \
		GPRINT:b:MIN:"Minimum\:%8.2lf %s" \
		GPRINT:b:MAX:"Maximum\:%8.2lf %s\n" > /dev/null

	for a in offset sjit cjit wander freq disp jitter
	do
		${RRD_BIN}/rrdtool graph --imgformat PNG ${STATUS}/${X}/daily-ntp-${a}.png \
			--width 650 --height 200 --start -86400 --end=-300 \
			--title "${X} - ${a} - Daily - `date`" \
			--vertical-label "${X}" \
			DEF:a="${RRDPAGE}/${X}.rrd":${a}:LAST \
			AREA:a#002A97FF:"${a}:" \
			GPRINT:a:LAST:" Current\:%8.2lf %s" \
                	GPRINT:a:AVERAGE:"Average\:%8.2lf %s" \
			GPRINT:a:MIN:"Minimum\:%8.2lf %s" \
                	GPRINT:a:MAX:"Maximum\:%8.2lf %s\n" > /dev/null
		
		${RRD_BIN}/rrdtool graph --imgformat PNG ${STATUS}/${X}/weekly-ntp-${a}.png \
			--width 650 --height 200 --start -691200 --end=-300 \
			--title "`TZ=UTC date`" \
			--vertical-label "${X}" \
			DEF:${a}=${RRDPAGE}/${X}.rrd:${a}:LAST \
			CDEF:n${a}=${a},1000,/ \
			AREA:n${a}#002A97FF:"${a}:" \
			GPRINT:n${a}:LAST:"Current\:%le" \
			GPRINT:n${a}:AVERAGE:"Average\:%8.2lf %s" \
			GPRINT:n${a}:MIN:"Minimum\:%8.2lf %s" \
                	GPRINT:n${a}:MAX:"Maximum\:%8.2lf %s\n" > /dev/null
		
		${RRD_BIN}/rrdtool graph --imgformat PNG ${STATUS}/${X}/monthly-ntp-${a}.png \
			--width 650 --height 200 --start -2629744 --end=-300 \
			--title "`TZ=UTC date`" \
			--vertical-label "${X}" \
			DEF:${a}=${RRDPAGE}/${X}.rrd:${a}:LAST \
			CDEF:n${a}=${a},1000,/ \
			AREA:n${a}#002A97FF:"${a}:" \
			GPRINT:n${a}:LAST:"Current\:%le" \
			GPRINT:n${a}:AVERAGE:"Average\:%8.2lf %s" \
			GPRINT:n${a}:MIN:"Minimum\:%8.2lf %s" \
                	GPRINT:n${a}:MAX:"Maximum\:%8.2lf %s\n" > /dev/null
		
		${RRD_BIN}/rrdtool graph --imgformat PNG ${STATUS}/${X}/yearly-ntp-${a}.png \
			--width 650 --height 200 --start -31556926 --end=-300 \
			--title "`TZ=UTC date`" \
			--vertical-label "${X}" \
			DEF:${a}=${RRDPAGE}/${X}.rrd:${a}:LAST \
			CDEF:n${a}=${a},1000,/ \
			AREA:n${a}#002A97FF:"${a}:" \
			GPRINT:n${a}:LAST:"Current\:%le" \
			GPRINT:n${a}:AVERAGE:"Average\:%8.2lf %s" \
			GPRINT:n${a}:MIN:"Minimum\:%8.2lf %s" \
                	GPRINT:n${a}:MAX:"Maximum\:%8.2lf %s\n" > /dev/null
		
	done
done

${RRD_BIN}/rrdtool graph --imgformat=PNG ${STATUS}/all-clients.png \
	--width=296 --height=83 --start=-86400 --end=-300 --lower-limit=0 -r \
	--title='Active Clients on All Servers' \
	--vertical-label='Active Clients' \
	DEF:a="/var/www/time.mattrude.com/rrd/kirby.mattrude.com-clients.rrd":clients:AVERAGE \
	DEF:b="/var/www/time.mattrude.com/rrd/twyla.mattrude.com-clients.rrd":clients:AVERAGE \
	DEF:c="/var/www/time.mattrude.com/rrd/samantha.mattrude.com-clients.rrd":clients:AVERAGE \
	LINE1:a#002A97FF:"Kirby:" \
	GPRINT:a:LAST:"Now\:%6.2lf %s" \
	GPRINT:a:AVERAGE:"Avg\:%6.2lf %s" \
	GPRINT:a:MAX:"Max\:%6.2lf %s\n" \
	LINE1:b#000000FF:"Twyla:" \
	GPRINT:b:LAST:"Now\:%6.2lf %s" \
	GPRINT:b:AVERAGE:"Avg\:%6.2lf %s" \
	GPRINT:b:MAX:"Max\:%6.2lf %s\n" \
	LINE1:c#990000FF:"Saman:" \
	GPRINT:c:LAST:"Now\:%6.2lf %s" \
	GPRINT:c:AVERAGE:"Avg\:%6.2lf %s" \
	GPRINT:c:MAX:"Max\:%6.2lf %s\n" > /dev/null

rm -f /var/www/time.mattrude.com/logs/ntp-stats-samantha.log /var/www/time.mattrude.com/logs/ntp-stats-twyla.log
ssh samantha /home/matt/bin/ntp/ntp_clients_stats > /var/www/time.mattrude.com/logs/ntp-stats-samantha.log
ssh twyla /home/matt/bin/ntp/ntp_clients_stats > /var/www/time.mattrude.com/logs/ntp-stats-twyla.log

rsync -a ${STATUS} twyla:${STATUS}/
rsync -a ${STATUS} samantha:${STATUS}/