/[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

Diff of /lib/PXElator/ping.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 334 by dpavlin, Fri Aug 28 23:30:38 2009 UTC revision 381 by dpavlin, Sun Aug 30 17:24:19 2009 UTC
# Line 7  use Net::Ping; Line 7  use Net::Ping;
7  use Data::Dump qw/dump/;  use Data::Dump qw/dump/;
8  use Time::HiRes;  use Time::HiRes;
9  use client;  use client;
10    use CouchDB;
11    
12  sub host {  sub host {
13          Net::Ping->new->ping( shift, 0.7 );          my $ip = shift;
14            my $status = fping($ip);
15            defined $status->{$ip};
16  }  }
17    
18  sub fping {  sub fping {
# Line 24  sub fping { Line 27  sub fping {
27    
28                  if ( $ret ) {                  if ( $ret ) {
29                          $syn{$host} = $ip;                          $syn{$host} = $ip;
 #                       $status->{dns}->{$ip} = $nslookup_duration * 1000;  
30                  } else {                  } else {
31                          push @{ $status->{address_not_found} }, $host;                          push @{ $status->{address_not_found} }, $host;
32                  }                  }
33          }          }
34    
35          while (my ($host,$rtt,$ip) = $p->ack) {          while (my ($host,$rtt,$ip) = $p->ack) {
                 $status->{$ip}->{rtt} = $rtt * 1000; # ms  
36                  warn "# $host $rtt $ip\n";                  warn "# $host $rtt $ip\n";
37                    $rtt *= 1000; # ms
38                  client::conf( $ip => 'hostname', default => $host ) if $host ne $ip;                  client::conf( $ip => 'hostname', default => $host ) if $host ne $ip;
39                    $status->{$host} = { host => $host, rtt => $rtt, ip => $ip };
40                    CouchDB::audit( $ip, $status->{$host});
41          }          }
42    
43          warn "# fping ",dump($status);          warn "# fping ",dump($status);

Legend:
Removed from v.334  
changed lines
  Added in v.381

  ViewVC Help
Powered by ViewVC 1.1.26