What's new

VPNMON VPNMON-R2 v2.0 -Jul 10, 2022- Monitor your VPN connection's Health (Thread locked/closed)

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

Interim v1.5 Beta4 is out there if anyone wants to test any of this new functionality... Here's some of the additions since v1.5b3:
  • Added live feedback during the config process to indicate what the user entered, to hopefully catch typos before getting saved into the config. When the enter key is hit, it will use the default value, whether it's a fill-in-the-blank, or a Y/N question. Also, please *note* that I'm now giving people feedback on Y/N questions as well based on Kal1975's feedback ;) -- thanks @Kal1975
  • Enhanced the WAN connectivity check and loop for when the WAN goes down. Based on some feedback from @Stephen Harrington, I've revamped the loop to utilize a different method to check for a WAN up/down situation. Please let me know how this works for you, @Stephen Harrington! :)
  • I have added another item to the config menu -- a delayed start-up option -- allowing you to specify how many seconds you would like to delay VPNMON-R2 from running when it starts up. This was added to allow for more compatibility with other potential scripts that are starting up after a router reboot. Please go through the (vpnmon-r2.sh -config) to add this setting -- thanks @Stephen Harrington!
Beta4
Code:
curl --retry 3 "https://raw.githubusercontent.com/ViktorJp/VPNMON-R2/master/vpnmon-r2-1.5b4.sh" -o "/jffs/scripts/vpnmon-r2.sh" && chmod a+rx "/jffs/scripts/vpnmon-r2.sh"

Stable:
Code:
curl --retry 3 "https://raw.githubusercontent.com/ViktorJp/VPNMON-R2/master/vpnmon-r2-1.4.sh" -o "/jffs/scripts/vpnmon-r2.sh" && chmod a+rx "/jffs/scripts/vpnmon-r2.sh"
 
Last edited:
And just some feedback on this, @Stephen Harrington ... this is what I experienced after I killed my modem:

1.) The VPNMON-R2 GUI will look like it's hanging on one of the VPN slots for about 2-3 minutes while it naturally times out
2.) It then falls back to the "WAN DOWN" screen, and loops there every 15 seconds waiting for the WAN to come back up.
3.) When WAN was detected again, it ran the vpnreset process... during this time, it briefly got stuck on the Skynet Firewall update for about 10-15 seconds, presumably because it was waiting for a WAN connection as well, and then continued on.
4.) Main GUI came back up, and all was back to square one. ;)

Code:
Mon May 16 00:00:02 EDT 2022 - VPNMON-R2 - **VPN2 Ping/http failed**
Mon May 16 00:00:02 EDT 2022 - VPNMON-R2 ----------> ERROR: WAN DOWN
Mon May 16 00:00:19 EDT 2022 - VPNMON-R2 ----------> ERROR: WAN DOWN
Mon May 16 00:00:35 EDT 2022 - VPNMON-R2 ----------> ERROR: WAN DOWN
Mon May 16 00:00:51 EDT 2022 - VPNMON-R2 ----------> ERROR: WAN DOWN
Mon May 16 00:01:07 EDT 2022 - VPNMON-R2 ----------> ERROR: WAN DOWN
Mon May 16 00:01:24 EDT 2022 - VPNMON-R2 - WAN Connection Re-established -- Resetting VPN
Mon May 16 00:01:24 EDT 2022 - VPNMON-R2 - Executing VPN Reset
Mon May 16 00:01:32 EDT 2022 - VPNMON-R2 - Killed all VPN Client Connections
Mon May 16 00:02:34 EDT 2022 - VPNMON-R2 - Updated Skynet Whitelist
Mon May 16 00:02:41 EDT 2022 - VPNMON-R2 - Refreshed VPN Slots 1 - 5 from 2031 SuperRandom NordVPN Server Locations
Mon May 16 00:02:41 EDT 2022 - VPNMON-R2 - Randomly selected VPN1 Client ON
Mon May 16 00:02:41 EDT 2022 - VPNMON-R2 - Successfully updated YazFi guest network(s) with the current VPN slot.
Mon May 16 00:02:41 EDT 2022 - VPNMON-R2 - VPN Reset Finished
Mon May 16 00:02:58 EDT 2022 - VPNMON-R2 - API call made to update city to Denver
 
