ko

来源:互联网 发布:生死狙击刷枪刷枪软件 编辑:程序博客网 时间:2024/04/30 12:45

 

use strict;

use warnings;

use Net::Ping;

 

my @host_array = qw(127.0.0.1);

 

my $last_isOk = 1; #上次的测试结果

my $curr_isOk = 1; #最终测试结果

my $normalT = 5; #正常情况下测试间隔

my $failedT = 1;

my $is_runing = 0;

 

while (1) {

    $last_isOk = $curr_isOk;

    

foreach my $host (@host_array)

{

$curr_isOk = (&test_site($host)) ? 1 : 0; 

last if $curr_isOk; #如果有成功,则不继续测

}

 

#本地网络有问题

unless ($curr_isOk) {

if (1 == $last_isOk) {#上次成功,本次失败,需要修改失败锁

&setLock(0);

#写日志#---待完善

}

}

elsif(0 == $last_isOk) { #上次失败,本次成功,需要修改失败锁

&setLock(1);

#写日志#---待完善

}

 

unless ($is_runing) {

#启动日志,---待完善

print "-----start ok-----/n";

$is_runing = 1;

}

sleep ($curr_isOk ? $normalT : $failedT);

}

 

##====================================主程序到此结束========================

 

#设置文件锁

#入参:1设置为成功,0设置为失败

sub setLock

{

#---待完善

print "set ",shift, "/n";

}

 

#失败返回0,成功返回1

sub test_site

{

my $host = shift;

my $timeOut = 5; #超时时间

my $max_ms = 200/1000; #ping 允许的时延,200毫秒

my $tmpIs = 1; #测试结果

 

my $p = Net::Ping->new("icmp");

$p->hires();

my ($ret, $duration, $ip) = $p->ping($host, $timeOut); #进行 icmp 测试

unless ($ret and ($duration < $max_ms)){#icmp 失败,进行 tcp 测试

#写日志---待完善,记录返回时间

sleep 1;

 

my $tcp_p = Net::Ping->new("tcp", 2);

$tcp_p->port_number(getservbyname("http", "tcp"));

$tmpIs = 0 unless $tcp_p->ping($host);

$tcp_p->close();

}

 

$p->close();

return $tmpIs;

}

 

 

 

铁了心爱你.mp3 

christina aguilera-fighter.mp3 

Craigie Hill.wma 

Join Me.mp3 

LoveToBeLovedByYouMarcTerenzi.mp3 

the_lonely_shepherd.mp3 

《台北故宫》片头曲《爱延续》.mp3 

世上只有妈妈好.mp3 

两千年等一次.mp3 

仙剑问情.mp3 

伍佰 痛哭的人.mp3 

光棍好苦 .mp3 

勇敢的心电影主题曲.mp3 

周华健-上上签.mp3 

周华健-江湖笑.mp3 

周华健—其实不想走.mp3 

宇宙骑士-Reason.mp3 

宇宙骑士-永远の孤独.mp3 

宇宙骑士最后的插曲Masquerade.MP3 

宇宙骑士结尾曲2「Lonely Heart」.mp3 

张宇.一个人的天荒地老.mp3 

张明敏-一剪梅.wma 

徐小凤-每一步.mp3 

我终于失去了你.mp3 

救姻缘-黄安.mp3 

李丽芬-爱不释手.mp3 

王杰-红尘有你.mp3 

画心-张靓颖.mp3 

画皮原声.mp3 

笑看风云.MP3 

胡戈-被逼的.wmv 

莲花争霸配乐-江湖路琴箫合奏.mp4 

贾鹏芳 旅愁 绝美的二胡演奏.mp3 

锦绣二重唱--思念总在分手后.mp3 

 

 

 

 

 

 

原创粉丝点击