Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Determne all hosts on my intranet

Status
Not open for further replies.

MoshiachNow

IS-IT--Management
Feb 6, 2002
1,851
IL
HI,

How will I determine all active hosts on my network ?
Using "rup" shows some,but does not seem to show all,and hangs for very long time.

"Long live king Moshiach !"
 
for example with a littel script?

i=1
network=your.network.number # e.g 192.168.1
while [ $i -lt 255 ]
do
ping -c 2 $network.$i
if [ $? -eq 0 ]
then echo "here comes whatever you want e.g. logging
fi
i=$((i++1))
done

Hope that helps

mad_murdock
 
use

ping -q -c 2 $network.$i | head -1

for more readable output

--
| Mike Nixon
| Unix Admin
|
----------------------------
 
forget above.

Try

i=1

network=192.168.25

while [ $i -lt 255 ]
do
ping -c 2 $network.$i > /dev/null
if [ $? -eq 0 ]
then
echo "$network.$i Host found"
fi

i=$((i++1))

done



--
| Mike Nixon
| Unix Admin
|
----------------------------
 

If you run 'rwhod' on all the hosts, the command 'ruptime' will list them all with uptime, # of users, load, etc.

Cheers

Henrik Morsing
Certified AIX 4.3 Systems Administration
& p690 Technical Support
 
@mrn: Wow, incredible, and what exactly is the difference to my script???

mad_murdock
 
The ping is ok,however if most of the hosts are down,the timeout for the ping is very long,in total.

Is there any way to timeout the ping after 1 second or use command other then ping to sense the host status ?

"Long live king Moshiach !"
 
Hi levw

You can goahead with mrn script...the ping time out (in the event of host down)...
There is no other substitute for this...There are certain utilities ....as you said one sec timeout period ...is not feasible...

I can suggest the command which works like ping is
traceroute....If u want ...u can replace the
ping -c 2 with traceroute -m 2 in MRN script...

This will take 20-24 sec to time out...I won't say this is better than ping command in this perspective...As time out
is concerned both will behave in the same way...

sushveer
IBM certified specialist-p-series AIX5L System Administration
AIX/SOLARIS/WEBSPHERE-MQ/TIVOLI Administrator
 
Thanks to all.
Now - how can I determine if I'm dealing with PC/AIX/router ,without hanging again for a long timeout ?

"Long live king Moshiach !"
 
Hi Levw

This is my last contribution.I checked the timeout periods
of ping utility and traceroute utility..I have new findings and want to share with you and unix group.

I concluded traceroute is better than ping as time out is concerned (while node is down)

You can try and test your self by following procedure:

method1: using traceroute utility
#time traceroute -m 2 hostname
You can see time out is 6 sec (node down scenerio)
you can see time out is 2 sec (node up scenerio)

method2:using ping utility
#time ping -c 1 hostname
you can see time out is 10sec (node down scenerio)
also you can find time out is 2 sec (node up scenerio)

If u have all nodes up in your network ...both utilities wil
behave in the same way.But in the event of node down...traceroute consumes less time so it is superior...

This is my practical experience.The time out also depend on network interfaces bandwidth and speeds...
Just try by your self...
That's it!

sushveer
IBM certified specialist-p-series AIX5L System Administration
AIX/SOLARIS/WEBSPHERE-MQ/TIVOLI Administrator
 
Thanks,

What i have eventually done is running the rsh in background and killing it after 2 seconds if still alive,thus assuming the host is non responsive:

rsh $network.$I.$N –l sciroot lslpp –l |grep Output &
sleep 2
if ps –ef |grep rsh >/dev/null ;then
kill `ps –ef |grep rsh |grep –v grep|awk ‘{ print $2 }’`
else
<do something>


&quot;Long live king Moshiach !&quot;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top