File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / ntp / scripts / ntp-status
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Tue May 29 12:08:38 2012 UTC (12 years, 7 months ago) by misho
Branches: ntp, MAIN
CVS tags: v4_2_6p5p0, v4_2_6p5, HEAD
ntp 4.2.6p5

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

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>