Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Ping sweep with reporting

by shandor (Monk)
on May 14, 2007 at 21:15 UTC ( #615424=note: print w/replies, xml ) Need Help??


in reply to Ping sweep with reporting

Here's a possibility from a Solaris server. Note that by default, ping on Solaris returns "server is alive" when the server can ping. Otherwise, the ping times out after a few seconds.
#!/usr/bin/perl use strict; use warnings; my $ping = "/usr/sbin/ping"; while (<DATA>){ chomp; my $ping_out = `$ping $_ 2> /dev/null`; chomp ($ping_out); if ($ping_out !~ /is alive/){ print "$_ isn't pinging\n"; } } __DATA__ server1 server2 server3
Another possibility is to use the ping -t 1 format on a linux server. If anything shows up in $ping_out, then the server is pingable, otherwise it's not.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://615424]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (5)
As of 2021-06-22 16:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What does the "s" stand for in "perls"? (Whence perls)












    Results (107 votes). Check out past polls.

    Notices?