Community discussions

MUM Europe 2020
 
galleon2006
just joined
Topic Author
Posts: 22
Joined: Fri Jan 17, 2014 7:59 am

Ping results to log

Thu Mar 06, 2014 8:11 am

Hello. I need a script that will be ping remote host every second and write information into log file when ping latency is more than 10 ms
For example:
I define IP address and Mikrotik ping it.
Usually latency is 1 ms, but sometimes is 10 and more
So i need to have log file like this:
Jan 17 05:00:00 ping to 192.168.1.1 is 11ms
Jan 17 05:00:01 ping to 192.168.1.1 is 31ms
Jan 17 05:00:02 ping to 192.168.1.1 is 21ms

Jan 18 06:42:02 ping to 192.168.1.1 is 51ms
Jan 18 09:48:01 ping to 192.168.1.1 is 13ms
Jan 18 15:22:03 ping to 192.168.1.1 is 24ms
Thanks for help and sorry for bad english.

I tried this script:
:local avgping

/tool flood-ping x.x.x.x count=1 size=56 do={
:set avgping ($"avg-rtt");
}
:if ($avgping > 10) do={
log info "Ping to gateway x.x.x.x is $avgping ms"
}
and run it every 1 second.
Is that correct? Because I got different result with "flood-ping" and "ping" from terminal.
I just need to write all ping thats >10ms by command /ping x.x.x.x
 
User avatar
NAB
Trainer
Trainer
Posts: 503
Joined: Tue Feb 10, 2009 4:08 pm
Location: UK
Contact:

Re: Ping results to log

Thu Mar 06, 2014 11:42 am

Is that correct? Because I got different result with "flood-ping" and "ping" from terminal.
The code looks fine to me. I am pretty sure that avg-rtt is only available from flood-ping and I would certainly use flood-ping.
Nicholas Barnes BSc(hons)
Certified Mikrotik Consultant
Certified Mikrotik Trainer

Vitell - Asterisk, Linux and network consultants
Unofficial IRC channel: #routerboard on irc.z.je
 
galleon2006
just joined
Topic Author
Posts: 22
Joined: Fri Jan 17, 2014 7:59 am

Re: Ping results to log

Thu Mar 06, 2014 1:36 pm

The code looks fine to me. I am pretty sure that avg-rtt is only available from flood-ping and I would certainly use flood-ping.
Thanks!
Can you tell me please how can i get "TIME" value in my script when I use this command (not "flood-ping" , just "ping":
[admin@MikroTik] > ping 192.168.0.1 count=1
HOST SIZE TTL TIME STATUS
192.168.0.1 56 255 55ms
How can I get 55ms value in my script or it's impossible?
 
icenetz
just joined
Posts: 1
Joined: Mon Dec 02, 2019 4:04 am

Re: Ping results to log

Mon Dec 02, 2019 4:12 am

hi i tried test this script(system > scripts, running scripts) but nothing happen
and then test to terminal

[xxx@router] > :local avgping
[xxx@router] >
[xxx@router] > /tool flood-ping 192.168.
{... :set avgping ($"avg-rtt");
syntax error (line 2 column 6)
[xxx@router] > }
[xxx@router] > :if ($avgping > 10) do={
{... log info "Ping to gateway 192.168.1.150 is $
{... }

its said syntax error on :set avgping

where i missed?

Who is online

Users browsing this forum: No registered users and 10 guests