head	1.2;
access;
symbols
	RELENG_3_5_0_RELEASE:1.1.1.1
	RELENG_3_4_0_RELEASE:1.1.1.1
	RELENG_3_3_0_RELEASE:1.1.1.1
	RELENG_3_2_PAO:1.1.1.1.0.14
	RELENG_3_2_PAO_BP:1.1.1.1
	RELENG_3_2_0_RELEASE:1.1.1.1
	RELENG_3_1_0_RELEASE:1.1.1.1
	RELENG_3:1.1.1.1.0.12
	RELENG_3_BP:1.1.1.1
	RELENG_2_2_8_RELEASE:1.1.1.1
	RELENG_3_0_0_RELEASE:1.1.1.1
	RELENG_2_2_7_RELEASE:1.1.1.1
	RELENG_2_2_6_RELEASE:1.1.1.1
	RELENG_2_2_5_RELEASE:1.1.1.1
	RELENG_2_2_2_RELEASE:1.1.1.1
	RELENG_2_2_1_RELEASE:1.1.1.1
	RELENG_2_2_0_RELEASE:1.1.1.1
	RELENG_2_1_7_RELEASE:1.1.1.1
	RELENG_2_1_6_1_RELEASE:1.1.1.1
	RELENG_2_1_6_RELEASE:1.1.1.1
	RELENG_2_2:1.1.1.1.0.10
	RELENG_2_2_BP:1.1.1.1
	RELENG_2_1_5_RELEASE:1.1.1.1
	RELENG_2_1_0_RELEASE:1.1.1.1
	RELENG_2_1_0:1.1.1.1.0.8
	RELENG_2_1_0_BP:1.1.1.1
	RELENG_2_0_5_RELEASE:1.1.1.1
	RELENG_2_0_5:1.1.1.1.0.6
	RELENG_2_0_5_BP:1.1.1.1
	RELENG_2_0_5_ALPHA:1.1.1.1
	RELEASE_2_0:1.1.1.1
	BETA_2_0:1.1.1.1
	ALPHA_2_0:1.1.1.1.0.4
	xntp_3_4e:1.1.1.1
	MOVED_NEWCVS:1.1.1.1
	FINAL_1_1_5:1.1.1.1
	ALPHA_1_1_5:1.1.1.1
	FINAL_1_1:1.1.1.1
	GAMMA_1_1:1.1.1.1
	xntp_3_3s:1.1.1.1
	udel_3_3p:1.1.1.1
	udel:1.1.1
	BETA_1_1:1.1.1.1.0.2
	BP_BETA_1_1:1.1.1.1
	UDEL_33Z:1.1.1.1
	UDEL_33B:1.1.1.1
	UDEL:1.1.1;
locks; strict;
comment	@# @;


1.2
date	99.12.22.15.23.54;	author roberto;	state dead;
branches;
next	1.1;

1.1
date	93.12.21.18.36.35;	author wollman;	state Exp;
branches
	1.1.1.1;
next	;

1.1.1.1
date	93.12.21.18.36.36;	author wollman;	state Exp;
branches;
next	;


desc
@@


1.2
log
@Bye bye xntpd.
@
text
@#!/bin/sh 
#
# ntpgroper host ...
#
# This script checks each hostname given as an argument to see if
# it is running NTP.  It reports one of the following messages (assume
# the host is named "dumbo.hp.com":
#
#   dumbo.hp.com not registered in DNS
#   dumbo.hp.com not responding to ping
#   dumbo.hp.com refused ntpq connection
#   dumbo.hp.com not responding to NTP
#   dumbo.hp.com answers NTP version 2, stratum: 3, ref: telford.nsa.hp.com
#   dumbo.hp.com answers NTP version 3, stratum: 3, ref: telford.nsa.hp.com
#
# It ain't pretty, but it is kinda useful.
#
# Walter Underwood, 11 Feb 1993, wunder@@hpl.hp.com
#
# converted to /bin/sh from /bin/ksh by scott@@ee.udel.edu 24 Mar 1993

PATH="/usr/local/etc:$PATH" export PATH

verbose=1
logfile=/tmp/cntp-log$$
ntpqlog=/tmp/cntp-ntpq$$

# I wrap the whole thing in parens so that it is possible to redirect
# all the output somewhere, if desired.
(
for host in $*
do
    # echo "Trying $host."

    gethost $host > /dev/null 2>&1
    if [ $? -ne 0 ]
    then
        echo "$host not registered in DNS"
        continue
    fi

    ping $host 64 1 > /dev/null 2>&1 
    if [ $? -ne 0 ]
    then
        echo "$host not responding to ping"
	continue
    fi
    
    # Attempt to contact with version 3 ntp, then try version 2.
    for version in 3 2
    do

        ntpq -c "ntpversion $version" -p $host > $ntpqlog 2>&1

        if fgrep -s 'Connection refused' $ntpqlog
        then
            echo "$host refused ntpq connection"
            break
        fi

        responding=1
        fgrep -s 'timed out, nothing received' $ntpqlog > /dev/null && responding=0

        if   [ $responding -eq 1 ]
        then
	    ntpq -c "ntpversion $version" -c rl $host > $ntpqlog

            # First we extract the reference ID (usually a host or a clock)
            synchost=`fgrep "refid=" $ntpqlog`
            #synchost=${synchost##*refid=} # strip off the beginning of the line
            #synchost=${synchost%%,*}      # strip off the end  
	    synchost=`expr "$synchost" : '.*refid=\([^,]*\),.*'`

            # Next, we get the stratum
            stratum=`fgrep "stratum=" $ntpqlog`
            #stratum=${stratum##*stratum=}
            #stratum=${stratum%%,*}
	    stratum=`expr "$stratum" : '.*stratum=\([^,]*\),.*'`

	    echo "$host answers NTP version $version, stratum: $stratum, ref: $synchost"
            break;
        fi

	if [ $version -eq 2 -a $responding -eq 0 ]
        then
            echo "$host not responding to NTP"
        fi
    done
done
)
# ) >> $logfile

if [ -f $ntpqlog ]; then
    rm $ntpqlog
fi
@


1.1
log
@Initial revision
@
text
@@


1.1.1.1
log
@xntpd 3.3b from UDel
@
text
@@
