/[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 330 by dpavlin, Fri Aug 28 22:29:08 2009 UTC revision 381 by dpavlin, Sun Aug 30 17:24:19 2009 UTC
# Line 6  use strict; Line 6  use strict;
6  use Net::Ping;  use Net::Ping;
7  use Data::Dump qw/dump/;  use Data::Dump qw/dump/;
8  use Time::HiRes;  use Time::HiRes;
9    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 23  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) {
36                  $status->{$ip}->{rtt} = $rtt * 1000; # ms                  warn "# $host $rtt $ip\n";
37                    $rtt *= 1000; # ms
38                    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 dump($status);          warn "# fping ",dump($status);
44    
45          return $status;          return $status;
46    

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

  ViewVC Help
Powered by ViewVC 1.1.26