Hello everyone.
I have one unresolved task in my network
I want to report reponse time of ping external address - i have 2 WAN and i want to measure response time for every path…
I found this part of code (with ping-flood command):
IP for Ping 8.8.8.8 by WAN1: 10.0.0.1
IP for Ping 8.8.4.4 by WAN2: 10.0.0.2
Make static route like
/ip route
add distance=1 dst-address=8.8.8.8/32 gateway=1.1.1.1 pref-src=10.0.0.1
add distance=1 dst-address=8.8.4.4/32 gateway=2.2.2.2 pref-src=10.0.0.2when you do flood-ping (can be considered DOS attack… you FLOOD the dst by ping… do 1 flood-ping size=38 ever 1 sec for “x” sec instead…)
the route are giving “automatically” src-address and you can choice wan interface.
Use this instead:
:local avgRttA value=0;
:local avgRttB value=0;
:local numPing value=4;
:local toPingIP1 value=8.8.8.8;
:local toPingIP2 value=8.8.4.4;
:for tmpA from=1 to=$numPing step=1 do={
/tool flood-ping count=1 size=38 address=$toPingIP1 do={
:set avgRttA ($“avg-rtt” + $avgRttA);
}
/tool flood-ping count=1 size=38 address=$toPingIP2 do={
:set avgRttB ($“avg-rtt” + $avgRttB);
}
/delay delay-time=1;
}
:log info ("Ping Average for 8.8.8.8 by WAN1: ".[:tostr ($avgRttA / $numPing )].“ms”);
:log info ("Ping Average for 8.8.4.4 by WAN2: ".[:tostr ($avgRttB / $numPing )].“ms”);
I forgot to add some details - I have 2 WAN and configured failover with VOIP as high priority service. (WAN1 - VOIP , WAN2 - rest of traffic)
I have to check ping response time from one external IP address - (provider of my VOIP service)
So i think i cannot use static routes (because i have voip isolated from rest of traffic - and changes in routing table may corrupt VOIP connections)
Is there any chance to run ping command with these parameters via Mikrotik API and read avg-rtt value without creation ssh connection ?
Yes, but this still means that you need an external device from which you’ll launch the API command, and inspect the results from. If you plan on storing the results on an external device anyway, then that shouldn’t be a problem - in fact, it would ease the process if that same device is the one launching the API command.
You could use “/system ssh” with 127.0.0.1 as an address, and use the “output-to-file” argument to write the output to a file.
But as you point out,
if i run ping and redirect output only result’s of ping command is writen to file so it will be > useless > for me.
… since parsing it is going to be very difficult locally, and (more importantly) it would be really fragile (e.g. an innocent change from one version to the next - like adding an extra column or an extra space - will screw up the whole thing). So in the end of the day, it’s much better to use the API in this scenario.
Many thanks for help
I have checked many solutions and i chose to create crontab task with ssh:
/usr/bin/ssh -i /home/nagios/.ssh/id_dsa -l monitor_user “system script run monitor_voip” < /dev/random > /tmp/voip_ping.logAPI Ping don’t have routing-mark parameter available.
Many thanks for discussion about possible solutions.