Changing Interface state using EEM

Changing Interface state using EEM

This is a simple attempt to get familiar with EEM. Here, an example configuration of EEM is used to change the state of the interface to UP when the state goes DOWN accidentally.

First, the interface Loopback0 is enabled manually.

Loopback0 interface

interface Loopback 0

no shutdown

!

The router is configured with EEM configuration as below-

EEM Configuration

event manager applet LOOP0

event syslog pattern "Interface Loopback0.* down" period 1

action 1.0 syslog msg "Interface Loopback0 DOWN"

action 2.0 cli command "enable"

action 2.1 cli command "config t"

action 2.2 cli command "interface loopback 0"

action 2.3 cli command "no shutdown"

action 3.0 syslog msg "Interface Loopback0 UP"

!

Test run:

When the Loopback0 interface is shutdown manually, it triggers the EEM applet and performs the configuration.

Output

interface loopback 0

shutdown

!

*Mar 1 00:07:50.771: %LINK-5-CHANGED: Interface Loopback0, changed state to administratively down

*Mar 1 00:07:50.779: %HA_EM-6-LOG: LOOP0: Interface Loopback0 DOWN

*Mar 1 00:07:50.859: %HA_EM-6-LOG: LOOP0: Interface Loopback0 UP

*Mar 1 00:07:52.851: %LINK-3-UPDOWN: Interface Loopback0, changed state to up

TIP

If the EEM applet relies on syslog msg, make sure the logging console and terminal monitor is ON.