I have perl script that I use to check and ping a list of ip,
The problem is, I didnt understand how to ping ipv6 on perl,
Could I use Ping::External??And how could I get the ping result (reply or not)?
This is my code
#!/usr/bin/perl --
use Net::Ping;
use Data::Validate::IP;
use Time::HiRes;
$own = qx(perl /opt/probing/cekip.pl);
$ownhost = hostname;
@host = $ARGV[0];
for ( $x = 1 ; $x <= 49 ; $x++ ) {
$time = [Time::HiRes::gettimeofday];
$starttime =
Time::HiRes::tv_interval( $time, [Time::HiRes::gettimeofday] ) * 1000;
$ping = Net::Ping->new("icmp");
$endtime =
Time::HiRes::tv_interval( $time, [Time::HiRes::gettimeofday] ) * 1000;
$waktu = $endtime - $starttime;
$waktu1 = $waktu1 + $waktu;
foreach $host2 (@host) {
if ( is_ipv4($host2) ) {
unless ( $ping->ping($host2) ) {
#print "error:$host", scalar(localtime), "\n";
$lost = $lost + 1;
}
else {
#print "success:$host", scalar(localtime), "\n";
$lost = 0;
$sent = $x;
$receive = $receive + 1;
if ( $waktu > $max1 ) {
$max1 = $waktu;
$max = sprintf( "%.2f", $max1 );
}
if ( $waktu < $min1 ) {
$min1 = $waktu;
$min = sprintf( "%.2f", $min1 );
}
}
}
if ( is_ipv6($host2) ) {
// Still Blank Here..
}
}
Thanks in advance,
Franz