Community discussions

MikroTik App
 
arky
just joined
Topic Author
Posts: 12
Joined: Sat Apr 09, 2011 12:39 pm

OSPF backup route send email

Mon Jun 12, 2017 1:05 pm

Hi,
I have an OSPF routing network. On one router I have backup routes by ether10 and ether9. When the ether10 falls, the route switches to ether9. At this point in the window routing -> ospf-> routes shows me the IP gateway of the distant router 10.20.180.12.
And now the question of how to send the email that the traffic with ether10 jumped on ether9?
I thought to check the moment of appearance of the gateway (10.20.180.120) script but something can not embrace it.
 
gustavomam
Trainer
Trainer
Posts: 287
Joined: Tue Jul 23, 2013 6:29 pm
Location: Spain
Contact:

Re: OSPF backup route send email

Mon Jun 12, 2017 6:23 pm

Hi,

Test this

Set in e-mail settings
/tool e-mail
set address=smtp.gmail.com from=<mail@gmail.com> password=abc123 port=587 start-tls=yes user=mail@gmail.com

Create script

:global status10 [interface ethernet get ether10 running]
:global status9 [interface ethernet get ether9 running]

:if ($status10 = true&& $status9 = false) do={
:log info ("route2 disabled")
/tool e-mail send to="peter@gmail.com" subject="ALERT route 2 disabled"
}

:if ($status9 = true && $status10 = false) do={
:log info ("route1 disabled")
/tool e-mail send to="peter@gmail.com" subject="ALERT route 1 disabled"
}
 
User avatar
JohnSmith75
just joined
Posts: 4
Joined: Mon Jun 12, 2017 2:14 pm
Location: USA

Re: OSPF backup route send email

Mon Jun 12, 2017 10:51 pm

Give a feedback please, does it helps you or not?
 
User avatar
nichky
Forum Guru
Forum Guru
Posts: 1379
Joined: Tue Jun 23, 2015 2:35 pm

Re: OSPF backup route send email

Tue Jun 13, 2017 9:23 am

Does anyone check this one?
 
arky
just joined
Topic Author
Posts: 12
Joined: Sat Apr 09, 2011 12:39 pm

Re: OSPF backup route send email

Thu Jun 15, 2017 9:05 pm

Hi Gustavo,
I do not want to disable ether9 or 10 interface.
On ether 9 and 10 I have OSPF. Now the traffic goes to ether9 interfers and when it stops P2P traffic it switches me traffic to the second link via ethjer10.
This is like a script to investigate when all traffic has switched to ether10.
 
gustavomam
Trainer
Trainer
Posts: 287
Joined: Tue Jul 23, 2013 6:29 pm
Location: Spain
Contact:

Re: OSPF backup route send email

Fri Jun 16, 2017 9:39 am

Ok

Arky you can use this:
:global gateway1 ("10.20.180.120")
/ip route {
:foreach i in=[find gateway=$gateway1] do={
:if ([/ip route get $i active]) do={
/tool e-mail send to="peter@gmail.com" subject="ALERT Gateway1 is enable"
:log info ("ALERT Gateway1 is enable") ;
} else={
/tool e-mail send to="peter@gmail.com" subject="ALERT Gateway1 is disable"
:log info ("ALERT Gateway1 is disable") ;
}
}
}
	
 
User avatar
nichky
Forum Guru
Forum Guru
Posts: 1379
Joined: Tue Jun 23, 2015 2:35 pm

Re: OSPF backup route send email

Fri Jun 16, 2017 7:33 pm

gustavomam, Did you check that one in your MT. Does it work well?
 
gustavomam
Trainer
Trainer
Posts: 287
Joined: Tue Jul 23, 2013 6:29 pm
Location: Spain
Contact:

Re: OSPF backup route send email

Fri Jun 16, 2017 9:11 pm

Yes I have tried it early morning

Did it work for you?
 
arky
just joined
Topic Author
Posts: 12
Joined: Sat Apr 09, 2011 12:39 pm

Re: OSPF backup route send email

Sun Jun 18, 2017 5:30 pm

Hi Gustawo,
We have some progress.
I started the script at home and at the moment of switching traffic on ether10 w / ip route has a number of dynamic gateways (D-dynamic A-active o-OSPF). For each gateway sends email and logs and as a result I have 40 emails and logs. How to crush one?
When route goes back to ether9 and no 10.10.180.120 in / ip route this script will not send email or log.
 
gustavomam
Trainer
Trainer
Posts: 287
Joined: Tue Jul 23, 2013 6:29 pm
Location: Spain
Contact:

Re: OSPF backup route send email

Mon Jun 19, 2017 4:59 pm

Hi.

Maybe you can complete your routine with a more conditions like this:
:foreach i in=[find gateway=$gateway1 && active && dst-address=0.0.0.0/0] do={

Who is online

Users browsing this forum: No registered users and 8 guests