Ping in script problem

I recently loaded a script on a routerboard running ROS 5.0 beta3 and the output is not what I expected.

The following is an extract of the scrip to illustrate the problem:

:local otherside 172.18.254.134;
:local latency [ping $otherside interval=20ms count=100];
:log info ("Ping timeouts ".(100 - $latency));

On a rb running ros 3.30 it works perfectly, yet on the new rb running ros 5.0 b3 it does not. I double checked by running the ping in winbox, and it is correct. The log output should contain the amount of pings that timed out, yet it prints 100 (meaning the result of the ping command was 0). Please see attached images.

Did the syntax or usage of the ping command change?

Regards,
Pieter.
broken.jpg
working.jpg

What's new in 5.0beta3 (2010-Jun-17 13:46):

*) console - output of '/ping' and '/tool traceroute' commands is more
    in line with the rest of the console commands;

try

ping $otherside interval=20ms count=100

in Terminal and see the result

Hi Chupaka, thanks for the reply. I see the two outputs differ. Now the question is, how do I get the original result as this new method breaks my current scripts :laughing:

unfortunately, I have not installed beta3 yet, so I can’t see actual output, and you don’t want to post it =)

Hi, sorry, I did not realise you do not have beta3 available.

Here is the output from beta3:

[admin@rb433ah] > ping 172.18.254.134 interval=500ms  count=10      
HOST                                    SIZE  TTL TIME  STATUS                 
172.18.254.134                          56    64  241ms
172.18.254.134                          56    64  220ms
172.18.254.134                          56    64  280ms
172.18.254.134                          56    64  330ms
172.18.254.134                          56    64  228ms
172.18.254.134                          56    64  310ms
172.18.254.134                          56    64  276ms
172.18.254.134                          56    64  191ms
172.18.254.134                          56    64  243ms
172.18.254.134                          56    64  310ms
    sent=10 received=10 packet-loss=0% min-rtt=191ms avg-rtt=262ms 
   max-rtt=330ms 
HOST                                    SIZE  TTL TIME  STATUS

and this is from Ros3.30:

[admin@rb433] > ping 172.18.18.254 interval=20ms count=10         
172.18.18.254 64 byte ping: ttl=64 time=5 ms
172.18.18.254 ping timeout
172.18.18.254 ping timeout
172.18.18.254 64 byte ping: ttl=64 time=3 ms
172.18.18.254 64 byte ping: ttl=64 time=11 ms
172.18.18.254 64 byte ping: ttl=64 time=3 ms
172.18.18.254 64 byte ping: ttl=64 time=14 ms
172.18.18.254 64 byte ping: ttl=64 time=4 ms
172.18.18.254 64 byte ping: ttl=64 time=5 ms
172.18.18.254 64 byte ping: ttl=64 time=4 ms
10 packets transmitted, 8 packets received, 20% packet loss
round-trip min/avg/max = 3/6.1/14 ms

Here is the output for a :put command:
Ros5.0beta3

[admin@rb433ah] > :put [ping 172.18.254.134 interval=500ms  count=10
]
HOST                                    SIZE  TTL TIME  STATUS                 
172.18.254.134                          56    64  371ms
172.18.254.134                          56    64  411ms
172.18.254.134                          56    64  207ms
172.18.254.134                          56    64  127ms
172.18.254.134                          56    64  221ms
172.18.254.134                          56    64  220ms
172.18.254.134                          56    64  147ms
172.18.254.134                          56    64  401ms
172.18.254.134                          56    64  227ms
172.18.254.134                          56    64  267ms
    sent=10 received=10 packet-loss=0% min-rtt=127ms avg-rtt=259ms 
   max-rtt=411ms 
HOST                                    SIZE  TTL TIME  STATUS

Ros3.30

[admin@rb433] > :put [ping 172.18.18.254 interval=20ms count=10]
172.18.18.254 64 byte ping: ttl=64 time=3 ms
172.18.18.254 64 byte ping: ttl=64 time=6 ms
172.18.18.254 64 byte ping: ttl=64 time=12 ms
172.18.18.254 64 byte ping: ttl=64 time=6 ms
172.18.18.254 64 byte ping: ttl=64 time=4 ms
172.18.18.254 64 byte ping: ttl=64 time=4 ms
172.18.18.254 64 byte ping: ttl=64 time=2 ms
172.18.18.254 64 byte ping: ttl=64 time=12 ms
172.18.18.254 ping timeout
172.18.18.254 64 byte ping: ttl=64 time=5 ms
10 packets transmitted, 9 packets received, 10% packet loss
round-trip min/avg/max = 2/6.0/12 ms
9

Looks like the last line on ros3.30 contains the variable number I am looking for, but for beta3 it is a blank line. Any ideas? My Mikrotik scripting is very… basic :smiley:

hmmm… I can’t find a way to get the result of ping command in beta3… sounds like a lack of feature =) because “sent=10 received=10 packet-loss=0% <…>” seems like API output, but you cannot get it via CLI :frowning: will wait for beta4 =)

Thanks for the help Chupaka.

Can anyone from the Mikrotik staff please confirm if this problem will be addressed in beta4?

Or if there is a way to get this script to work on beta3?

Thanks :smiley:

please write to support@ to be sure =)

I did :slight_smile:

Sadly no reply yet, but I am sure they are busy with it. Just wanted to get some confirmation.

Im tyring something similar.

This works from the CLI:

:foreach i in=[/ppp active find where radius=no] do={ :if ([/ping count=1 [/ppp active get $i address]]!=1) do={ /ppp active remove $i } }

But not in a script. The ping command returns the number of successful pings as a result on the CLI, but not in a script. Is that intended?

beta5 is here, you may check it =)

Been running beta5 since 9am EST on 4 routers… :smiley:

and the problem you described is still here? then write to support@ =)

I will. I never tried doing that particular function until yesterday. Im assuming it did work because I saw failover scripts that used it in that way… :smiley:

Good day. I have been busy on a different project for a while now, and have only recently had time to look at this ping script again.

I loaded Ros5 beta 6 and the ping script is still not working.

I will send a mail to support as well, I just wanted to keep this thread updated too.

Please see attached image for the results.

Best regards :slight_smile:
mikrotik-ping-test.jpg

Hi, I checked RC2, the problem is still there. :frowning:

In v5.0rc1 it seems to work fine for me, both in terminal and scripts.

It may be that it accepts properties more like other commands (ex. /ping address=x.x.x.x …)

This worked for me:

# Should output 5
:local p [/ping address=127.0.0.1 count=5 interval 1s]
:put $p
Output: 5



# Should output 0
:local p [/ping address=255.254.254.254 count=5 interval 1s]
:put $p
Output: 0

Hi dssmiktik, thanks for the reply.

I checked and yes, it looks like the ping works when you run the script via the terminal. But if you run that script by running clicking the icon on winbox or via the scheduler it does not work.

Please see attached screenshot:

1 - ran via terminal, output is correct.
2 - ran via winbox, output is wrong.
3 - i use Log to output the variable because I do not intend to run the script via console every 5 minutes on 100 routers.

P.S. This ping script is a small part of a much larger script.
ping-problem-rc2.jpg

Sorry, I missed the part about only running it via winbox (not terminal).

I’m getting very weird results as well. When I run via terminal, the terminal output and log both show correct values. When I run via winbox, the log shows an empty entry, completely blank. Also, when I run :execute “/system script run ”, completely blank log entries are created.