watchdog script for openwrt
sometimes my 3g based openwrt system gets in a broken state, and as it is going to be remote, I need a watchdog script to reboot it if the internet connection is broken
This is a bash script that runs from boot
---------------
#!/bin/sh
ping -4 -c 3 -I ppp0 www.google.com | grep -v '0 packets received' | grep 'packets received' || (ping -4 -c 3 -I ppp0 www.yahoo.com | grep -v '0 packets received' | grep 'packets received' || reboot)
sleep 60
/bin/sh /etc/config/watchdog.sh >> /dev/null 2>&1 &
---------------
it is called from /etc/rc.d/S95done
This is a bash script that runs from boot
---------------
#!/bin/sh
ping -4 -c 3 -I ppp0 www.google.com | grep -v '0 packets received' | grep 'packets received' || (ping -4 -c 3 -I ppp0 www.yahoo.com | grep -v '0 packets received' | grep 'packets received' || reboot)
sleep 60
/bin/sh /etc/config/watchdog.sh >> /dev/null 2>&1 &
---------------
it is called from /etc/rc.d/S95done
Comments
must wait before start 2 Mn on ubiquiti picostation 2 HP mode universal repeater and ping router was attached
#!/bin/sh
sleep 180
ping -4 -c 3 -I wlan0-1 192.168.154.254 | grep -v '0 packets received' | grep 'packets received' || (ping -4 -c 3 -I wlan0-1 www.yahoo.com | grep -v '0 packets received' | grep 'packets received' || reboot)
sleep 60
/bin/sh /etc/config/watchdog.sh >> /dev/null 2>&1 &
have you an idea ??
pour que le router reboot automatiquement lorsque la connection est couper(mode universal repeater)
aller dans system a l'onglet startup, en bas ajouter ces lignes de commande dans local startup
#!/bin/sh
ping -4 -c 3 -I wlan0-1 192.168.154.254 | grep -v '0 packets received' | grep 'packets received' || (ping -4 -c 3 -I wlan0-1 www.yahoo.com | grep -v '0 packets received' | grep 'packets received' || reboot)
/bin/sh /etc/config/watchdog.sh >> /dev/null 2>&1 &
se connecter en SSH et aller dans /etc , vous trouvez ici le rc.local qu'il faut rendre executable comme ceci: chmod +x rc.local
pour finir dans system allez a scheduled task (cron) et ajouter ces commandes pour un ping toutes les 2Mn
*/2 * * * * /etc/rc.local
voila ces fini !! @sly2015