Date: Mon, 13 Jun 2005 21:09:37 +1000 From: Joshua Goodall <joshua@roughtrade.net> To: Ollivier Robert <roberto@FreeBSD.org> Cc: cvs-src@FreeBSD.org, src-committers@FreeBSD.org, cvs-all@FreeBSD.org Subject: Re: cvs commit: src/usr.sbin/ntp Makefile config.h src/usr.sbin/ntp/arlib Makefile src/usr.sbin/ntp/doc Makefile ntp-genkeys.8 src/usr.sbin/ntp/libntp Makefile... Message-ID: <20050613110937.GA29004@roughtrade.net> In-Reply-To: <200407201544.i6KFiWWr001296@repoman.freebsd.org> References: <200407201544.i6KFiWWr001296@repoman.freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
--wRRV7LY7NUeQGEoC Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Bit tardy, but ... On Tue, Jul 20, 2004 at 03:44:32PM +0000, Ollivier Robert wrote: > roberto 2004-07-20 15:44:32 UTC > > FreeBSD src repository > > Modified files: > usr.sbin/ntp Makefile config.h > usr.sbin/ntp/doc Makefile > usr.sbin/ntp/libntp Makefile > usr.sbin/ntp/ntpd Makefile > usr.sbin/ntp/ntpdate Makefile > usr.sbin/ntp/ntpdc Makefile > usr.sbin/ntp/ntpq Makefile > usr.sbin/ntp/ntptrace Makefile nitpick: ntptrace should be #!/usr/bin/perl not #!/usr/local/bin/perl or not be a perl script at all! Like the alternative attached. (NB doesn't do reverse lookups unless someone commits bin/79903) thanks Joshua --wRRV7LY7NUeQGEoC Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=ntptrace #!/bin/sh # usage: ntptrace [-n] [-t timeout] [server] NTPQ=/usr/bin/ntpq GETENT=/usr/sbin/getent BC=/usr/bin/bc TR=/usr/bin/tr dodns=yes timeout=2 lookup() { if [ -z "$dodns" -o ! -x $GETENT ]; then echo $1 return 0 fi $GETENT hosts "$1" | { read addr name aliases if [ ! -z "$name" ]; then echo $name else echo $1 fi } } while getopts "vdnr:t:" option do case $option in n) dodns= ;; t) timeout="${OPTARG}" ;; r|d|v) # ignored, allowed for compatibility ;; *) echo "usage: `basename $0` [-n] [-t timeout] [server]" exit 2 ;; esac done >&2 shift $((OPTIND - 1)) server=${1:-localhost} timeout=$((timeout * 1000)) while true; do stratum=255 qry=`$NTPQ -n -c "timeout ${timeout}" -c rv "${server}" | $TR , '\n'` for i in $qry; do case "$i" in stratum=*) stratum=`echo $i | cut -d= -f2` ;; peer=*) peer=`echo $i | cut -d= -f2` ;; offset=*|phase=*) offset=`echo $i | cut -d= -f2` ;; rootdelay=*) rootdelay=`echo $i | cut -d= -f2` ;; refid=*) refid=`echo $i | cut -d= -f2` ;; *) ;; esac done [ "$stratum" = "255" ] && exit offset=`echo "$offset" / 1000 | $BC -l` rootdelay=`echo "$rootdelay" / 1000 | $BC -l` printf "%s: stratum %d, offset %f, root distance %f" \ "`lookup $server`" "${stratum}" "${offset}" "${rootdelay}" [ "$stratum" = "1" ] && printf ", refid '%s'" "${refid}" echo "" [ "$stratum" = "0" -o "$stratum" = "1" -o "$stratum" = "16" ] && exit case "$refid" in 127.127.*) exit ;; *) ;; esac next="" qry=`$NTPQ -n -c "timeout ${timeout}" -c "pstat ${peer}" "${server}" | $TR , '\n'` for i in $qry; do case "$i" in srcadr=*) next=`echo $i | cut -d= -f2` ;; *) ;; esac done [ -z "$next" ] && exit server=$next done --wRRV7LY7NUeQGEoC--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20050613110937.GA29004>