Phoenix.pm: Net::Ping Object

Frooninckx Craig - cfroon Craig.Frooninckx at acxiom.com
Tue Feb 5 16:14:58 CST 2002


I thought of that as well and tried it with 5, which is what the
documentation says is the default if you don't put anything in for timeout
(second argument on the new method or the ping method).

-----Original Message-----
From: Bill Nash [mailto:billn at billn.net]
Sent: Tuesday, February 05, 2002 12:34 AM
To: 'phoenix-pm-list at happyfunball.pm.org'
Subject: Re: Phoenix.pm: Net::Ping Object



If memory serves correctly (I'm a few years out from having used
Net::Ping), it looks like you're missing the timeout value, which, if
undefined, could result in the package reporting the host unreachable
because the response time is > 0.

- billn

On Tue, 5 Feb 2002, Frooninckx Craig - cfroon wrote:

> 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