[96068] in RedHat Linux List
Re: PING program
daemon@ATHENA.MIT.EDU (Tim Hockin)
Fri Oct 23 12:20:47 1998
From: Tim Hockin <thockin@isunix.it.ilstu.edu>
To: redhat-list@redhat.com
Date: Fri, 23 Oct 1998 11:20:36 -0500 (CDT)
In-Reply-To: <Pine.LNX.3.96.981023120021.6828A-100000@liposome.genebee.msu.su> from "timsoftware@liposome.genebee.msu.su" at Oct 23, 98 12:01:50 pm
Resent-From: redhat-list@redhat.com
Reply-To: redhat-list@redhat.com
> > I can post code, if you really want it, or it can be left as a (simple)
> > excercise for the user. :)
> Do you have that script?
> I made the script that scans all IP adresses in LAN but pinging iss a very
> long process, maybe you can help me how to minimize pinging time?
> Tim
basically, I send them all to the background in small (50 IP's) batches,
sleep some timeout time, and kill any pings that are remaining. I figure
if it doesn't respond in [1,2,3 - you decide] seconds, it is not alive.
here is my basic script
#!/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
sh -c "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.