diff options
author | Lorry Tar Creator <lorry-tar-importer@baserock.org> | 2014-12-02 09:01:21 +0000 |
---|---|---|
committer | <> | 2014-12-04 16:11:25 +0000 |
commit | bdab5265fcbf3f472545073a23f8999749a9f2b9 (patch) | |
tree | c6018dd03dea906f8f1fb5f105f05b71a7dc250a /scripts/deprecated/ntp-status | |
download | ntp-dev-4.2.7p482.tar.gz |
Imported from /home/lorry/working-area/delta_ntp/ntp-dev-4.2.7p482.tar.gz.ntp-dev-4.2.7p482
Diffstat (limited to 'scripts/deprecated/ntp-status')
-rwxr-xr-x | scripts/deprecated/ntp-status | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/scripts/deprecated/ntp-status b/scripts/deprecated/ntp-status new file mode 100755 index 0000000..4109124 --- /dev/null +++ b/scripts/deprecated/ntp-status @@ -0,0 +1,45 @@ +#!/bin/sh + +# From: Marc Brett <Marc.Brett@westgeo.com> + +# Here's a quick hack which can give you the stratum, delay, offset +# for any number of ntp servers. + +NTPDATE=/usr/local/bin/ntpdate +NSLOOKUP=/usr/sbin/nslookup +EGREP=/bin/egrep +AWK=/bin/awk +RM=/bin/rm +FILE=/tmp/ntp.$$ + +USAGE="Usage: $0 hostname [hostname ...]" + +if [ $# -le 0 ] +then + echo $USAGE 2>&1 + exit 1 +fi + +trap '$RM -f $FILE; exit' 1 2 3 4 13 15 + +for HOST in $* +do + HOSTNAME=`$NSLOOKUP $HOST | $EGREP "Name:" | $AWK '{print $2}'` + if [ -n "$HOSTNAME" ] + then + $NTPDATE -d $HOST 2>/dev/null | $EGREP '^stratum|^delay|^offset|^originate' > $FILE + STRATUM=`$EGREP '^stratum' $FILE | $AWK '{print $2}'` + OFFSET=`$EGREP '^offset' $FILE | $AWK '{print $2}'` + DELAY=`$EGREP '^delay' $FILE | $AWK '{print $2}'` + TIMESTAMP=`$EGREP '^originate' $FILE | $AWK '{print $4 " " $5 " " $6 " " $7 " " $8}'` + if [ "$STRATUM" -ne 0 ] + then + echo "$HOSTNAME: stratum:$STRATUM delay:$DELAY offset:$OFFSET $TIMESTAMP" + else + echo $HOSTNAME: Not running NTP + fi + fi + +done + +$RM -f $FILE |