Created
December 23, 2009 08:29
-
-
Save hryk/262399 to your computer and use it in GitHub Desktop.
ping sample with AnyEvent::FastPing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use strict; | |
use warnings; | |
use AnyEvent; | |
use AnyEvent::FastPing; | |
use Data::Dumper; | |
my $done = AnyEvent->condvar; | |
AnyEvent::FastPing::register_cb sub { | |
my $array = shift; | |
my @octets = unpack 'C4', $array->[0]->[0]; | |
print "from : ".join('.', @octets )."\n"; | |
print "time : $array->[0]->[1]\n"; | |
print "-----\n"; | |
}; | |
AnyEvent::FastPing::icmp_ping( | |
[ | |
[v10.16.1.1, v10.16.1.20, .01] | |
], | |
.001, 0x12345678, | |
sub { | |
warn "All ranges pinged.\n"; | |
$done->broadcast; | |
} | |
); | |
$done->wait; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment