From 36ef6b4fe2c26f3c03340a31b64e4d329c482adb Mon Sep 17 00:00:00 2001 From: Matt Rude Date: Sat, 7 May 2011 20:24:11 -0500 Subject: still starting out --- scripts/README | 3 + scripts/do-mung-newhost | 16 +++++ scripts/do-newntpstat | 21 ++++++ scripts/do-ntp-rrdstats | 28 ++++++++ scripts/do-xntp | 155 +++++++++++++++++++++++++++++++++++++++++++ scripts/templates/index-head | 28 ++++++++ scripts/templates/index-tail | 3 + scripts/templates/template | 29 ++++++++ 8 files changed, 283 insertions(+) create mode 100644 scripts/README create mode 100755 scripts/do-mung-newhost create mode 100755 scripts/do-newntpstat create mode 100755 scripts/do-ntp-rrdstats create mode 100755 scripts/do-xntp create mode 100644 scripts/templates/index-head create mode 100644 scripts/templates/index-tail create mode 100644 scripts/templates/template (limited to 'scripts') 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 @@ + + Time Server Status + + + + +experimental ntp tech info + +

+NTP Status Page +

+

+Legends (taken from + +http://www.eecis.udel.edu/~mills/ntp/html/ntpq.html): +
+

+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
+
+
+

+ + 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 @@ +

+ + 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 @@ +

+

Host POOL, Daily Status

+

+ +
+ +
+ +
+ +
+ +
+ +
+

Host POOL, Weekly Status

+
+ +
+ +
+ +
+ +
+ +
+ +

-- cgit v1.2.3-59-ga6da