2007-11-28 11:35:04 +01:00
|
|
|
|
#!/bin/bash
|
|
|
|
|
#
|
|
|
|
|
# Plugin to monitor clock offset and delay, using ntpdate
|
|
|
|
|
#
|
|
|
|
|
# Parameters understood:
|
|
|
|
|
#
|
|
|
|
|
# config (required)
|
|
|
|
|
#
|
|
|
|
|
# Author: Rune Nordb<64>e Skillingstad <rune.skillingstad@ntnu.no>
|
|
|
|
|
#
|
|
|
|
|
# Magic markers - optional - used by installation scripts and
|
|
|
|
|
# munin-node-configure:
|
|
|
|
|
#
|
|
|
|
|
#%# family=manual
|
|
|
|
|
#%# capabilities=
|
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
NTPDATE="/usr/sbin/ntpdate"
|
|
|
|
|
PEER=$(basename $0 | sed -e 's/^ntpdate_//' -e 's/_/./g')
|
|
|
|
|
|
|
|
|
|
if [ ! -x "$NTPDATE" ]; then
|
|
|
|
|
echo "Can't find ntpdate executable"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if [ "$PEER" = "" ]; then
|
|
|
|
|
echo "Unknown peer"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if [ "$1" = "config" ]; then
|
2010-07-06 10:22:50 +02:00
|
|
|
|
echo "graph_title NTP offset and delay to peer $PEER"
|
2015-08-29 15:15:24 +02:00
|
|
|
|
echo "graph_category time"
|
2007-11-28 11:35:04 +01:00
|
|
|
|
echo "graph_args --base 1000 --vertical-label msec"
|
|
|
|
|
echo "offset.label Offset"
|
|
|
|
|
echo "offset.draw LINE2"
|
|
|
|
|
echo "delay.label Delay"
|
|
|
|
|
echo "delay.draw LINE2"
|
|
|
|
|
exit 0
|
|
|
|
|
fi
|
|
|
|
|
|
2010-07-06 10:22:50 +02:00
|
|
|
|
LANG=en_US
|
2010-06-22 17:25:32 +02:00
|
|
|
|
DATA=($($NTPDATE -q $PEER | awk '/^server.*offset/{gsub(/,/,"");if(dela==0||$8<dela){offs=$6;dela=$8;}}END{print offs*1000,dela*1000;}'))
|
2007-11-28 11:35:04 +01:00
|
|
|
|
|
2010-07-06 10:22:50 +02:00
|
|
|
|
[ -z "$DATA" -o "x$DATA" = "x0" ] && exit 1
|
|
|
|
|
echo "offset.value ${DATA[0]}"
|
|
|
|
|
echo "delay.value ${DATA[1]}"
|
2007-11-28 11:35:04 +01:00
|
|
|
|
|
|
|
|
|
exit 0
|
|
|
|
|
|