sealin
February 10, 2013, 3:29pm
1
: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!
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
September 1, 2021, 1:37pm
4
Hi,
Not working for mac ping, how can I get avg-rtt value for mac ping?
Thank you.
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."
}
}