Simple internet connection uptime monitor

I do this the other way around with Pingdom. Free account, one check. Ping the WAN ip address of the router, and it's all good. You get a monthly uptime report, and you can shout at the cable company.


i don't know any util but i did myself a simple code for that with 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;

What it does is that it will try to ping google every time it runs and it will then print to a file if it got a reply or not along with the time so you can check later from what time to what time the internet was unavailable.

If you like it i can make the smalls changes to be used in windows and you did need to install ActivePerl that is all.

The only changes needed are paths and commands that may be different on windows nothing else.