dlostboy (at) lostinfo (dot) com 

Home | Journal | Multimedia | Files | Other | Links | About

      Monitoring your FreeBSD machine's connection to the world.

So you have a BSD box at home as your proxy/nat and you're having problems with your connection. Crappy service, bad wiring..whatever..and want to know when things get bad. This script should help:

	#!/bin/sh
	LOGFILE=/tmp/testresults.txt
	
	echo 'Running checks:' `date` > $LOGFILE
	echo 'Path & Latency...' >> $LOGFILE
	/usr/sbin/traceroute any.ip.address.you.know >> $LOGFILE
	echo 'Packetloss...' >> $LOGFILE
	/sbin/ping -c 25 the.same.ip.address | /usr/bin/tail -n 3 >> $LOGFILE
	if /usr/bin/grep "0% packet loss" $LOGFILE; then
	
	else
	        /usr/sbin/sendmail your.email@address.com < $LOGFILE
	fi
	/bin/rm $LOGFILE
	
Then put in your /etc/crontab,
  • */30 * * * * root /path/to/check_connect.sh > /dev/null 2>&1 The script will email you every time packetloss exceeds 0%
  •  
     

      ©2000, ©2001 LostInformation