Community discussions

MikroTik App
 
kaz050457
just joined
Topic Author
Posts: 2
Joined: Sun Feb 18, 2024 4:17 pm

help ping

Mon Apr 14, 2025 5:56 am

Latest update this script is not working anymore. Bug? or have a new way to implement It. I'm getting a null/blank value. ty


:local pinghost "8.8.8.8"
:local pingresult [/ping $pinghost count=5 as-value]

:log info ("Packet Loss: " . ($pingresult->"packet-loss") . "%")
:log info ("Min RTT: " . ($pingresult->"min-rtt") . " ms")
:log info ("Avg RTT: " . ($pingresult->"avg-rtt") . " ms")
:log info ("Max RTT: " . ($pingresult->"max-rtt") . " ms")
 
armdx
just joined
Posts: 4
Joined: Sun Nov 05, 2023 3:19 pm
Location: Mexico

Re: help ping  [SOLVED]

Mon Apr 14, 2025 10:50 am

Hi friend! :D
I was check your script, technically a simple view don't exist a problem, but depend of routerOS version the scripting present a error.
If you use any Mikrotik equip whit a routerOS v6 your sintaxis when use the next line:
local pingresult [/ping $pinghost count=5 as-value]
Have a sintax error, because the console can't add "as-value" parameter, so for this version exist a error.
Now if use routerOS v7.18.2 (version I was use to make test and don't have idea last routerOS 7 versions if apply this) in the line need add next parameter "proplist", when use this, can add: avg-rtt, packet-loss, max-rtt and min-rtt. (View proplist image add)
With this parameter you can modify script and obtain your interested data but maybe not showing like interesting, because to use proplist the data stored like this:
.id=*0;max-rtt=00:00:00.000171;.id=*1;max-rtt=00:00:00.000171;.id=*2;max-rtt=00:00:00.000171;.id=*3;max-rtt=00:00:00.000171;.id=*4;max-rtt=00:00:00.000171
So, this is a little detail to use proplist parameter. Maybe a solve is try sum values and print result in another variable, but it's important search how routerOS obtain this results when use a simple ping command

I hope my commentaries can help you.

Regards!
You do not have the required permissions to view the files attached to this post.
 
kaz050457
just joined
Topic Author
Posts: 2
Joined: Sun Feb 18, 2024 4:17 pm

Re: help ping

Tue Apr 15, 2025 4:37 am

Hi friend! :D
I was check your script, technically a simple view don't exist a problem, but depend of routerOS version the scripting present a error.
If you use any Mikrotik equip whit a routerOS v6 your sintaxis when use the next line:
local pingresult [/ping $pinghost count=5 as-value]
Have a sintax error, because the console can't add "as-value" parameter, so for this version exist a error.
Now if use routerOS v7.18.2 (version I was use to make test and don't have idea last routerOS 7 versions if apply this) in the line need add next parameter "proplist", when use this, can add: avg-rtt, packet-loss, max-rtt and min-rtt. (View proplist image add)
With this parameter you can modify script and obtain your interested data but maybe not showing like interesting, because to use proplist the data stored like this:
.id=*0;max-rtt=00:00:00.000171;.id=*1;max-rtt=00:00:00.000171;.id=*2;max-rtt=00:00:00.000171;.id=*3;max-rtt=00:00:00.000171;.id=*4;max-rtt=00:00:00.000171
So, this is a little detail to use proplist parameter. Maybe a solve is try sum values and print result in another variable, but it's important search how routerOS obtain this results when use a simple ping command

I hope my commentaries can help you.

Regards!
ty for the help. It's working now. Here's sample working script on ros7 if someone needed..

:local pinghost "8.8.8.88"
:local pingdata [/ping $pinghost count=5 as-value proplist=packet-loss]
:local lossPercent 0

:foreach item in=$pingdata do={
:set lossPercent ($item->"packet-loss")
}

:log info ("Packet Loss to $pinghost: $lossPercent%")