How EXACTLY does the "WDS/Connection Watchdog" set

Post new topic   Reply to topic    DD-WRT Forum Index -> General Questions
Author Message
lagrangersf
DD-WRT Novice


Joined: 01 Mar 2013
Posts: 21

PostPosted: Tue Aug 10, 2021 14:42    Post subject: How EXACTLY does the "WDS/Connection Watchdog" set Reply with quote
I know in general that the "WDS/Connection Watchdog" setting on the Administration>Keep Alive page of DD-WRT can be used to automatically ping a specified IP address at a preset interval, and automatically reboot the router in the event it does not respond.

However, what is not explained in the help files is exactly HOW this setting functions. I.E. does it trigger a reboot immediately after a single failed ping response, or does it require a certain number of consecutive failed ping responses to trigger the reboot? I ask because I do not want this setting to be randomly rebooting the router due to brief packet loss/network interruptions caused by non-serious momentary problems (high network usage, brief less-than-a-few-seconds connection drops, etc).
Sponsor
kernel-panic69
DD-WRT Guru


Joined: 08 May 2018
Posts: 14125
Location: Texas, USA

PostPosted: Tue Aug 10, 2021 16:16    Post subject: Reply with quote
I believe if I am reading this correctly, that it's 3 failed responses to ping considering all of the defined variables in the script.

https://svn.dd-wrt.com/browser/src/router/wdswatchdog/wdswatchdog.sh

_________________
"Life is but a fleeting moment, a vapor that vanishes quickly; All is vanity"
Contribute To DD-WRT
Pogo - A minimal level of ability is expected and needed...
DD-WRT Releases 2023 (PolitePol)
DD-WRT Releases 2023 (RSS Everything)

----------------------
Linux User #377467 counter.li.org / linuxcounter.net
eibgrad
DD-WRT Guru


Joined: 18 Sep 2010
Posts: 9157

PostPosted: Tue Aug 10, 2021 16:41    Post subject: Reply with quote
Since the watchdog is just a script, you can examine it.

Code:
root@lab-ddwrt2:~# cat /etc/config/wdswatchdog.sh
#!/bin/sh

WDS_WATCHDOG_INTERVAL_SEC=$(nvram get wds_watchdog_interval_sec)
WDS_WATCHDOG_IPS=$(nvram get wds_watchdog_ips)

while sleep $WDS_WATCHDOG_INTERVAL_SEC
do
  for ip in $WDS_WATCHDOG_IPS
  do
    if ping -c 1 $ip > /tmp/null
    then
      echo "$ip ok"
    else
      echo "$ip dropped one"
      sleep 10
      if ! ping -c 1 $ip > /tmp/null
      then
        echo "$ip dropped two"
        sleep 10
        if ! ping -c 1 $ip > /tmp/null
        then
           echo "$ip dropped three, Restarting Router"
           /usr/sbin/nvram commit
           /sbin/reboot &
        fi
      fi
    fi
  done
done 2>&1



As stated previously, it checks up to three (3) times, waiting 10 seconds between each check. Only on the third failure does it reboot. The process loops, waiting the amount of time specified in the GUI between passes. Notice you can check multiple IPs as well.

Easy enough to rewrite it to your own specs if it's not to your liking. For example, I personally think it would make more sense if it failed *all* IP checks before rebooting, just in case only one of the IPs is down. But it doesn't. If any fail, it reboots. Kind of pointless too that it echos to the terminal when it runs from a headless process.

_________________
ddwrt-ovpn-split-basic.sh (UPDATED!) * ddwrt-ovpn-split-advanced.sh (UPDATED!) * ddwrt-ovpn-client-killswitch.sh * ddwrt-ovpn-client-watchdog.sh * ddwrt-ovpn-remote-access.sh * ddwrt-ovpn-client-backup.sh * ddwrt-mount-usb-drives.sh * ddwrt-blacklist-domains.sh * ddwrt-wol-port-forward.sh * ddwrt-dns-monitor.sh (NEW!)
Display posts from previous:    Page 1 of 1
Post new topic   Reply to topic    DD-WRT Forum Index -> General Questions All times are GMT

Navigation

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum