Ping monitoring

While searching for simple DSL line monitoring tool I found nothing really simple and decent. My goal is to hunt down internet connectivity instability. Since I have linux box inside, it is very easy to achieve.

Put this script into cron to run at each hour and you will get history for your connection.

#!/bin/sh

dir=/var/log/ping/`date +%Y.%m.%d`
fn=`date +%H.00`

mkdir -p $dir

# Ping gateway and google dns for 1 hour
ping -c 3601 -i 1 [GW_IP] > $dir/$fn.gw&
ping -c 3601 -i 1 8.8.8.8 > $dir/$fn.gog&

# Wait for pings to finish
wait

# Gzip final files
gzip $dir/$fn.gw
gzip $dir/$fn.gog

# Clean up old files for 3 month
find /var/log/ping/ -type f -mtime +90 -exec rm {} \;

Leave a Reply

Your email address will not be published.