Community discussions

 
dadaniel
Member Candidate
Member Candidate
Topic Author
Posts: 157
Joined: Fri May 14, 2010 11:51 pm

get packet-loss value from ping

Fri Sep 21, 2018 12:28 pm

Is there a script that gets the built-in packet-loss percentage value of mikrotik's ping command and send a mail when a specific threshold is reached? I'm not very good at scripting, could please someone point me in the right direction?
 
User avatar
rendezz
just joined
Posts: 15
Joined: Mon Sep 17, 2018 11:07 am

Re: get packet-loss value from ping

Fri Sep 21, 2018 2:48 pm

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)))
Home of the Badjr, the cloud-managed business network router built on Mikrotik http://baselinecloud.com/badjr

Who is online

Users browsing this forum: No registered users and 11 guests