Menu

#3 agent.pm ping implementation is platform dependent

v1.0_(example)
open
nobody
None
5
2003-07-15
2003-07-15
Anonymous
No

In agent.pm, sub ping(), there is this snippet of code:

my $pingobj = Net::Ping->new( $> ? "udp" : "icmp",
$pings);
if ($pingobj->ping($ip))
{
my @temp = `ping -c $pings $ip`;
chomp $temp[1];
$stat = '1';
push @msg, $temp[1];
}

Now, the first two lines using Net::Ping are fine. But the
next bit of code looks like it's trying to parse some
STDOUT in the form of '<address> is alive' or '<address>
is unreachable', or maybe it's expecting a ping that
provides four lines of ping statistics (as on Windows
platforms).

Well...

Win32: ping does not have a -c option. -i is used to
specify the time-to-live, and -t is used to specify
continuous ping mode.

SunOS 5.8: ping uses -c as a traffic class. If you want
to specify a timeout value, it's ping <addr> <timeout>

OpenBSD 3.2: ping uses -c as a count of packets. -t is
used to specify the time-to-live.

So... in this case, whatever message you're wanting to
put into that array needs to be (more or less) hard-
coded, and not gleaned from a shell command which isn't
implemented the same across platforms. Also, shelling
out is slow, and this scheme will generate two sets of
pings instead of just one.

If you have any questions about this bug report, please
contact me at dpmott@sep.com.

Thanks!

Discussion


Log in to post a comment.