#!/bin/sh # This script is public domain, there is no copyright on it. # - Wayne Schlitt # figure out our IP address our_dom=`ntpq -c host | sed 's/current host is //'` if [ "$our_dom" = "localhost" -o "$our_dom" = "127.0.0.1" ] then our_dom=`dnsdomainname` fi our_ip=`dig $our_dom +short` pool_ns=`dig pool.ntp.org ns +short | sed "s/\.$//" | sort` num_pool_ns=`echo "$pool_ns" | wc -l` if [ $num_pool_ns -lt 3 ] then echo "Error: could not get a complete list of pool name servers" echo "found: $pool_ns" exit 1 fi ns_refs="" ns_count=0 for ns in $pool_ns do ip=`dig pool.ntp.org @$ns a +short | grep "^$our_ip$"` if [ -n "$ip" ] then ns_refs="$ns_refs $ns" ns_count=`expr $ns_count + 1` fi done tstamp=`date "+%D %T"` if [ "X$1" = "X-startfile" ] then if [ -f $2 ] then stats=`/usr/local/sbin/ntp_clients_stats -startfile $2 | head -2 | \ sed "s/.*: */ /" | tr '\n' ' '` else echo "$2 does not exist" 1>&2 exit 1 fi else stats=`/usr/local/sbin/ntp_clients_stats | head -2 | \ sed "s/.*: */ /" | tr '\n' ' '` fi echo "$tstamp $stats $ns_count $ns_refs"