@Viktor Jaep, thanks for your continued work on this, Beta 4 is not looking that flash for me however unfortunately :)
I've rolled back to Beta 3 for now, as I have limited time to test at the moment.

It looks like it's not longer detecting my VPN is connected on initial startup, even though it definitely IS!
It then just keeps looping around as it never sees the VPN as being up, so I can't tell you whether the "WAN Down" situation is improved as I can't get it running in stable fashion.

I ran it manually using "-config" and went back through the Config steps again (feedback on selections is now great BTW), adding in "my" 30 second delay and then let it run.

First few lines of my SSH session log ...

Code:
admin@AsusRouter:/jffs/scripts# ./vpnmon-r2.sh -monitor
Delaying VPNMON-R2 start-up for 30 seconds...
   _    ______  _   ____  _______  _   __      ____ ___
  | |  / / __ \/ | / /  |/  / __ \/ | / /     / __ \__ \
  | | / / /_/ /  |/ / /|_/ / / / /  |/ /_____/ /_/ /_/ /
  | |/ / ____/ /|  / /  / / /_/ / /|  /_____/ _, _/ __/
  |___/_/   /_/ |_/_/  /_/\____/_/ |_/     /_/ |_/____/  v1.5b4

Mon May 16 16:18:44 AEST 2022 -------- Last Reset: 0d 00h:05m:39s
./vpnmon-r2.sh: line 1560: timeout: not found
./vpnmon-r2.sh: line 1560: timeout: not found
./vpnmon-r2.sh: line 1560: timeout: not found
./vpnmon-r2.sh: line 1560: timeout: not found
./vpnmon-r2.sh: line 1560: timeout: not found
VPN State 1: 2: 3: 4: 5: --------- Interval: 60 Sec
-----------------------------------------------------------------
- VPN1 Disconnected
-----------------------------------------------------------------

[Checking WAN Connectivity]...
[Checking WAN Connectivity]...ACTIVE

[Checking NordVPN Server Load]...
Ping Lo:0 Hi:0 ms | Load:  0%  | Config: VPNMGR
[Gathering VPN RX and TX Stats]... | Ttl RX:0.00 GB TX:0.00 GB
-----------------------------------------------------------------

Connection has failed, VPNMON-R2 is executing VPN Reset


Checking WAN Connectivity...
Checking WAN Connectivity...ACTIVE

Step 1 - Kill all VPN Client Connections

VPN was definitely up and connected.

Here is a Onedrive link to a .Zip file with my SSH session log, and the VPNMON-R2 log and config ...


Cheers,

Stephen
 
@Viktor Jaep, thanks for your continued work on this, Beta 4 is not looking that flash for me however unfortunately :)
I've rolled back to Beta 3 for now, as I have limited time to test at the moment.

It looks like it's not longer detecting my VPN is connected on initial startup, even though it definitely IS!
It then just keeps looping around as it never sees the VPN as being up, so I can't tell you whether the "WAN Down" situation is improved as I can't get it running in stable fashion.

I ran it manually using "-config" and went back through the Config steps again (feedback on selections is now great BTW), adding in "my" 30 second delay and then let it run.

First few lines of my SSH session log ...

Code:
admin@AsusRouter:/jffs/scripts# ./vpnmon-r2.sh -monitor
Delaying VPNMON-R2 start-up for 30 seconds...
   _    ______  _   ____  _______  _   __      ____ ___
  | |  / / __ \/ | / /  |/  / __ \/ | / /     / __ \__ \
  | | / / /_/ /  |/ / /|_/ / / / /  |/ /_____/ /_/ /_/ /
  | |/ / ____/ /|  / /  / / /_/ / /|  /_____/ _, _/ __/
  |___/_/   /_/ |_/_/  /_/\____/_/ |_/     /_/ |_/____/  v1.5b4

Mon May 16 16:18:44 AEST 2022 -------- Last Reset: 0d 00h:05m:39s
./vpnmon-r2.sh: line 1560: timeout: not found
./vpnmon-r2.sh: line 1560: timeout: not found
./vpnmon-r2.sh: line 1560: timeout: not found
./vpnmon-r2.sh: line 1560: timeout: not found
./vpnmon-r2.sh: line 1560: timeout: not found
VPN State 1: 2: 3: 4: 5: --------- Interval: 60 Sec
-----------------------------------------------------------------
- VPN1 Disconnected
-----------------------------------------------------------------

