Watchdog-ping

This revision is from 2013/11/10 21:20. You can Restore it.

How to configure the relay on gpio output for interrupt (reset) any (modem) devices due to failed PINGs.

Create bash scripts, open

vim /etc/init.d/watchdog-ping

and paste (with edited WAIT, IP and RELAY settings)

#!/bin/sh
# BEGIN INIT INFO
# Provides:        watchdog-ping
# Required-Start:  $network $remote_fs $syslog
# Required-Stop:   $network $remote_fs $syslog
# Default-Start:   2 3 4 5
# Default-Stop:
# Short-Description: Start watchdog ping
# END INIT INFO

WAIT="60"             # sec delay between ping test
IP="192.168.11.197"   # testing IP or URL
RELAY="6"             # number relay (1-8)

while true; do
        while ping -qc 1 $IP >/dev/null
                do sleep $WAIT
        done
        sleep $WAIT
        echo "1" > /home/pi/remoteqth/cfg/gpio$RELAY
        sleep 1
        echo "0" > /home/pi/remoteqth/cfg/gpio$RELAY
done
exit 0

set

chmod 774 /etc/init.d/watchdog-ping

You have two startup options

  1. run script directly in terminal
    /etc/init.d/watchdog-ping
  2. or set as damon - will be run automatically after reboot
    update-rc.d watchdog-ping defaults

Have fun!