Handle ethernet up/down events

Is there anyway to hook ethernet up/down events? Or do you just have to write a script that periodically checks the status to see if the state has changed? I don’t want to use netwatch to ping a host I just want to fire a script if the physical link goes up or down.

in version 4 and older you had to check manually using some scripting wizardry. In version 5 there is possibility to add topic interface to logging and see up/down events.

Thank you janisk, but I can’t seem to get the topic to work correctly. I did the following.

[admin@two] > /system logging add topics=interface action=memory
[admin@two] > /system logging add topics=interface action=echo  
[admin@two] > /system logging print
Flags: X - disabled, I - invalid 
 #   TOPICS                                                                                         ACTION                                                                                         PREFIX    
 0   info                                                                                           memory                                                                                                   
 1   error                                                                                          memory                                                                                                   
 2   warning                                                                                        memory                                                                                                   
 3   critical                                                                                       echo                                                                                                     
 4   interface                                                                                      memory                                                                                                   
 5   interface                                                                                      echo

But I don’t see any output on the console or in /log print when I pull one of the ethernet cables. I’m probably doing something wrong so any pointers would be appreciated. I’m running 5.0rc3 the topic wasn’t present under rc1.

this is usual way how i use logging facility in routeros:

set up logging:

[admin@hs] /system logging action add name=interface target=memory
[admin@hs] /system logging add action=interface topics=interface

reap the results

[admin@hs] > log print follow where buffer=interface


 = = =   = = =   = = =      = = =   = = =   = = =      = = =   = = =   = = =

02:59:14 interface,info ether3-tst link down 
02:59:17 interface,info ether3-tst link up

this is mostly due to several “loud topics” are set in logging and this good way to separate them from one another.