[Checking WAN Connectivity]...
[Checking WAN Connectivity]...ACTIVE

[Checking NordVPN Server Load]...
Ping Lo:0 Hi:0 ms | Load:  0%  | Config: VPNMGR
[Gathering VPN RX and TX Stats]... | Ttl RX:0.00 GB TX:0.00 GB
-----------------------------------------------------------------

Connection has failed, VPNMON-R2 is executing VPN Reset


Checking WAN Connectivity...
Checking WAN Connectivity...ACTIVE

Step 1 - Kill all VPN Client Connections

VPN was definitely up and connected.

Here is a Onedrive link to a .Zip file with my SSH session log, and the VPNMON-R2 log and config ...


Cheers,

Stephen
Nice catch, Steve. I think I left some debug code in there... hey - it was a late night! :) I've since removed it, and re-uploaded Beta 4. Please give it a shot at your convenience! I just retested it on my end and got similar results as before.

Here's the link:

Beta4
Code:
curl --retry 3 "https://raw.githubusercontent.com/ViktorJp/VPNMON-R2/master/vpnmon-r2-1.5b4.sh" -o "/jffs/scripts/vpnmon-r2.sh" && chmod a+rx "/jffs/scripts/vpnmon-r2.sh"
 
Please give it a shot at your convenience! I just retested it on my end and got similar results as before.

Thanks, will give it a crack tomorrow and report back.
 
As an aside, is post-mount the right place to be doing the auto-start? Are there other options?
Here is how I did it.

In short, I created a script called call-monitors.sh in /jffs/scripts, then I call that script at the end of post-mount.
 
Thanks, will give it a crack tomorrow and report back.
I keep looking at my watch saying "It MUST be daytime over in Australia by now! Hope Steve's test goes WELL!" Lol.
 
Hope Steve's test goes WELL!" Lol.
Beautiful late autumn day here so decided a long walk in the sunshine had priority! :)
I was literally writing my reply when your message popped up! Don't want you fretting any longer so ...

Yes, it works! Just installed the "newer" Beta 4 and pulled the power to my Cable Modem and it all appears to do what it should now as per your guide.

Slight hiccup is that your "Startup Delay" doesn't seem to fix the problems with my other scripts not firing correctly, whereas as my "old' method of just putting a "sleep 30" at the top of your script does still work. I need to play with that some more to confirm and also try and figure out what @iTyPsIDg is doing with his script and whether I want to go there as well?

But we are up and running with a solid base to continue the experiments so thought you'd want the good news whilst I play further.
 
Beautiful late autumn day here so decided a long walk in the sunshine had priority! :)
I was literally writing my reply when your message popped up! Don't want you fretting any longer so ...

Yes, it works! Just installed the "newer" Beta 4 and pulled the power to my Cable Modem and it all appears to do what it should now as per your guide.

Slight hiccup is that your "Startup Delay" doesn't seem to fix the problems with my other scripts not firing correctly, whereas as my "old' method of just putting a "sleep 30" at the top of your script does still work. I need to play with that some more to confirm and also try and figure out what @iTyPsIDg is doing with his script and whether I want to go there as well?

But we are up and running with a solid base to continue the experiments so thought you'd want the good news whilst I play further.
I'm SO happy to hear all went well (for the most part)! ;) That walk was certainly well-deserved!

That's really strange, that putting sleep 30 at the top of the script would be different than putting a sleep timer in there before the main script kicks off. So, I did find this... you can call commands like this without having to insert the sleep statement. Would something like this work for you? This might just work in your post-mount script?

Code:
sleep 30; sh /jffs/scripts/vpnmon-r2.sh -screen
 
This might just work in your post-mount script?
Yes, it does, same difference I think but saves me having to modify your script each time you update it ...
 
Yes, it does, same difference I think but saves me having to modify your script each time you update it ...

Perhaps that's the fix you're looking for, Obiwan Kenobi! :p
 
Since post-mount is a blocking script with a maximum execution timeout of 120 seconds, use care when deliberately introducing delays.
does that time out extend to scripts that are spawn from it with one line of code?

@Viktor Jaep It should also be noted that post-mount runs every time anything gets mounted. So you would want to play carefully how many spawns of a script you allow as well.
 
