OSPF backup route send email

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.

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”
}

Give a feedback please, does it helps you or not?

Does anyone check this one?

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.

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") ;
}
}
}

gustavomam, Did you check that one in your MT. Does it work well?

Yes I have tried it early morning

Did it work for you?

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.

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={