Tracking my internet connection

April 25, 2010 on 5:12 pm | In Coding, Making | No Comments

Ok, to be fair most of the time my internet connection is great – it’s nice and fast. But periodically it will go all wonky for a few days and then I want to ‘keep an eye’ on it. A bit tricky… However there are two good things: there’s a fairly simple web page on the router that gives me all its stats, and Be (my ISP) has an excellent forum with lots of helpful technical people & Be staff to give tips on what to do. So if I can gather useful info for them, I’m sure I’ll be able to fix it.

What I decided to do is only use Python to ‘scrape’ the data I wanted from the Router’s web page and the stuff it into some data store and give me a nice graph out of it. I did look at cacti/rrdtool but I would have had to install and configure lots of other things (as I’m on a Mac) and I just wanted to use Python ideally, because Mac OS X comes with Python pre-installed.

So instead, I’ve knocked up a simple script that reads the Router status once a minute and writes a row of data out to a sqlite database (which is very simple to knock up). Then I have another script that reads out of that database and produces a html page with a graph or two. I’ve used the Google Visualisation API to draw the graphs, because they have a simple python API for it and a nice timeline graph that I can use.

I’ve a little Mac mini that I can leave on running my little ‘monitor.py’ script and Mac OS X has ‘web sharing’ (using Apache web server) that I can use to invoke ‘report.py’ to produce some nice interactive graphs of the history of my router. (a quick link on how to set this up)

So now I will leave this running for a while and see what data it produces. When I have a LOT of data I should probably summarise per hour and/or per day, and not keep every single minute’s worth of data. I don’t need to worry about that too much yet.

I might even be able to use this approach at work, although we do have Cacti set up there, so that may be a better option, but it is very complicated to configure and this might be a simpler/more flexible solution – especially with lots of good graphing solutions now out there.

The scripts are here: speedtouch_monitor.zip (41 KB)
They should work with a Speedtouch 585 Modem set to it’s default IP address (eg any Be customer).
You will probably need to enter your router’s password in the monitor.py file.

Also here is an example report from report.py.

Creative Commons License This work is licensed under a Creative Commons Attribution 2.5 License.
Powered by WordPress with Pool theme design by Borja Fernandez, modified by bubb.
Entries and comments feeds. Valid XHTML and CSS. ^Top^