Community discussions

MikroTik App
 
User avatar
sealin
just joined
Topic Author
Posts: 10
Joined: Sun Feb 03, 2013 12:58 pm

how to get the "avg-rtt" value of command "ping"

Sun Feb 10, 2013 5:29 pm

:global ipa
:set ipa [/ping 8.8.1.1 interval=0.1 count=20 interface=pppoe-out9]
:put $ipa

by the script above
i can get how many packets have gotten the destination
but i wonder how to get the "avg-rtt" value as showed in the picture, thanks a lot!
You do not have the required permissions to view the files attached to this post.
 
User avatar
sealin
just joined
Topic Author
Posts: 10
Joined: Sun Feb 03, 2013 12:58 pm

Re: how to get the "avg-rtt" value of command "ping"

Mon Feb 11, 2013 2:59 am

:shock: help,thanks
 
User avatar
greencomputing
Frequent Visitor
Frequent Visitor
Posts: 95
Joined: Wed Jun 23, 2010 1:12 pm
Location: Italy

Re: how to get the "avg-rtt" value of command "ping"

Thu Feb 28, 2013 4:49 pm

Hi sir

the ping retun value is defined to be related to the # of count set in the ping command .
That is the theory ... but you need some effective and working solution so I'll stop here the words and now the substances
to get the rtt on the average I used a workaround using the /tool flood-ping utility ; adapt the following to your requirement :

Suppose you need to monitor greencomputik.com host and make decision based on the avg-rtt ,
:local avgRtt ; /tool flood-ping greencomputiK.com  count=3 do={
  :if ($sent = 3) do={
    :set avgRtt $"avg-rtt"
  }
}
:put $avgRtt;


and here you have the output /th above code is included in script1) :
[nic.greencomputik@greencomputik-lan.net] /system script> run script1    
      sent: 3
  received: 3
   min-rtt: 70
   avg-rtt: 70
   max-rtt: 71

fetched rtt :70

Hoping that will help you.
greeting from greencomputiK land
 
kirac
just joined
Posts: 3
Joined: Wed Sep 01, 2021 12:48 pm

Re: how to get the "avg-rtt" value of command "ping"

Wed Sep 01, 2021 4:37 pm

Hi,

Not working for mac ping, how can I get avg-rtt value for mac ping?

Thank you.
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11968
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: how to get the "avg-rtt" value of command "ping"  [SOLVED]

Sat Sep 04, 2021 1:38 am

search tag # rextended mac ping results

Now you can, see this example:
/file remove [find where name="testmacping.txt"]
{
    :local jobid [:execute file=testmacping.txt script="/ping address=64:D1:54:55:FF:CC arp-ping=yes interface=bridge count=10"]
    :put "Waiting the end of process for file testmacping.txt to be ready, max 20 seconds..."
    :global Gltesec 0
    :while (([:len [/sys script job find where .id=$jobid]] = 1) && ($Gltesec < 20)) do={
        :set Gltesec ($Gltesec + 1)
        :delay 1s
        :put "waiting... $Gltesec"
    }
    :put "Done. Elapsed Seconds: $Gltesec\r\n"
    :if ([:len [/file find where name="testmacping.txt"]] = 1) do={
        :local filecontent [/file get [/file find where name="testmacping.txt"] contents]
        :if ($filecontent ~ "received=0") do={:put "Unreachable"; :return ""}
        :if ($filecontent ~ "input does not match any value of interface") do={:put "Wrong Interface"; :return ""}
        :local resultstart [:find $filecontent "sent" -1]
        :local resultend [:find $filecontent " \r\n\r\n" $resultstart]
        :local getresult [:pick $filecontent $resultstart $resultend]
        :local getavgrtt [:pick $getresult ([:find $getresult "avg-rtt=" -1] + 8) [:find $getresult " max-rtt" -1] ]
        :put "Result: >$getresult<"
        :put "only avg-rtt: >$getavgrtt<"
    } else={
        :put "File not created."
    }
}

Who is online

Users browsing this forum: anav, Andrey05, ivicask and 91 guests