Embedded Event Manager(EEM) is a scripting language in cisco devices that will allow you to automate some actions inside the devices.
In this example I'm trying to enable an interface that has been shutdown for some reasons.
In this example I'm trying to enable an interface that has been shutdown for some reasons.
TOPOLOGY
CONFIGURATION
■R1 CONFIG
interface Loopback0
ip address 1.1.1.1 255.255.255.0
!
interface FastEthernet0/0
ip address 192.168.1.1 255.255.255.0
duplex auto
speed auto
!
router ospf 1
router-id 1.1.1.1
log-adjacency-changes
network 0.0.0.0 255.255.255.255 area 0
ip address 1.1.1.1 255.255.255.0
!
interface FastEthernet0/0
ip address 192.168.1.1 255.255.255.0
duplex auto
speed auto
!
router ospf 1
router-id 1.1.1.1
log-adjacency-changes
network 0.0.0.0 255.255.255.255 area 0
event manager applet NOSHUT
event syslog pattern ".*FastEthernet0/0.*down.*"
action 1.0 cli command "enable"
action 2.0 cli command "conf t"
action 3.0 cli command "interface fastEthernet 0/0"
action 4.0 cli command "no shutdown"
event syslog pattern ".*FastEthernet0/0.*down.*"
action 1.0 cli command "enable"
action 2.0 cli command "conf t"
action 3.0 cli command "interface fastEthernet 0/0"
action 4.0 cli command "no shutdown"
■R2 CONFIG
interface Loopback0
ip address 2.2.2.2 255.255.255.255
!
interface FastEthernet0/0
ip address 192.168.1.2 255.255.255.0
duplex auto
speed auto
!
router ospf 1
router-id 2.2.2.2
log-adjacency-changes
network 0.0.0.0 255.255.255.255 area 0
ip address 2.2.2.2 255.255.255.255
!
interface FastEthernet0/0
ip address 192.168.1.2 255.255.255.0
duplex auto
speed auto
!
router ospf 1
router-id 2.2.2.2
log-adjacency-changes
network 0.0.0.0 255.255.255.255 area 0
■CHECK(let 's shutdown f0/0 and see what's happening in the background)
R1#debug event manager action cli
Debug EEM action cli debugging is on
R1#conf t
Enter configuration commands, one per line. End with CNTL/Z.
R1(config)#int f0/0
R1(config-if)#do sh ip int br
Interface IP-Address OK? Method Status Protocol
FastEthernet0/0 192.168.1.1 YES manual up up
Loopback0 1.1.1.1 YES manual up up
R1(config-if)#shut
R1(config-if)#
*Mar 1 01:06:21.399: %OSPF-5-ADJCHG: Process 1, Nbr 2.2.2.2 on FastEthernet0/0 from FULL to DOWN, Neighbor Down: Interface down or detached
*Mar 1 01:06:21.463: %HA_EM-6-LOG: NOSHUT : DEBUG(cli_lib) : : CTL : cli_open called.
*Mar 1 01:06:21.567: %HA_EM-6-LOG: NOSHUT : DEBUG(cli_lib) : : OUT :
*Mar 1 01:06:21.571: %HA_EM-6-LOG: NOSHUT : DEBUG(cli_lib) : : OUT : R1>
*Mar 1 01:06:21.571: %HA_EM-6-LOG: NOSHUT : DEBUG(cli_lib) : : IN : R1>enable
*Mar 1 01:06:21.587: %HA_EM-6-LOG: NOSHUT : DEBUG(cli_lib) : : OUT :
*Mar 1 01:06:21.587: %HA_EM-6-LOG: NOSHUT : DEBUG(cli_lib) : : OUT : R1#
*Mar 1 01:06:21.587: %HA_EM-6-LOG: NOSHUT : DEBUG(cli_lib) : : IN : R1#conf t
*Mar 1 01:06:21.611: %HA_EM-6-LOG: NOSHUT : DEBUG(cli_lib) : : OUT :
*Mar 1 01:06:21.611: %HA_EM-6-LOG: NOSHUT : DEBUG(cli_lib) : : OUT : Enter configuration commands, one per line. End with CNTL/Z.
*Mar 1 01:06:21.611: %HA_EM-6-LOG: NOSHUT : DEBUG(cli_lib) : : OUT : R1(config)#
*Mar 1 01:06:21.61
R1(config-if)#5: %HA_EM-6-LOG: NOSHUT : DEBUG(cli_lib) : : IN : R1(config)#interface fastEthernet 0/0
*Mar 1 01:06:21.731: %HA_EM-6-LOG: NOSHUT : DEBUG(cli_lib) : : OUT :
*Mar 1 01:06:21.731: %HA_EM-6-LOG: NOSHUT : DEBUG(cli_lib) : : OUT : R1(config-if)#
*Mar 1 01:06:21.735: %HA_EM-6-LOG: NOSHUT : DEBUG(cli_lib) : : IN : R1(config-if)#no shutdown
*Mar 1 01:06:21.779: %HA_EM-6-LOG: NOSHUT : DEBUG(cli_lib) : : OUT :
*Mar 1 01:06:21.779: %HA_EM-6-LOG: NOSHUT : DEBUG(cli_lib) : : OUT : R1(config-if)#
*Mar 1 01:06:21.779: %HA_EM-6-LOG: NOSHUT : DEBUG(cli_lib) : : IN : R1(config-if)#exit
*Mar 1 01:06:21.783: %HA_EM-6-LOG: NOSHUT : DEBUG(cli_lib) : : CTL : cli_close called.
*Mar 1 01:06:21.807: %SYS-5-CONFIG_I: Configured from console by vty0
R1(config-if)#do sh ip int br
Interface IP-Address OK? Method Status Protocol
FastEthernet0/0 192.168.1.1 YES manual up up
Loopback0 1.1.1.1 YES manual up up
R1(config-if)#
*Mar 1 01:06:27.007: %OSPF-5-ADJCHG: Process 1, Nbr 2.2.2.2 on FastEthernet0/0 from LOADING to FULL, Loading Done
R1(config-if)#
As you can see in 6seconds OSPF was up after a moment.
R1#debug event manager action cli
Debug EEM action cli debugging is on
R1#conf t
Enter configuration commands, one per line. End with CNTL/Z.
R1(config)#int f0/0
R1(config-if)#do sh ip int br
Interface IP-Address OK? Method Status Protocol
FastEthernet0/0 192.168.1.1 YES manual up up
Loopback0 1.1.1.1 YES manual up up
R1(config-if)#shut
R1(config-if)#
*Mar 1 01:06:21.399: %OSPF-5-ADJCHG: Process 1, Nbr 2.2.2.2 on FastEthernet0/0 from FULL to DOWN, Neighbor Down: Interface down or detached
*Mar 1 01:06:21.463: %HA_EM-6-LOG: NOSHUT : DEBUG(cli_lib) : : CTL : cli_open called.
*Mar 1 01:06:21.567: %HA_EM-6-LOG: NOSHUT : DEBUG(cli_lib) : : OUT :
*Mar 1 01:06:21.571: %HA_EM-6-LOG: NOSHUT : DEBUG(cli_lib) : : OUT : R1>
*Mar 1 01:06:21.571: %HA_EM-6-LOG: NOSHUT : DEBUG(cli_lib) : : IN : R1>enable
*Mar 1 01:06:21.587: %HA_EM-6-LOG: NOSHUT : DEBUG(cli_lib) : : OUT :
*Mar 1 01:06:21.587: %HA_EM-6-LOG: NOSHUT : DEBUG(cli_lib) : : OUT : R1#
*Mar 1 01:06:21.587: %HA_EM-6-LOG: NOSHUT : DEBUG(cli_lib) : : IN : R1#conf t
*Mar 1 01:06:21.611: %HA_EM-6-LOG: NOSHUT : DEBUG(cli_lib) : : OUT :
*Mar 1 01:06:21.611: %HA_EM-6-LOG: NOSHUT : DEBUG(cli_lib) : : OUT : Enter configuration commands, one per line. End with CNTL/Z.
*Mar 1 01:06:21.611: %HA_EM-6-LOG: NOSHUT : DEBUG(cli_lib) : : OUT : R1(config)#
*Mar 1 01:06:21.61
R1(config-if)#5: %HA_EM-6-LOG: NOSHUT : DEBUG(cli_lib) : : IN : R1(config)#interface fastEthernet 0/0
*Mar 1 01:06:21.731: %HA_EM-6-LOG: NOSHUT : DEBUG(cli_lib) : : OUT :
*Mar 1 01:06:21.731: %HA_EM-6-LOG: NOSHUT : DEBUG(cli_lib) : : OUT : R1(config-if)#
*Mar 1 01:06:21.735: %HA_EM-6-LOG: NOSHUT : DEBUG(cli_lib) : : IN : R1(config-if)#no shutdown
*Mar 1 01:06:21.779: %HA_EM-6-LOG: NOSHUT : DEBUG(cli_lib) : : OUT :
*Mar 1 01:06:21.779: %HA_EM-6-LOG: NOSHUT : DEBUG(cli_lib) : : OUT : R1(config-if)#
*Mar 1 01:06:21.779: %HA_EM-6-LOG: NOSHUT : DEBUG(cli_lib) : : IN : R1(config-if)#exit
*Mar 1 01:06:21.783: %HA_EM-6-LOG: NOSHUT : DEBUG(cli_lib) : : CTL : cli_close called.
*Mar 1 01:06:21.807: %SYS-5-CONFIG_I: Configured from console by vty0
R1(config-if)#do sh ip int br
Interface IP-Address OK? Method Status Protocol
FastEthernet0/0 192.168.1.1 YES manual up up
Loopback0 1.1.1.1 YES manual up up
R1(config-if)#
*Mar 1 01:06:27.007: %OSPF-5-ADJCHG: Process 1, Nbr 2.2.2.2 on FastEthernet0/0 from LOADING to FULL, Loading Done
R1(config-if)#
As you can see in 6seconds OSPF was up after a moment.
No comments:
Post a Comment