Talk:Improved Netwatch II

From MikroTik Wiki
Jump to: navigation, search

Instead of 2 scripts, is there any problem with using just one like the following? If the pings fail AND the default route is set to 1 then it will set it to 3... If the pings do not fail AND the default route is set to 3 then it will set it to 1... If the pings do not fail AND the default route is already set to 1, then it will do nothing.

{

local i 0; {:do {:set i ($i + 1)} while (($i < 5) && ([/ping 4.2.2.2 interval=3 count=1]=0))};

:if ($i=5 && [/ip route get [find comment="Default Route"] distance]=1) do={:log info "Main Gateway Down"; /ip route set [find comment="Default Route"] distance=3} else={ :if ([/ip route get [find comment="Default Route"] distance]=3) do={:log info "Main Gateway Up"; /ip route set [find comment="Default Route"] distance=1} } }