aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorMatt Rude <[email protected]>2011-05-07 20:24:11 -0500
committerMatt Rude <[email protected]>2011-05-07 20:24:11 -0500
commit36ef6b4fe2c26f3c03340a31b64e4d329c482adb (patch)
tree304f8d5e314c84aeb4793590cc67a4bbd5f2be5d /scripts
parentf050e9d654ac9f8c237bcfaa27f84f9341d4179d (diff)
downloadtime.mattrude.com-36ef6b4fe2c26f3c03340a31b64e4d329c482adb.tar.gz
time.mattrude.com-36ef6b4fe2c26f3c03340a31b64e4d329c482adb.tar.bz2
time.mattrude.com-36ef6b4fe2c26f3c03340a31b64e4d329c482adb.zip
still starting out
Diffstat (limited to 'scripts')
-rw-r--r--scripts/README3
-rwxr-xr-xscripts/do-mung-newhost16
-rwxr-xr-xscripts/do-newntpstat21
-rwxr-xr-xscripts/do-ntp-rrdstats28
-rwxr-xr-xscripts/do-xntp155
-rw-r--r--scripts/templates/index-head28
-rw-r--r--scripts/templates/index-tail3
-rw-r--r--scripts/templates/template29
8 files changed, 283 insertions, 0 deletions
diff --git a/scripts/README b/scripts/README
new file mode 100644
index 0000000..2880691
--- /dev/null
+++ b/scripts/README
@@ -0,0 +1,3 @@
+I have written a set of scripts that use "ntpq -c rv" probes to gather statistics from the various servers. I'm using a list-of-systems mode with auto generation of the index.html file. The first script to run is do-newntpstat to create the database. Make sure the database that is created gets moved to the place where the next script can find it. Add your host name(s) to the list-of-systems and run do-mung-newhost to create the index.html file. The script takes template files 1. index-head, 2. template, 3. index-tail and churns out the updated web page. The cron job then runs do-xntp to update the png data images. A further script do-ntp-rrdstats probes the ntp-dev servers and extracts the reqired data it then uses to populate the rrd database.
+
+http://www.wraith.sf.ca.us/ntp/index.html#monitoring
diff --git a/scripts/do-mung-newhost b/scripts/do-mung-newhost
new file mode 100755
index 0000000..b0219b9
--- /dev/null
+++ b/scripts/do-mung-newhost
@@ -0,0 +1,16 @@
+#!/bin/sh
+
+POOLPAGE=/usr/local/www/data/status
+TEMPLATESDIR=/usr/local/www/data/scripts/templates
+
+cd $POOLPAGE
+cat /dev/null > out.template
+
+for X in `cat /usr/local/www/data/rrd/list-of-systems`
+do
+ sed -e s/POOL/$X/g $TEMPLATESDIR/template >> out.template
+done
+
+sync
+cat $TEMPLATESDIR/index-head out.template $TEMPLATESDIR/index-tail > index.html
+rm -f out.template
diff --git a/scripts/do-newntpstat b/scripts/do-newntpstat
new file mode 100755
index 0000000..8f4e1d7
--- /dev/null
+++ b/scripts/do-newntpstat
@@ -0,0 +1,21 @@
+#! /bin/sh
+
+case "$1" in
+ "") echo "Missing system name."; exit 1
+esac
+
+RRD_BIN=/usr/local/bin
+
+# 26 hours and 8 days data bins
+
+${RRD_BIN}/rrdtool create $1.rrd \
+ DS:offset:GAUGE:1200:U:U \
+ DS:sjit:GAUGE:1200:U:U \
+ DS:cjit:GAUGE:1200:U:U \
+ DS:wander:GAUGE:1200:U:U \
+ DS:freq:GAUGE:1200:U:U \
+ DS:disp:GAUGE:1200:U:U \
+ RRA:LAST:0.5:1:312 \
+ RRA:LAST:0.5:12:2304
+
+#end
diff --git a/scripts/do-ntp-rrdstats b/scripts/do-ntp-rrdstats
new file mode 100755
index 0000000..1b3b99b
--- /dev/null
+++ b/scripts/do-ntp-rrdstats
@@ -0,0 +1,28 @@
+#!/bin/sh
+
+case "$1" in
+ "") echo "Missing system name."; exit 1
+esac
+
+/usr/local/bin/ntpq -4 -c rv $1 | awk 'BEGIN{ RS=","}{ print }' >> /tmp/ntp-rrdstats.$$
+
+NOFFSET=`grep offset /tmp/ntp-rrdstats.$$ | awk 'BEGIN{FS="="}{print $2}'`
+NFREQ=`grep frequency /tmp/ntp-rrdstats.$$ | awk 'BEGIN{FS="="}{print $2}'`
+NSJIT=`grep sys_jitter /tmp/ntp-rrdstats.$$ | awk 'BEGIN{FS="="}{print $2}'`
+NCJIT=`grep clk_jitter /tmp/ntp-rrdstats.$$ | awk 'BEGIN{FS="="}{print $2}'`
+NWANDER=`grep clk_wander /tmp/ntp-rrdstats.$$ | awk 'BEGIN{FS="="}{print $2}'`
+NDISPER=`grep rootdisp /tmp/ntp-rrdstats.$$ | awk 'BEGIN{FS="="}{print $2}'`
+
+
+#echo ${NOFFSET} ${NSJIT} ${NCJIT} ${NWANDER} ${NFREQ} ${NDISPER}
+#exit
+
+# keep this in the same order as do-newntpstat creates them, please.
+
+/usr/local/bin/rrdtool update \
+ $1.rrd \
+ N:${NOFFSET}:${NSJIT}:${NCJIT}:${NWANDER}:${NFREQ}:${NDISPER}
+
+rm /tmp/ntp-rrdstats.$$
+
+#end
diff --git a/scripts/do-xntp b/scripts/do-xntp
new file mode 100755
index 0000000..f3ebe99
--- /dev/null
+++ b/scripts/do-xntp
@@ -0,0 +1,155 @@
+#!/bin/sh
+
+RRD_BIN=/usr/local/bin
+RRDPAGE=/usr/local/www/data/rrd
+SCRIPTS=/usr/local/www/data/scripts
+
+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 ${RRDPAGE}/${X}-ntp-offset.png \
+ --width 600 --height 200 \
+ --vertical-label "${X}" \
+ --title "`TZ=UTC date`" \
+ --start -93600 \
+ DEF:offset=${RRDPAGE}/${X}.rrd:offset:LAST \
+ CDEF:noffset=offset,1000,/ \
+ LINE1:noffset#0000FF:"offset" \
+ GPRINT:noffset:LAST:%le
+
+${RRD_BIN}/rrdtool graph \
+ --imgformat PNG ${RRDPAGE}/${X}-ntp-sysjit.png \
+ --width 600 --height 200 \
+ --vertical-label "${X}" \
+ --title "`TZ=UTC date`" \
+ --start -93600 \
+ DEF:sjit=${RRDPAGE}/${X}.rrd:sjit:LAST \
+ CDEF:nsjit=sjit,1000,/ \
+ LINE1:nsjit#0000FF:"sysjit" \
+ GPRINT:nsjit:LAST:%le
+
+${RRD_BIN}/rrdtool graph \
+ --imgformat PNG ${RRDPAGE}/${X}-ntp-clkjit.png \
+ --width 600 --height 200 \
+ --vertical-label "${X}" \
+ --title "`TZ=UTC date`" \
+ --start -93600 \
+ DEF:cjit=${RRDPAGE}/${X}.rrd:cjit:LAST \
+ CDEF:ncjit=cjit,1000,/ \
+ LINE1:ncjit#0000FF:"cjit" \
+ GPRINT:ncjit:LAST:%le
+
+${RRD_BIN}/rrdtool graph \
+ --imgformat PNG ${RRDPAGE}/${X}-ntp-wander.png \
+ --width 600 --height 200 \
+ --vertical-label "${X}" \
+ --title "`TZ=UTC date`" \
+ --start -93600 \
+ DEF:wander=${RRDPAGE}/${X}.rrd:wander:LAST \
+ LINE1:wander#0000FF:"wander" \
+ GPRINT:wander:LAST:%le
+
+${RRD_BIN}/rrdtool graph \
+ --imgformat PNG ${RRDPAGE}/${X}-ntp-freq.png \
+ --width 600 --height 200 \
+ --alt-autoscale \
+ --vertical-label "${X}" \
+ --title "`TZ=UTC date`" \
+ --start -93600 \
+ DEF:freq=${RRDPAGE}/${X}.rrd:freq:LAST \
+ LINE1:freq#0000FF:"frequency (ppm)" \
+ GPRINT:freq:LAST:%lf
+
+${RRD_BIN}/rrdtool graph \
+ --imgformat PNG ${RRDPAGE}/${X}-ntp-disp.png \
+ --width 600 --height 200 \
+ --alt-autoscale \
+ --vertical-label "${X}" \
+ --title "`TZ=UTC date`" \
+ --start -93600 \
+ DEF:disp=${RRDPAGE}/${X}.rrd:disp:LAST \
+ CDEF:ndisp=disp,1000,/ \
+ LINE1:ndisp#0000FF:"dispersion" \
+ GPRINT:ndisp:LAST:%lf
+
+# fat (weekly) graphs
+
+
+${RRD_BIN}/rrdtool graph --imgformat PNG ${RRDPAGE}/${X}-week-ntp-offset.png \
+ --width 600 --height 200 \
+ --vertical-label "${X}" \
+ --title "`TZ=UTC date`" \
+ --start -691200 \
+ DEF:offset=${RRDPAGE}/${X}.rrd:offset:LAST \
+ CDEF:noffset=offset,1000,/ \
+ LINE1:noffset#0000FF:"offset" \
+ GPRINT:noffset:LAST:%le
+
+${RRD_BIN}/rrdtool graph --imgformat PNG ${RRDPAGE}/${X}-week-ntp-sysjit.png \
+ --width 600 --height 200 \
+ --vertical-label "${X}" \
+ --title "`TZ=UTC date`" \
+ --start -691200 \
+ DEF:sjit=${RRDPAGE}/${X}.rrd:sjit:LAST \
+ CDEF:nsjit=sjit,1000,/ \
+ LINE1:nsjit#0000FF:"sysjit" \
+ GPRINT:nsjit:LAST:%le
+
+${RRD_BIN}/rrdtool graph --imgformat PNG ${RRDPAGE}/${X}-week-ntp-clkjit.png \
+ --width 600 --height 200 \
+ --vertical-label "${X}" \
+ --title "`TZ=UTC date`" \
+ --start -691200 \
+ DEF:cjit=${RRDPAGE}/${X}.rrd:cjit:LAST \
+ CDEF:ncjit=cjit,1000,/ \
+ LINE1:ncjit#0000FF:"clkjit" \
+ GPRINT:ncjit:LAST:%le
+
+${RRD_BIN}/rrdtool graph --imgformat PNG ${RRDPAGE}/${X}-week-ntp-wander.png \
+ --width 600 --height 200 \
+ --vertical-label "${X}" \
+ --title "`TZ=UTC date`" \
+ --start -691200 \
+ DEF:wander=${RRDPAGE}/${X}.rrd:wander:LAST \
+ LINE1:wander#0000FF:"wander" \
+ GPRINT:wander:LAST:%le
+
+${RRD_BIN}/rrdtool graph \
+ --imgformat PNG ${RRDPAGE}/${X}-week-ntp-freq.png \
+ --width 600 --height 200 \
+ --alt-autoscale \
+ --vertical-label "${X}" \
+ --title "`TZ=UTC date`" \
+ --start -691200 \
+ DEF:freq=${RRDPAGE}/${X}.rrd:freq:LAST \
+ LINE1:freq#0000FF:"frequency (ppm)" \
+ GPRINT:freq:LAST:%lf
+
+
+${RRD_BIN}/rrdtool graph \
+ --imgformat PNG ${RRDPAGE}/${X}-week-ntp-disp.png \
+ --width 600 --height 200 \
+ --alt-autoscale \
+ --vertical-label "${X}" \
+ --title "`TZ=UTC date`" \
+ --start -691200 \
+ DEF:disp=${RRDPAGE}/${X}.rrd:disp:LAST \
+ CDEF:ndisp=disp,1000,/ \
+ LINE1:ndisp#0000FF:"dispersion" \
+ GPRINT:ndisp:LAST:%lf
+
+done
+
+#end
+
+
diff --git a/scripts/templates/index-head b/scripts/templates/index-head
new file mode 100644
index 0000000..fd2aa33
--- /dev/null
+++ b/scripts/templates/index-head
@@ -0,0 +1,28 @@
+<head>
+ <title>Time Server Status</title>
+ <link rel="stylesheet" type="text/css" href="style.css"/>
+ <link rel="icon" href="favicon.ico" type="image/x-icon" />
+</head>
+<html>
+<title>experimental ntp tech info</title>
+<body>
+<h2>
+NTP Status Page
+</h2>
+<p>
+Legends (taken from
+<a href="http://www.eecis.udel.edu/~mills/ntp/html/ntpq.html">
+http://www.eecis.udel.edu/~mills/ntp/html/ntpq.html</a>):
+<br>
+<pre>
+offset combined time offset
+frequency clock frequency offset (PPM)
+sys_jitter combined system jitter
+clk_jitter clock jitter
+clk_wander clock frequency wander (PPM)
+rootdisp total dispersion to the primary reference clock
+</pre>
+<br>
+<p>
+
+
diff --git a/scripts/templates/index-tail b/scripts/templates/index-tail
new file mode 100644
index 0000000..102f439
--- /dev/null
+++ b/scripts/templates/index-tail
@@ -0,0 +1,3 @@
+<p>
+</body>
+</html>
diff --git a/scripts/templates/template b/scripts/templates/template
new file mode 100644
index 0000000..621f3d6
--- /dev/null
+++ b/scripts/templates/template
@@ -0,0 +1,29 @@
+<p>
+<h2>Host POOL, Daily Status</h2>
+<p>
+<img src="/rrd/POOL-ntp-offset.png">
+<br />
+<img src="/rrd/POOL-ntp-freq.png">
+<br />
+<img src="/rrd/POOL-ntp-sysjit.png">
+<br />
+<img src="/rrd/POOL-ntp-clkjit.png">
+<br />
+<img src="/rrd/POOL-ntp-wander.png">
+<br />
+<img src="/rrd/POOL-ntp-disp.png">
+<br />
+<h2>Host POOL, Weekly Status</h2>
+<br />
+<img src="/rrd/POOL-week-ntp-offset.png">
+<br />
+<img src="/rrd/POOL-week-ntp-freq.png">
+<br />
+<img src="/rrd/POOL-week-ntp-sysjit.png">
+<br />
+<img src="/rrd/POOL-week-ntp-clkjit.png">
+<br />
+<img src="/rrd/POOL-week-ntp-wander.png">
+<br />
+<img src="/rrd/POOL-week-ntp-disp.png">
+</p>