the 'help cyril with linux' thread (3)

1 Name: cyrilthefish!ljAhqzG3aU 2005-05-20 23:21 ID:/PSvJGYq

Anyone good with writing linux bash scripts here? i could do with a little help...

i have a home network that includes a few windows PCs and a few linux PCs. I also have an ADSL broadband connection that is hilariously unstable due to the line-noise and varying signal-noise ratio of my BT phone line.

so what i want to do is set up a cron job or something on my 24/7 running (debian) linux server that maybe pings google or something a few times and reboots the ADSL router if there is too much packet loss. (the ADSL router isn't intelligent enough to notice if the ADSL line drops/errors all over the place)

i've figured out the telnet commands/login-info to reboot the router, but i'm lost as to where to start with for detecting packet loss.... i don't want it rebooting every time a single packet drops :o

2 Name: dmpk2k!hinhT6kz2E 2005-05-21 00:38 ID:CHctIl8R

#!/bin/sh
IP=<insert IP>
if [ -n "`ping -qc 5 $IP | grep "0% packet"`" ] ; then
<reboot router>
fi

There are probably better ways to do this, but there you go. Make sure the IP you use is of the first hop after the router. Using google for reference may be a bad idea, since you'll be needlessly abusing your router if a backbone somewhere goes down.

3 Name: CyB3r h4xX0r g33k 2005-05-21 06:30 ID:Heaven

gb2/code
This thread has been closed. You cannot post in this thread any longer.