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...
Joshua Goodall
joshua at roughtrade.net
Mon Jun 13 11:09:40 GMT 2005
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
-------------- next part --------------
#!/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
More information about the cvs-src
mailing list