今天突然想起来想在perl下实现远程主机存活状态的检查,经过查阅资料,写了下面这个小脚本:
#!/usr/bin/perl -w
use Net::Ping;
my @host_array = ('61.143.162.153',
'61.142.161.198');
my $p = Net::Ping->new("icmp");
foreach $host (@host_array)
{
print "$host is ";
print "NOT " unless $p->ping($host, 2);
print "reachable.\n";
sleep(1);
}
$p->close();
阅读(1259) | 评论(0) | 转发(1) |