Monitoring your internet connection

Half a year ago my DSL Connection started dropping every hour or so and is re-established after a minute. This was very annoying.

Since O2 ships this blautiful router which gives no information at all, how to document these connection losses?

What I have so far:

checkinternet.sh (shell script)

#!/bin/bash
echo "Date - Localhost - o2.box - LAN Printer - Spiegel.de" > checkinternet.log
while true
date >> checkinternet.log
do
( while read ip; do ping -c1 -W1 -q $ip; done ) < ips | grep round >> checkinternet.log
sleep 10
done

ips (text file)

localhost
o2.box
192.168.1.2
www.spiegel.de

checkinternet.l (lex script)

%{
#include <stdio.h>
%}
%%
[a-zA-Z]+[ ][a-zA-Z]+[ ][0-9]+[ ]     printf("\n"); /* printf("\n%s,", yytext); */
[0-9]+[\:][0-9]+[\:][0-9]+            printf("%s,", yytext);
CEST      /* ignore */
\n        /* ignore */
[ \t]     /* ignore */
round-trip /* ignore */
min      /* ignore */
avg      /* ignore */
max      /* ignore */
stddev      /* printf("CONNECT "); */
=        /* ignore */
[0-9]+\.[0-9]+                       printf("%s,", yytext);
\/       /* ignore */
ms      /* ignore */
[0-9]+ /* ignore year */
%%

Compile with

lex checkinternet.l
cc lex.yy.c -o checkinternet -ll

Then run checkinternet.sh for a few hours, then

./checkinternet < checkinternet.log > checkinternet.csv
tail checkinternet.csv
open /Applications/Microsoft\ Office\ 2011/Microsoft\ Excel.app/ checkinternet.csv

And plot rows 1,5,… screenshot and annotate with the Mac OS Preview

Works – but there is room for improvement. Comments are always welcome.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s