Ghost in the Machine (logging connection uptime)

Problem: I think, despite many hours of on site tech support/cable guys, my net connection is still dropping (the ‘cable light’ indicating communication to isp’ stays off when it should be solid) for 1-2min periods on a frequent but seemingly random basis.

My Approach: Before deciding my next course of action, I’d like to log exactly when the connection is dropping. The modem is plugged into my Apple Time capsule router. The log generated by time capsule cannot easily (trust me on this one) be stored on a computer and it overwrites itself often. So I am looking for a program, ideally cheap/free (on mac or pc) that will keep track of every time the connection drops/hangs. It automatically reconnects whenever the issue is gone.

I’ve tried a buncha mac progs and none provided this functionality. Whats the simplest way to automatically log when my connection drops?

b
u
m
p

A shell script to periodically run ‘ping’ to some nearby router or known good host should be sufficient. Something like this, saved in a text file and then marked as “executable”:



#!/bin/sh

# change HOST_TO_PING to the machine you'd like to ping
HOST_TO_PING=192.168.1.9
SECONDS_BETWEEN_PINGS=120

while true
do
    # note: exact ping args are for OSX version of ping.  change on other systems
    if ping -t 5 -c 1 $HOST_TO_PING 2>&1 > /dev/null
    then
        echo OK: `date`
    else
        echo FAIL: `date`
    fi
    sleep $SECONDS_BETWEEN_PINGS
done


If you call that ‘pingthing’ and then open up a terminal and run e.g.:



pingthing > pinglog.txt


and leave that going for a few days, that’ll give you a nice view of when your connection goes down. You can of course tailor the output to whatever you want to do with the data, such as having it only spit out messages when it fails, or changing the date format. If you want more help on that, just ask.

ETA: I should add that if you’re unfamiliar with using the terminal and shell scripts, you may be completely confused by my instructions, which are pretty sketchy. If that’s the case, don’t get discouraged: just let me know and I’ll walk you through it. It’s not all that hard.