CC: | "bug-Net-Ping [...] rt.cpan.org" <bug-Net-Ping [...] rt.cpan.org>, Geoff Collis <gcollis [...] yahoo-inc.com> |
Subject: | FW: Net::Ping tcp check error? |
Date: | Wed, 28 Nov 2012 12:07:39 +0000 |
To: | Rob Brown <bbb [...] cpan.org> |
From: | Geoff Collis <gcollis [...] yahoo-inc.com> |
Umm Exchange does not like the recipient name; apologies for writing directly to you Rob.
From: Geoff Collis
Sent: Wednesday, November 28, 2012 12:54
To: bug-Net-Ping@rt.cpan.org.
Cc: Geoff Collis
Subject: Net::Ping tcp check error?
Dear Sir/Madam
I have been struggling to get "tcp" check to work on RHEL5 and Win7
RHEL5: v5.8.8 built for i386-linux-thread-multi
Win7: ActivePerl 5.14.2 Build 1402 (64-bit); Net::Ping 2.36
Pseudo-code snippet explaining the issue, "port_number" method does not appear to work, the ping check always fails.
#my $port_name = "ssh";
#my $port_number = 22;
my $port_name = "ftp";
my $port_number = 21;
# tcp protocol
$ping = Net::Ping->new( "tcp", 2 );
# tcp port to check
# $ping->port_number(getservbyname($port_number, "tcp")); # DOES NOT WORK
# $ping->port_number(getservbyname($port_number, "tcp") || $port_number); # DOES NOT WORK
# Following hack (accessing the structure directly) fixes the issue
$ping->{'port_num'} = ( getservbyname( $port_name, "tcp" ) || $port_number );
$ping->service_check(1);
if ( $ping->ping($host) ) {
print "$host is alive on tcp port($port_name)", "\n";
}
else {
print "$host is not responding on tcp port($port_name)", "\n";
}
Ping.pm - do you not need to quote the "port_num" argument?
sub port_number {
my $self = shift;
if(@_) {
$self->{port_num} = shift @_;
$self->service_check(1);
}
return $self->{port_num};
}
geoff
collis
infrastructure performance & capacity planning
gcollis@yahoo-inc.com<mailto:gcollis@yahoo-inc.com>
direct +41 (21) 8315303 mobile +41 (79) 5580528
route de gilly 30 , rolle, 1180, ch
phone (408) 349 3300 fax (408) 349 3301
[http://forgood.zenfs.com/logos/yahoo.gif]
Yahoo! Sàrl is a limited company registered in Switzerland. Registered number: CH-550-1051940-9. Registered office as above. This message may contain information that is privileged and confidential.
Any unauthorized disclosure, use or dissemination, either whole or partial, is prohibited. If you are not the intended recipient of the message, please notify the sender immediately.