What's new

Email notification when switching to secondary WAN?

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

Version 1.3
Hmm works ok from the terminal, but doesn't work when router is rebooted. Doesn't send emails.
It took 60 seconds on version 1.2 to send email. now it takes 142 seconds - but no email..

Code:
Aug  1 03:00:12 wan: finish adding multi routes
Aug  1 03:00:12 admin: wan_connect_notification: WAN connection restored. Ping cycles = 71, Actual time = 142, via /jffs/scripts/wan-start
Jun 22 17:51:29 dnsmasq-dhcp[297]: DHCPREQUEST(br0) 192.168.1.87 xx:xx:xx:xx:xx:xx

hmmmm now it sends letter without WAN status and ip after wait time 160 seconds..
 
Last edited:
Hmm works ok from the terminal, but doesn't work when router is rebooted. Doesn't send emails.
It took 60 seconds on version 1.2 to send email. now it takes 142 seconds - but no email..

Code:
Aug  1 03:00:12 wan: finish adding multi routes
Aug  1 03:00:12 admin: wan_connect_notification: WAN connection restored. Ping cycles = 71, Actual time = 142, via /jffs/scripts/wan-start
Jun 22 17:51:29 dnsmasq-dhcp[297]: DHCPREQUEST(br0) 192.168.1.87 xx:xx:xx:xx:xx:xx
Look closely at the syslog, as I wrote, you need to increase the PING_COUNT to about 90 or 100.
 
Look closely at the syslog, as I wrote, you need to increase the PING_COUNT to about 90 or 100.
i increased to 200 and got email without WAN status and ip after wait time 160 seconds..

Does it take so much time because of the script? version 1.2 needed 60 seconds sharp to get ip and wan status when rebooting. Now with version 1.3 it takes 160 seconds - but still no wan status and ip..
 
Hmm works ok from the terminal, but doesn't work when router is rebooted. Doesn't send emails.
It took 60 seconds on version 1.2 to send email. now it takes 142 seconds - but no email..

Code:
Aug  1 03:00:12 wan: finish adding multi routes
Aug  1 03:00:12 admin: wan_connect_notification: WAN connection restored. Ping cycles = 71, Actual time = 142, via /jffs/scripts/wan-start
Jun 22 17:51:29 dnsmasq-dhcp[297]: DHCPREQUEST(br0) 192.168.1.87 xx:xx:xx:xx:xx:xx

hmmmm now it sends letter without WAN status and ip after wait time 160 seconds..
I see, in your syslog it reports success, but no email?
 
i increased to 200 and got email without WAN status and ip after wait time 160 seconds..

Does it take so much time because of the script? version 1.2 needed 60 seconds sharp to get ip and wan status when rebooting. Now with version 1.3 it takes 160 seconds - but still no wan status and ip..
No, it should continue as soon as WAN is up and ping was successful. Let me double check the script.
 
I see, in your syslog it reports success, but no email?
When i set ping count to 200 - i see success in syslog but get email with no wan status and no ip. Even after 150 seconds:
Aug 1 03:00:13 admin: wan_connect_notification: WAN connection restored. Ping cycles = 75, Actual time = 150, via /jffs/scripts/wan-start
......
Jun 22 18:08:37 admin: wan_connect_notification: WAN type change detected, notification sent to avoronkov@gmail.com via /jffs/scripts/wan-start

If i leave ping count to 50 - i don't get email at all. But version 1.2 vorked perfectly even with 60 sec timeout..
 
If i leave ping count to 50 - i don't get email at all. But version 1.2 vorked perfectly even with 60 sec timeout..
That part hasn't even changed from 1.2 to 1.3...
Jun 22 18:08:37 admin: wan_connect_notification: WAN type change detected, notification sent to avoronkov@gmail.com via /jffs/scripts/wan-start
That part says that the script went through the email part. If it were a timeout then it would not print the line to Syslog.
Your router may be picky, let me re-upload the script with a few cosmetic changes.
Just a sec...
 
Script re-uploaded, download, change credentials/settings and replace existing file.
 
@stylish_me I see now where it could go wrong, let me make a small change...
 
Great thank you!
I think that timeout shouldn't be more then in version 1.2. It was 60 seconds. Now in 1.3 it became 150-160. May be the problem is somewhere there..
No, in your case the WAN IP is not registered yet, just a sec, need to test it on my routers....
 
Version 1.4 of the WAN connect notification script is now available.
- added WAN IP register auto wait cycles if that is slow on some routers/modems
- above is reported in email as 'WAN IP register wait cycles' 0 means there was no waiting cycle necessary. Every cycle has a 2 seconds pause built in.
So if it were 5 cycles, the time it took to register would be about 10 seconds.

Download in Other Scripts section here.
 
Version 1.4
Don't see any difference:

There's been a WAN type change on the router on Thu, 22 Jun 2017 19:29:29 +0300.

Router RT-N66U is now connected through .
The new IP is:

wan_connect_notification script stats:
Ping cycles = 71, actual wait time until WAN up = 142 seconds.
WAN IP register wait cycles: 1.
Script settings: PING_TIMEOUT = 2, PING_COUNT = 200, Max wait time = 400 seconds.


---
Your friendly router.
 
WAN IP register wait cycles: 1.
So it had to wait for the WAN type to be registered but it is not yet written to NVRAM.
I'll add another if clause after that to make sure the IP is not NULL.
 
So it had to wait for the WAN type to be registered but it is not yet written to NVRAM.
I can't understand - why it took only 60 seconds after reboot for version 1.2 to get ip, wan state and send me the email with correct information - and now ver 1.4 needs more then 140 seconds? On the same router with same settings. Only different script - v 1.2 with fixed timeout 60 sec and ver 1.4 with watchdog.
 
i switched back to v 1.2 with 60 sec timeout and it perfectly works:
Thu, 22 Jun 2017 19:50:43 +0300.
cleardot.gif

Your router is now connected through Primary WAN.
The new IP is: 10.13.70.222
 
I can't understand - why it took only 60 seconds after reboot for version 1.2 to get ip, wan state and send me the email with correct information - and now ver 1.4 needs more then 140 seconds? On the same router with same settings. Only different script - v 1.2 with fixed timeout 60 sec and ver 1.4 with watchdog.
Because now it actually checks if the router is online. But it still is a mystery to me why it would take that long.
Maybe increase the PING-TIMEOUT to 4?
Let me think about it over Dinner, if I can get a thought in between the chatter of the others...
 
Because now it actually checks if the router is online.
But v1.2 sends emails within 60 sec with correct information - so router is online within that 60-sec period for sure.
I would say even more - it sends emails even when timout is set to 5 or 10 sec. It means that the router is online right after the reboot. But these emails have no ip and wan status. As soon as i set to 60 sec - everything works perfect.
So why does v1.4 need 2-3 times more time to get the same information - that is the question.

Let me think about it over Dinner, if I can get a thought in between the chatter of the others...
No problem, i use v1.2 for now. As soon as you have any new ideas - i will make some tests with pleasure. Bon Appetit!
 

Similar threads

Latest threads

Sign Up For SNBForums Daily Digest

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