What's new
  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

ChkWAN automated monitoring.

miazza

Regular Contributor
I have installed the chkWAN script following the instructions in https://github.com/MartineauUK/Chk-WAN.

Now I'm trying to have it installed in cron for automated monitoring.

I have done this:
Code:
cat > /jffs/scripts/wan-event << EOF;chmod +x /jffs/scripts/wan-event
#!/bin/sh

if [ "\$2" == "connected" ];then
   # sleep 5
   # No need for recommended 'sleep n' as ChkWAN.sh has default 10 secs delay
   # Check WAN connectivity every 5 minutes
   sh /jffs/scripts/ChkWAN.sh cron="\*/5 \* \* \* \*" &
fi
EOF

But this is just updating the wan-event script.

In order to add the cron job
Code:
*/5 * * * * /jffs/scripts/ChkWAN.sh #WAN_Check#
I needed to add it manually with
Code:
crontab -e
Is this the right way ?
 
I have installed the chkWAN script following the instructions in https://github.com/MartineauUK/Chk-WAN.

Now I'm trying to have it installed in cron for automated monitoring.

I have done this:
Code:
cat > /jffs/scripts/wan-event << EOF;chmod +x /jffs/scripts/wan-event
#!/bin/sh

if [ "\$2" == "connected" ];then
   # sleep 5
   # No need for recommended 'sleep n' as ChkWAN.sh has default 10 secs delay
   # Check WAN connectivity every 5 minutes
   sh /jffs/scripts/ChkWAN.sh cron="\*/5 \* \* \* \*" &
fi
EOF

But this is just updating the wan-event script.

In order to add the cron job
Code:
*/5 * * * * /jffs/scripts/ChkWAN.sh #WAN_Check#
I needed to add it manually with
Code:
crontab -e
Is this the right way ?
See
 
I actually prefer updating the event scripts to run the ChkWAN script directly. That's also described in the GitHub readme.

By doing this, whenever the internet connection comes up, the ChkWAN script is kicked off and it starts monitoring the internet connection. When the router first comes up and then the internet comes up, the ChkWAN cycle starts. When ChkWAN sees that the internet connection is down, it restarts the WAN connection and ends. By doing so, when the internet connection starts again, ChkWAN starts up again and the cycle continues.

I find this works well for me as whenever my internet connection was having issues, I was just stopping and restarting the WAN connection. The CRON option is fine but doing it without CRON avoids the possibility of multiple ChkWAN scripts running at the same time. Not sure if that's actually possible.

Working well for me. Thanks @Martineau
 
Well, my question was indeed a bit different.
I like the cron version and I edited cron via the crontab -e adding the code */5 * * * * /jffs/scripts/ChkWAN.sh #WAN_Check# at the end.
This will launch the ChkWAN.sh by default every 5 minutes.

The event script was not working for me , I found my router with the wan red led and no wan working... needed to powercycle the rooter.
 
I write again here because I realize that every time I use a VPN, this script reboot the router:
Code:
Dec  1 19:25:00 (ChkWAN.sh): 12781 v1.17 connection status monitoring will begin in 10 seconds.....
Dec  1 19:25:11 (ChkWAN.sh): 12781 v1.17 Monitoring connection using 2 target PING hosts ( 9.9.9.9 1.1.1.1) (Tries=3)
Dec  1 19:25:11 (ChkWAN.sh): 12781 Monitoring pass 1 out of 3
Dec  1 19:25:20 (ChkWAN.sh): 12781 v1.17 Monitoring connection using PING method to 9.9.9.9 check FAILED
Dec  1 19:25:29 (ChkWAN.sh): 12781 v1.17 Monitoring connection using PING method to 1.1.1.1 check FAILED
Dec  1 19:25:39 (ChkWAN.sh): 12781 Monitoring pass 2 out of 3
Dec  1 19:25:48 (ChkWAN.sh): 12781 v1.17 Monitoring connection using PING method to 9.9.9.9 check FAILED
Dec  1 19:25:57 (ChkWAN.sh): 12781 v1.17 Monitoring connection using PING method to 1.1.1.1 check FAILED
Dec  1 19:26:07 (ChkWAN.sh): 12781 Monitoring pass 3 out of 3
Dec  1 19:26:16 (ChkWAN.sh): 12781 v1.17 Monitoring connection using PING method to 9.9.9.9 check FAILED
Dec  1 19:26:25 (ChkWAN.sh): 12781 v1.17 Monitoring connection using PING method to 1.1.1.1 check FAILED
Dec  1 19:26:25 (ChkWAN.sh): 12781 Rebooting..... (Action=REBOOT)

It seems that with VPN active and therefore different IP, 9.9.9.9 and 1.1.1.1 are not reached. is there any way to use a different IP or otherwise solve the issue ?
 
I write again here because I realize that every time I use a VPN, this script reboot the router:
Code:
Dec  1 19:25:00 (ChkWAN.sh): 12781 v1.17 connection status monitoring will begin in 10 seconds.....
Dec  1 19:25:11 (ChkWAN.sh): 12781 v1.17 Monitoring connection using 2 target PING hosts ( 9.9.9.9 1.1.1.1) (Tries=3)
Dec  1 19:25:11 (ChkWAN.sh): 12781 Monitoring pass 1 out of 3
Dec  1 19:25:20 (ChkWAN.sh): 12781 v1.17 Monitoring connection using PING method to 9.9.9.9 check FAILED
Dec  1 19:25:29 (ChkWAN.sh): 12781 v1.17 Monitoring connection using PING method to 1.1.1.1 check FAILED
Dec  1 19:25:39 (ChkWAN.sh): 12781 Monitoring pass 2 out of 3
Dec  1 19:25:48 (ChkWAN.sh): 12781 v1.17 Monitoring connection using PING method to 9.9.9.9 check FAILED
Dec  1 19:25:57 (ChkWAN.sh): 12781 v1.17 Monitoring connection using PING method to 1.1.1.1 check FAILED
Dec  1 19:26:07 (ChkWAN.sh): 12781 Monitoring pass 3 out of 3
Dec  1 19:26:16 (ChkWAN.sh): 12781 v1.17 Monitoring connection using PING method to 9.9.9.9 check FAILED
Dec  1 19:26:25 (ChkWAN.sh): 12781 v1.17 Monitoring connection using PING method to 1.1.1.1 check FAILED
Dec  1 19:26:25 (ChkWAN.sh): 12781 Rebooting..... (Action=REBOOT)

It seems that with VPN active and therefore different IP, 9.9.9.9 and 1.1.1.1 are not reached. is there any way to use a different IP or otherwise solve the issue ?
See the ChkWAN help for an example of how to specify custom PING= targets
 
See the ChkWAN help for an example of how to specify custom PING= targets
Yes I did it but no ping is working while the vpn is active. I tried also ping google.com and it does nt work while the browser is OK. The issue is firewall dependant and nothing to do with the script.
 
Last edited:
Yes I did it but no ping is working while the vpn is active. I tried also ping google.com and it does nt work while the browser is OK. The issue is firewall dependant and nothing to do with the script.
My point was that you could set/test the custom PING= targets with a known IP that is owned by the VPN provider i.e. some VPN providers allow you to use their private DNS servers or even an IP on the VPN endpoint.

However, if you are saying that ChkWAN is unable to ping anything if the VPN is active, and you stand by your summary statement

"The issue is firewall dependant and nothing to do with the script."

then I'm afraid I can't help.
 

Similar threads

Latest threads

Support SNBForums w/ Amazon

If you'd like to support SNBForums, just use this link and buy anything on Amazon. Thanks!

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Back
Top