and this is schedulescheduler-A
#set variables
:local pingcount 3
:local ipA 192.168.0.22
:local ipB 192.168.1.22
#ping gateways with src
:local pingresultA [/ping 8.8.8.8 src-address=$ipA count=$pingcount]
:local pingresultB [/ping 8.8.8.8 src-address=$ipB count=$pingcount]
#if link_A is UP
:if (($pingresultA=3)) do={
#send email
/tool e-mail send subject=($ipA . " is up ") \
body=("the gateway is up now at: " . [/system clock get date]) \ to=("test@gmail.com") tls=yes
#enable scheduler-Both
/system scheduler set [find name=ping_google_link_Both] disabled=no
#disablescheduler-B
/system scheduler set [find name=ping_google_link_B] disabled=yes
#disable scheduler-A
/system scheduler set [find name=ping_google_link_A] disabled=yes
}
scheduler-B
#set variables
:local pingcount 3
:local ipA 192.168.0.22
:local ipB 192.168.1.22
#ping gateways with src
:local pingresultA [/ping 8.8.8.8 src-address=$ipA count=$pingcount]
:local pingresultB [/ping 8.8.8.8 src-address=$ipB count=$pingcount]
#if Link_B is UP
:if (($pingresultB=3)) do={
#send email
/tool e-mail send subject=($ipB . " is up ") \
body=("the gateway is up now at: " . [/system clock get date]) \ to=("test@gmail.com") tls=yes
#enable scheduler-Both
/system scheduler set [find name=ping_google_link_Both] disabled=no
#disable scheduler-A
/system scheduler set [find name=ping_google_link_A] disabled=yes
#disable scheduler-B
/system scheduler set [find name=ping_google_link_B] disabled=yes
}
scheduler-Both
#set variables
:local pingcount 3
:local ipA 192.168.0.22
:local ipB 192.168.1.22
:global state no
#ping gateways with src
:local pingresultA [/ping 8.8.8.8 src-address=$ipA count=$pingcount]
:local pingresultB [/ping 8.8.8.8 src-address=$ipB count=$pingcount]
#if link_A is DOWN and link_B is UP then:
:if (($pingresultA=0) && ($pingresultB>0)) do={
#send email
/tool e-mail send subject=($ipA . " is down") \
body=("the gateway is down now at: " . [/system clock get date]) \ to=("test@gmail.com") tls=yes
#disable scheduler-A
/system scheduler set [find name=ping_google_link_A] disabled=no
#disable scheduler-B
/system scheduler set [find name=ping_google_link_B] disabled=yes
#disable scheduler-Both
/system scheduler set [find name=ping_google_link_Both] disabled=yes
}
#if link_A is UP and link_B is DOWN then:
:if (($pingresultA>0) && ($pingresultB=0)) do={
#send email
/tool e-mail send subject=($ipB . " is down") \
body=("the gateway is down now at: " . [/system clock get date]) \ to=("test@gmail.com") tls=yes
#disable scheduler-B
/system scheduler set [find name=ping_google_link_B] disabled=no
#disable scheduler-A
/system scheduler set [find name=ping_google_link_A] disabled=yes
#disable scheduler-Both
/system scheduler set [find name=ping_google_link_Both] disabled=yes
}
When count is strating in schedule i can see that Both is active, when something went wrong it should inform me and active script must be that which interface is in problem. So when I tried to disable a another wan interface, nothing happend, counting of schedule is still raising, like nothing happend. I tried to use a first usable line of script which tests a ping from a lanIP, and when I disabled interface ping is lost, so that part is working, i cant just figure out why the rest (informing, and changing to script of lost interface) is not working./system scheduler
add disabled=yes interval=5s name=ping_google_link_B on-event=scheduler-B \
policy=\
ftp,reboot,read,write,policy,test,winbox,password,sniff,sensitive,api \
start-date=jan/01/1970 start-time=00:00:00
add interval=5s name=ping_google_link_Both on-event=scheduler-Both policy=\
ftp,reboot,read,write,policy,test,winbox,password,sniff,sensitive,api \
start-date=jan/01/1970 start-time=00:00:00
add disabled=yes interval=5s name=ping_google_link_A on-event=scheduler-A \
policy=\
ftp,reboot,read,write,policy,test,winbox,password,sniff,sensitive,api \
start-date=jan/01/1970 start-time=00:00:00
BtW i found this script here http://phallaccmt.blogspot.rs/2016/02/m ... ns-to.html