Phoenix.pm: Net::Ping Object

Frooninckx Craig - cfroon Craig.Frooninckx at acxiom.com
Tue Feb 5 11:36:27 CST 2002


I've written a small application that is suppose to go out and ping a server
to verify that the network is still active between the local server and the
remote server.  When I do a command line ping it works fine, however, when I
use the Net::Ping object, it reports that it is unable to access the remote
server (in the code the remote server is actually the localserver).  Can
anyone see the bug??

-Craig


SOURCE CODE:
#!/usr/bin/perl -w

# Application to check the availibility of production servers every hour.

use strict;

use Net::Ping;
use Date::Format;

while () {
        my $p = Net::Ping->new() or die "Can't create ping: $!\n";
        my $time = time2str( "%X", time );
        print "\nTime: $time\n";
        my $host = "127.0.0.1";
        print "Ping: ", $p->ping( $host ), "\n";
        print "$host is responding!\n" if $p->ping( $host );
        $p->close;
        sleep 60;
};

__END__

RESULTS:
cfroon at gsgatlas: /usr/users/cfroon/Perl => ping.pl      

Time: 10:32:20
Ping: 0
cfroon at gsgatlas: /usr/users/cfroon/Perl => ping 127.0.0.1
PING 127.0.0.1 (127.0.0.1): 56 data bytes
64 bytes from 127.0.0.1: icmp_seq=0 ttl=64 time=0 ms
64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0 ms
64 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=0 ms


----127.0.0.1 PING Statistics----
3 packets transmitted, 3 packets received, 0% packet loss
round-trip (ms)  min/avg/max = 0/0/0 ms


********************************************************************

The information contained in this communication is
confidential, is intended only for the use of the recipient
named above, and may be legally privileged.
If the reader of this message is not the intended
recipient, you are hereby notified that any dissemination, 
distribution, or copying of this communication is strictly
prohibited.
If you have received this communication in error,
please re-send this communication to the sender and
delete the original message or any copy of it from your
computer system. Thank You.




More information about the Phoenix-pm mailing list