Hello.
Can please tell me how correctly ping some resources from all interfaces which i have on a router?
I’ve created the script, but it doesn’t work correctly(
:foreach interface1 in=[/interface print where name~"ether"] do={
:if ([/ping 8.8.8.8 count=10 interface=$interface1]=0) do={
:log error "LINK DOWN";
} else={
:log info "LINK FINE";
}
}
with all interfaces, you mean “all true ethernet interfaces”?
/interface
:foreach if in=[find where type="ether"] do={
:local ifname [get $if name]
:local result [/ping 8.8.8.8 count=10 interface=$if]
:if ($result=0) do={
:log error "Ping on $ifname: ALL FAILED (0/10)"
} else={
:if ($result!=10) do={
:log warning "Ping on $ifname: ONLY SOME ($result/10)"
} else={
:log info "Ping on $ifname: ALL OK (10/10)"
}
}
}
Hello.
Thank you for your reply.
Yes, i mean all ethernet interfaces on the router.
And in this case how can hide ping output result?
SEQ HOST SIZE TTL TIME STATUS
0 no route to host
1 no route to host
2 no route to host
3 no route to host
4 no route to host
sent=5 received=0 packet-loss=100%
Leave only the message about FAILED of OK.
I mean when i use :put instead :log
When ping is executed, for default the text go on screen.
Do not exist an option on ping command to do not do that.
I understand it.
But via a script i can send output result from ping to null and print only the result about FAILED or OK from :put message.
Please redefine your question, you contraddice yourself, and I do not understand what you mean.
I mean that i want to see only result from my script as massage - FAILED or OK, but without ping output.
For example as in this topic)
http://forum.mikrotik.com/t/suppress-output-from-ping-in-script/79536/1
Well, there is a guy called “rextended” that has already done the script on purpose.
http://forum.mikrotik.com/t/suppress-output-from-ping-in-script/79536/1
:global pingResult -1
/interface
:foreach if in=[find where type="ether"] do={
:local ifname [get $if name]
:local jobID [:execute ":set pingResult [:ping 8.8.8.8 count=10 interface=$ifname]"]
:while ([:len [/system script job find where .id=$jobID] ] > 0) do={
:delay 1s
}
:local result $pingResult
:if ($result=0) do={
# :log error "Ping on $ifname: ALL FAILED (0/10)"
:put "FAILED"
} else={
:if ($result!=10) do={
# :log warning "Ping on $ifname: ONLY SOME ($result/10)"
} else={
# :log info "Ping on $ifname: ALL OK (10/10)"
:put "OK"
}
}
}
Ok, FAILED and OK only… but 1 successfully ping over 10 is OK for you??? 
Yes, one successfully ping is ok for me.
Thank you so much