this is ours netwatch script that we are using:
and of course we are pinging 8.8.8.8 in 10sec interval with timeout 10sec
UP:
:local i 0; {:do {:set i ($i + 1)} while (($i < 5) && ([/ping 8.8.8.8 interval=3 count=1]=1))};
:if ($i=5) do={:log info "PRIMARY LINK UP";
/ip dhcp-client set default-route-distance=0 numbers=0}
DOWN:
:local i 0; {:do {:set i ($i + 1)} while (($i < 5) && ([/ping 8.8.8.8 interval=3 count=1]=0))};
:if ($i=5) do={:log info "PRIMARY LINK DOWN";
/ip dhcp-client set default-route-distance=3 numbers=0}
and monitor route in routes set
dst address to 8.8.8.8 gateway through "primary" link. So the ping to 8.8.8.8 will go always through wan1 interface , and cannot go through wan2. So when wan1 is up it will ping 8.8.8.8 and therefore will be up and set route distance to 0.
numbers=0 is for "1st" dhcp client , you can see the number if you go to /ip dhcp-client print you will see the number under #