Watchdog-ping

This revision is from 2013/11/08 23:32. You can Restore it.

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

open

vim /etc/init.d/watchdog-ping

and paste

#!/bin/sh
# BEGIN INIT INFO
# Provides:        edge
# 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
IP="192.168.11.197"   # 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

There are two possibilities

  1. run script directly
    /etc/init.d/watchdog-ping
  2. or

update-rc.d n2n defaults}}