Below is an extract from the Badjr's failover detection code
Take it for a spin
:local totalpingsreceived 0;
:local avgrtt 0;
:local pinglimit 4
/tool flood-ping address=8.8.8.8 count=$pinglimit interval=00:00:01 timeout=00:00:01 do={
:if ($sent = $pinglimit) do={
:set totalpingsreceived $"received"
:if ($totalpingsreceived > 0) do={
:set avgrtt $"avg-rtt"
}
}
}
:put ("Total Pings Received: ".$totalpingsreceived)
:put ("Avg Rtt: ".$avgrtt)
:put ("Percentage: ".(($pinglimit*100) / ($totalpingsreceived)))