Answers:
我用Pingdom来做这件事。免费帐户,一张支票。Ping路由器的WAN IP地址,这一切都很好。您会获得每月的正常运行时间报告,并且可以向有线电视公司大喊大叫。
我不知道任何实用程序,但我使用perl为此做了一个简单的代码:
#!/usr/bin/perl
use Net::Ping;
use POSIX qw/strftime/;
if (-e '/var/run/net_test.pid') {
print "net_test already running.\n";
exit;
} else {
system "touch /var/run/net_test.pid";
}
my $host = "www.google.com";
my $ping = Net::Ping->new('icmp');
my $result = $ping->ping($host,2);
if ($result != 1) {
$format = strftime('[%d/%m/%Y %H:%M:%S]',localtime)." Internet is not available...";
$run = `echo $format >> /var/log/virtua_net`;
while ($result != 1) {
$result = $ping->ping($host,2);
sleep 60;
}
$format = strftime('[%d/%m/%Y %H:%M:%S]',localtime)." Internet is back...";
$run = `echo $format >> /var/log/virtua_net`;
} else {
$format = strftime('[%d/%m/%Y %H:%M:%S]',localtime)." Internet is ok...";
$run = `echo $format >> /var/log/virtua_net`;
}
$ping->close();
system "rm -rf /var/run/net_test.pid" if (-e "/var/run/net_test.pid");
exit;
它的作用是,它将在每次运行时尝试ping谷歌,然后随着时间的流逝,是否会得到答复,然后将其打印到文件中,以便您以后可以查看从什么时间到什么时间不可用。
如果您喜欢它,我可以进行细微更改以在Windows中使用,您确实需要安装ActivePerl。
唯一需要的更改是Windows上可能有所不同的路径和命令。
另一个不错的选择是http://www.alertfox.com/。免费的网站监视,交易测试和报告。
尝试使用PA Server Monitor Free版本。它的范围是有限的,但是免费版本可以Ping并为您创建图表。在Windows上运行,并作为后台服务运行,因此不会受到影响。
Powershell快速又脏
while ($true) {
#if (test-connection -count 1 microsoft.com -Quiet) {
if (test-connection -count 1 google.com ) {
$result=(get-date).ToString("yyyy-MM-dd hh:mm:ss")
$result = "$result ok"
"$result" | Tee-Object -FilePath c:\~~temp\router_log.txt -append #"$result" | Out-File -FilePath c:\~~temp\router_log.txt -append
sleep 5
} else {
while (-not (test-connection -count 1 google.com -Quiet)) {
$result=(get-date).ToString("yyyy-MM-dd hh:mm:ss")
$result = "$result down"
"$result" | Tee-Object -FilePath c:\~~temp\router_log.txt -append
sleep -millisecond 100
}
}
}