Watchdog-ping

Difference between revisions from 2015/03/03 18:55 and 2013/11/11 03:00.
[<<- RemoteQTH-server|RemoteQTH-server]

How to configure the relay on RapsberryPI 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
# run script directly in terminal {{/etc/init.d/watchdog-ping}}
# or set as damon - will be run automatically after reboot{{update-rc.d watchdog-ping defaults}}
Have fun!