root/lang/perl/App-MadEye/trunk/lib/App/MadEye/Plugin/Agent/Ping.pm @ 7553

Revision 7553, 456 bytes (checked in by tokuhirom, 6 years ago)

bug fixed.

Line 
1package App::MadEye::Plugin::Agent::Ping;
2use strict;
3use warnings;
4use App::MadEye::Plugin::Agent::Base;
5
6use Net::Ping;
7
8sub is_dead {
9    my ($self, $host) = @_;
10
11    my $conf = $self->config->{config};
12    my $timeout = $conf->{timeout} || 5;
13
14    my $p = Net::Ping->new("tcp");
15    $p->hires(1);
16    my ( $ret, ) = $p->ping( $host, $timeout );
17    $p->close;
18
19    if ($ret) {
20        return; # success
21    } else {
22        return "dead";
23    }
24}
25
261;
27
Note: See TracBrowser for help on using the browser.