What's new

ChkWAN automated monitoring.

  • 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!

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.
 

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!
Top