I have two scripts, one to update the default gateway e other to ping in default gateway and reboot case the timeout excedds 60.But the timeout script not workin when is schedulled.
Gateway script
Code: Select all
:global defGateway;:foreach i in=[/ip route find] do={:if ([:typeof [:find [/ip route get $i active] yes]]!="nil" && [:typeof [:find [/ip route get $i dst-address] 0.0.0.0/0 ]]!="nil" ) do={:set defGateway [/ip route get $i gateway]; }}
Code: Select all
:global i 0; {:do {:set i ($i + 1)} while (($i < 60) && ([/ping $defGateway interval=5 count=1]=0))};:if ($i=60 ) do={:log info "Reboot devido ao Netwatch" ;delay 3s; :foreach i in=[/user find] do={:if ([:typeof [:find [/user get $i name] "infra"]]!="nil") do={/user enable $i }} ;/sys reboot};