Ethernet "on up", "on down" script trigger

I need to monitor "ethernet down" event with the lowest latency possible. There is a system events logged for this but do we have built-in trigger for that? I noticed an old forum post in 2009 about this as an upcoming feature but cannot find the documentation.

search on forum my event handler

You can adapt it,
even something that checks the logs.

I don't have time to do it directly today, but I'd start with that myself.

Lots of ways to skin the black cat!! :slight_smile:

One can use Netwatch, or check-gateway ( and adjust how many checks and timings to state not available ), and even DNS checking to determine availability. Then there is event handler ala rextended. If you like complex that is a great option, max flex!

Much more detail is required to determine the optimal method but your context is vague.

Only as a side note and strictly speaking both Netwatch and ping check-gateway and similar do not actually monitor link status, but rather whether something on the other side of the monitored ether port responds or fails to respond.

The effect is very, very similar, but not exactly the same thing.

What about:

/interface ethernet cable test [find] once

/interface ethernet cable test [find name=ether2] once

?

Define "monitor". What do you want to do when the interface goes down? Trigger an alarm on a management station? Send a message to support staff? Execute some action on the router/switch itself? Except for the latter case, you may want to consider sending selected log messages to a syslog server and take it from there.

Logging -> Interface -> Regex "ethX" -> Action (Script) -> Script does what you want

On what device and RouterOS version does this work? On my RB5009 (7.21.4) I get:

[root@MikroTik] > logging interface
bad command name logging (line 1 column 1)
[root@MikroTik] > system logging interface
bad command name interface (line 1 column 16)

Edit: in RouterOS 7.22 there is a new log action target script. That should do the trick to create a log event handler. It then becomes something like

/system/logging/action add name=loghandler target=script script=...
/system/logging add topics=... regex=... action=loghandler

Nice.