/[pxelator]/lib/PXElator/ping.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /lib/PXElator/ping.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 330 - (show annotations)
Fri Aug 28 22:29:08 2009 UTC (14 years, 8 months ago) by dpavlin
File size: 616 byte(s)
added fping to all hosts
1 package ping;
2
3 use warnings;
4 use strict;
5
6 use Net::Ping;
7 use Data::Dump qw/dump/;
8 use Time::HiRes;
9
10 sub host {
11 Net::Ping->new->ping( shift, 0.7 );
12 }
13
14 sub fping {
15 my $p = Net::Ping->new('syn', 0.3);
16 $p->hires;
17
18 my $status;
19 my %syn;
20
21 foreach my $host ( @_ ) {
22 my ($ret,$nslookup_duration,$ip) = $p->ping($host);
23
24 if ( $ret ) {
25 $syn{$host} = $ip;
26 # $status->{dns}->{$ip} = $nslookup_duration * 1000;
27 } else {
28 push @{ $status->{address_not_found} }, $host;
29 }
30 }
31
32 while (my ($host,$rtt,$ip) = $p->ack) {
33 $status->{$ip}->{rtt} = $rtt * 1000; # ms
34 }
35
36 warn dump($status);
37
38 return $status;
39
40 }
41
42 1;

  ViewVC Help
Powered by ViewVC 1.1.26