Hello MikroTik Team,
I would like to request an enhancement to /tool netwatch that allows a “script” test type instead of only ICMP/HTTP.
Reason:
Many network health checks can’t be determined by a single ping to a fixed host. We often need to run a RouterOS script that tests multiple conditions — e.g., pinging several hosts from a specific interface, checking BGP state, verifying IP connectivity via different protocols, etc.
Proposed feature:
Add type=script (or similar) to Netwatch.
When selected, Netwatch would execute test-script= and use its boolean return value (true = up, false = down) to trigger the existing up-script and down-script.
This would allow MikroTik admins to integrate complex health logic into the same monitoring and automation framework as Netwatch, without needing to duplicate its scheduling and state tracking.
sample script:
/ip firewall address-list
add address=8.8.8.8 list=PingHosts
add address=4.2.2.1 list=PingHosts
add address=127.0.0.1 list=PingHosts
:global linkguard do={
:local iface $1
:local targetList $2
:local netOk false
:foreach i in=[/ip firewall address-list find list=$targetList] do={
:local t [/ip firewall address-list get $i address]
:if ([:tonum [/ping $t interface=$iface count=3 size=56 interval=300ms]] > 0) do={ :set netOk true }
}
:return $netOk
}
/tool/netwatch/add name=LG-ether1 \
type=script test-interval=30s timeout=3s \
test-script=":global linkguard; :return ([$linkguard "ether1" "PingHosts"])" \
up-script=":log info "LG-ether1: UP (linkguard passed)"" \
down-script=":log warning "LG-ether1: DOWN (linkguard failed)""
Thank you for considering this improvement — it would be a very powerful addition to RouterOS.
Best regards,
Tishri Clarin