If the script is spawned with & then it won’t delay the completion of post-mount.

Want to learn about this behavior a bit more... perhaps you guys can clear my confusion, @dave14305 and @SomeWhereOverTheRainBow?

1.) The 120 seconds max execution timeout... does this mean if you put a sleep statement in the post-mount that would exceed the 120s, it just wouldn't complete from that point forward? Or would it bork up your router? What if it spawns a script with that sleep statement that runs immediately after the script executes?

2.) Spawning the script with an &... would something like this be acceptable?
Code:
/jffs/scripts/vpnmon-r2.sh -screen & # vpnmon-r2
 
Want to learn about this behavior a bit more... perhaps you guys can clear my confusion, @dave14305 and @SomeWhereOverTheRainBow?

1.) The 120 seconds max execution timeout... does this mean if you put a sleep statement in the post-mount that would exceed the 120s, it just wouldn't complete from that point forward? Or would it bork up your router? What if it spawns a script with that sleep statement that runs immediately after the script executes?

2.) Spawning the script with an &... would something like this be acceptable?
Code:
/jffs/scripts/vpnmon-r2.sh -screen & # vpnmon-r2
From my understanding it prevents your router from proceeding forward. the & statement in your one liner allows the process to work in the background instead of the foreground (i.e. a spawn of post-mount); in theory as dave suggest, it would allow your script to run with the sleep inside it without breaking post-mounts rule. however, you would need your sleep to be inside the script spawn from the one liner and not separate inside the post-mount.
 
Last edited:
Want to learn about this behavior a bit more... perhaps you guys can clear my confusion, @dave14305 and @SomeWhereOverTheRainBow?

1.) The 120 seconds max execution timeout... does this mean if you put a sleep statement in the post-mount that would exceed the 120s, it just wouldn't complete from that point forward? Or would it bork up your router? What if it spawns a script with that sleep statement that runs immediately after the script executes?

2.) Spawning the script with an &... would something like this be acceptable?
Code:
/jffs/scripts/vpnmon-r2.sh -screen & # vpnmon-r2
You probably could get away with doing your script and the sleep like this.

Code:
(sleep 120 && /jffs/scripts/vpnmon-r2.sh -screen) & # vpnmon-r2
, but I am not sure. I believe the ( ) allows the capture to be done in a subshell that is casted into the
background with &

The latter of the methods is the better option though.
 
Perhaps that's the fix you're looking for, Obiwan Kenobi! :p
@Viktor Jaep

I've already reverted from using that, other issues surfaced and May 4th was more than a week ago so suspect any Star Wars effect has worn off ... :)

Observations from fiddling with it today ...

(1)

Using:-

Code:
(sleep 30 && /jffs/scripts/vpnmon-r2.sh -screen) & # vpnmon-r2

in post-mount as suggested by @SomeWhereOverTheRainBow seems to work just as well / identically to my original method of using:-

Code:
/jffs/scripts/vpnmon-r2.sh -screen & # vpnmon-r2

with a "sleep 30" added in as the first line of vpnmon-r2.sh, which is to be expected as they SHOULD be equivalent?

HOWEVER confirmed that using your built-in Startup Delay parameter (set to 30) DOES NOT give the same result at present - other AMTM scripts "fail to launch" properly

(2)

Although I said before that the revised Beta 4 was happily detecting WAN Down and WAN Up events and restarting the monitoring, upon further testing it only seem to do it ONCE, that is the first time a WAN Down/Up event occurs after a reboot and my auto-run (called from post-mount)!

The second time I simulate a WAN Down by powering off my cable modem, vpnmon-r2.sh never gets to the "red" screen telling you to reconnect/reboot your modem, no matter how long I wait. I've tried this a couple of times from cold boots of the RT-AX86U just to double-check and appears to be repeatable! Mystified by this one. Can you duplicate my findings or am I going crazy (again)?

(3)

I also note an error message as follows on the "first" monitor cycle iteration after the re-detect of the "WAN Up"

Code:
grep: bad regex '\b(*error*|Undefined)\b': Invalid preceding regular expression

Also see screenshot:-

Grep Error.jpg


Not sure if that is anything to do with anything, on the next monitor "loop" it doesn't appear again and all seems to work?

I also don't know if it is has anything with my point (2) above, but I guess it could be related?

:)
 
Last edited:

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