Community discussions

MikroTik App
 
done411
newbie
Topic Author
Posts: 27
Joined: Wed Jan 16, 2019 10:36 am

Netwatch ISP failover email notification

Mon Nov 15, 2021 10:45 am

Hi,

i have an issue regarding email notification in case of primary ISP went up/down.

I recieve email notification without any issue when enabling or disabling netwatch script.
But when i simulate ISP failover inside firewall by dropping ICMP 8.8.8.8 and internet is moving to secondary ISP (which works fine) i didn't receive email notification. In the logging i see message: Error sending e-mail <ISP OPTICAL UP>: timeout occured.

Maybe it's a transition issue because in that period when he wants to send the mail the ISP is switching and internet isn't avaiable? Is there any option to add a delay for sending the email?

Thanks!
 
holvoetn
Forum Guru
Forum Guru
Posts: 5491
Joined: Tue Apr 13, 2021 2:14 am
Location: Belgium

Re: Netwatch ISP failover email notification

Mon Nov 15, 2021 2:02 pm

It may indeed be pure logic.

If you want to have a delay:
hard coded
:delay <whatevertimeinsecondsyouwant> 


Nicer (concept):
- wait until a certain URL can be resolved (with timeout to avoid infinite wait)
- then send the mail
I don't have any examples at hand but there should be some floating around if you search a bit.
 
done411
newbie
Topic Author
Posts: 27
Joined: Wed Jan 16, 2019 10:36 am

Re: Netwatch ISP failover email notification

Mon Nov 15, 2021 2:11 pm

Thanks for your reply. I have tried to add the delay command but it doesn't work (no email had been send).
tool e-mail send from="info@xxx-xxx.com" server=xxx.xxx.de user=info@xxx-xxx.com password=xxx subject="ISP OPTICAL UP" body="ISP OPTICAL is up on $[/system clock get time]" to="xxx.xxx@googlemail.com":delay <20> 

ip route enable [find dst-address=0.0.0.0/0 gateway=pppoe-out]
:log warning "ISP OPTICAL is up"
 
holvoetn
Forum Guru
Forum Guru
Posts: 5491
Joined: Tue Apr 13, 2021 2:14 am
Location: Belgium

Re: Netwatch ISP failover email notification  [SOLVED]

Mon Nov 15, 2021 3:16 pm

Delay needs to be added BEFORE tool email ...

First wait. Then send.

And simply
:delay 20

No brackets needed.
 
done411
newbie
Topic Author
Posts: 27
Joined: Wed Jan 16, 2019 10:36 am

Re: Netwatch ISP failover email notification

Mon Nov 15, 2021 4:19 pm

Thanks! Now everything works!

Who is online

Users browsing this forum: Bing [Bot], iaming, jajo10, johnson73, KpuCko, mwm1x, pepe262 and 105 guests