[96070] in RedHat Linux List

home help back first fref pref prev next nref lref last post

PING Program

daemon@ATHENA.MIT.EDU (Tim Hockin)
Fri Oct 23 12:32:29 1998

From: Tim Hockin <thockin@isunix.it.ilstu.edu>
To: redhat-list@redhat.com
Date: Fri, 23 Oct 1998 11:31:58 -0500 (CDT)
Resent-From: redhat-list@redhat.com
Reply-To: redhat-list@redhat.com


eek, that ping script I sent was rather old.  everyone who loked at it.  it
can be made significantly more efficient .  here is the revision:


Tim

#!/bin/sh
# pingit
# by Tim Hockin <thockin@ais.net>
# 1997

# time to wait for a response
SLEEP=1

#ping a whole class C - easily modified for a smaller range
if [ foo$1 = foo ]; then
	echo "USAGE: $0 -  <ipnetwork>"
	echo "   eg: $0 192.168.1 "
	exit
else
	IP=$1
fi

I=1	
S=55

while [ $I -lt 255 ]; do
   while [ $I -lt $S ]; do
	(ping -c1 $IP.$I > /dev/null 2>&1 && echo $IP.$I    is up &)
	I=$((I+1))
   done

   # give memory a break...
   sleep $SLEEP 

   # if it hasn't answered by now, it is probably not alive..
   killall ping > /dev/null 2>&1

   # increment our upper bound
   S=$((S+50))
done


-- 
  PLEASE read the Red Hat FAQ, Tips, Errata and the MAILING LIST ARCHIVES!
		http://www.redhat.com http://archive.redhat.com
         To unsubscribe: mail redhat-list-request@redhat.com with 
                       "unsubscribe" as the Subject.


home help back first fref pref prev next nref lref last post