1 1.1 christos #!/bin/sh 2 1.1 christos 3 1.1 christos # From: Marc Brett <Marc.Brett (at] westgeo.com> 4 1.1 christos 5 1.1 christos # Here's a quick hack which can give you the stratum, delay, offset 6 1.1 christos # for any number of ntp servers. 7 1.1 christos 8 1.1 christos NTPDATE=/usr/local/bin/ntpdate 9 1.1 christos NSLOOKUP=/usr/sbin/nslookup 10 1.1 christos EGREP=/bin/egrep 11 1.1 christos AWK=/bin/awk 12 1.1 christos RM=/bin/rm 13 1.1 christos FILE=/tmp/ntp.$$ 14 1.1 christos 15 1.1 christos USAGE="Usage: $0 hostname [hostname ...]" 16 1.1 christos 17 1.1 christos if [ $# -le 0 ] 18 1.1 christos then 19 1.1 christos echo $USAGE 2>&1 20 1.1 christos exit 1 21 1.1 christos fi 22 1.1 christos 23 1.1 christos trap '$RM -f $FILE; exit' 1 2 3 4 13 15 24 1.1 christos 25 1.1 christos for HOST in $* 26 1.1 christos do 27 1.1 christos HOSTNAME=`$NSLOOKUP $HOST | $EGREP "Name:" | $AWK '{print $2}'` 28 1.1 christos if [ -n "$HOSTNAME" ] 29 1.1 christos then 30 1.1 christos $NTPDATE -d $HOST 2>/dev/null | $EGREP '^stratum|^delay|^offset|^originate' > $FILE 31 1.1 christos STRATUM=`$EGREP '^stratum' $FILE | $AWK '{print $2}'` 32 1.1 christos OFFSET=`$EGREP '^offset' $FILE | $AWK '{print $2}'` 33 1.1 christos DELAY=`$EGREP '^delay' $FILE | $AWK '{print $2}'` 34 1.1 christos TIMESTAMP=`$EGREP '^originate' $FILE | $AWK '{print $4 " " $5 " " $6 " " $7 " " $8}'` 35 1.1 christos if [ "$STRATUM" -ne 0 ] 36 1.1 christos then 37 1.1 christos echo "$HOSTNAME: stratum:$STRATUM delay:$DELAY offset:$OFFSET $TIMESTAMP" 38 1.1 christos else 39 1.1 christos echo $HOSTNAME: Not running NTP 40 1.1 christos fi 41 1.1 christos fi 42 1.1 christos 43 1.1 christos done 44 1.1 christos 45 1.1 christos $RM -f $FILE 46