Need Help ping Script

[admin@MikroTik] > ping 192.168.0.50 size=13400 count=5
HOST SIZE TTL TIME STATUS
192.168.0.50 timeout
192.168.0.50 13400 64 3ms
192.168.0.50 13400 64 3ms
192.168.0.50 timeout
192.168.0.50 timeout
sent=5 received=2 packet-loss=60% min-rtt=3ms avg-rtt=3ms max-rtt=3ms

Experts i need these results in sms
like this sent=5 received=2 packet-loss=60% min-rtt=3ms avg-rtt=3ms max-rtt=3ms

:local result [/ping 192.168.0.50 size=50000 count=6]
:if ($result =6) do={
  /tool sms send message=WORKING_FINE phone-number=01111111 usb1
:delay 10
  /tool sms send message=WORKING_FINE phone-number=031111111 usb1
} else={
  :if ($result = 0) do={
    /tool sms send message=DROPING_CHECK_IT phone-number=01111111 usb1
:delay 10
    /tool sms send message=DROPING_CHECK_IT phone-number=031111111 usb1
  }
}

Already using this but requirement some thing like that
sent=5 received=2 packet-loss=60% min-rtt=3ms avg-rtt=3ms max-rtt=3ms
Or just packet-loss=60% Avg
Please help me out thx

anyone ?

Try this

:local vText
:local vCount 6
:local vSize 50000
:local vResult

:set vResult [/ping 192.168.0.50 size=$vSize count=$vCount]
:set vText ("sent=$vCount received=$vResult packet-loss=" . ((100*$vResult)/$vCount) . "%")

...reporting code .....

It is not easy to get min/avg/max response time…or just I do not know how to do it

BartoszP

Change :local vTxt to :local vText or :set vText to :set vTxt

Done…thank you for spotting error

thx for reply

is this something like that

:local vTxt
:local vCount 6
:local vSize 50000
:local vResult

:set vResult [/ping 192.168.0.50 size=$vSize count=$vCount]
:set vText (“sent=$vCount received=$vResult packet-loss=” . ((100*$vResult)/$vCount) . “%”)

/tool sms send message=$vTxt phone-number=123456789 usb1

Yes.
Test it with:

:log warning ($vText)

instead of /tool … just watch the Log window
Please use my current code example as it has propoer variables names…

ping-script.png
thx bro for helping

sent and received is fine but packet loss is wrong

Yes…my fault… but it is so simple math that you should manage to change “success percentage” to “loss percentage”…

thanks so much brother :slight_smile: