[ale] how to see if a host is up on a network
Jason Boyles
jason at alltel.net
Sat Nov 15 21:29:12 EST 1997
On Sat, 15 Nov 1997, Joe Novosel wrote:
> > I need a way to find out if a host is alive on our network. I've looked at
> > using "ping -c 1 thehost" and it would work fine but my script can't afford to
> > wait 10 seconds for a downed host not to respond. Any suggestions?
> > ------ David Hamm - dhamm at itserve.com --------
> You can change the timeout on ping. If a system is on your network, then
> 1 second should be _more_ than enough time.
> (on Solaris, ping hostname timeout)
If you don't mind using perl you could use Net::ping. It will let
you do the regular ICMP echo, or check for a listener on the TCP echo
port. I use it at work to scan a list of hosts for upness, and send me a
page when their state changes (up or down). You may not want to use the
TCP or UDP methods, as the echo service may make you vulnerable to certain
DoS attacks.
Simple example (from the Net::ping POD pages):
use Net::Ping;
$p = Net::Ping->new();
print "$host is alive.\n" if $p->ping($host);
$p->close();
Obligatory Linux praise:
The simple ping script to which I refer has run continuously for a
year at a time on a lowly 486/50 Linux machine at work, dutifully alpha
paging me every time one of our monitored hosts changes status.
Ave Linus!
----
Jason Boyles <jason at alltel.net>
More information about the Ale
mailing list