Site Tools


connectivity_watchdog

Connectivity Watchdog

You might want to monitor your Internet connectivity. The simplest way to do this is to run a custom task script in, for example: Administration/Scheduler/Custom 1

The basic command would be something like:

/bin/ping -q -c1 8.8.4.4


(8.8.4.4. is a google DNS server) which would cover the monitoring part without performing any action.

In order to link an action to a success (&&) or failure (||) we will append the wanted condition and the command.

For example:

#if ping fails, restart the wan.
/bin/ping -q -c1 8.8.4.4 || /sbin/service wan restart

# if ping fails, reboot the device.
/bin/ping -q -c1 8.8.4.4 || /sbin/reboot

# successful pings will log "Internet Available" where ping failures will log "Internet unavailable".
/bin/ping -q -c1 8.8.4.4 && /usr/bin/logger "Internet available" || /usr/bin/logger "Internet unavailable" 
connectivity_watchdog.txt · Last modified: 2021/09/13 16:53 by hogwild