Community discussions

MikroTik App
Member Candidate
Member Candidate
Topic Author
Posts: 172
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
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= 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

Who is online

Users browsing this forum: No registered users and 28 guests