My First EEM Applet Script


Cisco IOS Embedded Event Manager (EEM)
is a powerful tool integrated with Cisco IOS Software for system management from within the device itself. EEM offers the ability to monitor events and take informational, corrective, or any desired action when the monitored events occur or when a threshold is reached. Capturing the state of the router during such situations can be invaluable in taking immediate recovery actions and gathering information to perform root-cause analysis. Network availability is also improved if automatic recovery actions are performed without the need to fully reboot the routing device.

Ok let try to Prevent someone turning off Loopback Zero! šŸ™‚

The Script:

event manager applet Lo0
event syslog occurs 2 pattern "Loopback0, changed state to admin"
action 1.0 syslog msg "Hey Someone shutdown my loopback0 - Turning it back on"
action 1.1 syslog msg "I am a Smart Router, i will turn my lo0 back up again"
action 1.2 cli command "enable"
action 1.3 cli command "configure ter"
action 1.4 cli command "int lo0"
action 1.5 cli command "no shut"
action 1.6 syslog msg "OK should be back up again"

EMMScript

Thanks to The Cisco Learning Network for this tip!

A Networker Blog

Advertisements

6 thoughts on “My First EEM Applet Script

  1. Nice one, however, there is a small issue! Loopback0 will change state to “admin down” even if it was deleted with “no interface loopback0”. Your script will in fact recreate the interface, but with no configuration. Perhaps you can add few more commands to fix that šŸ™‚

  2. Hello Marko!!

    Thanks for the catch there, and now with this script that issue should be fixed šŸ™‚

    Router(config-applet)#do show run | b event
    event manager applet Lo0
     event syslog occurs 2 pattern "Loopback0, changed state to admin"
     action 1.0 syslog msg "Hey Someone shutdown my loopback0 - Turning it back on"
     action 1.1 syslog msg "I am a Smart Router, i will turn my lo0 back up again"
     action 1.2 cli command "enable"
     action 1.3 cli command "configure ter"
     action 1.4 cli command "int lo0"
     action 1.5 cli command "no shut"
     action 1.6 syslog msg "OK should be back up again"
     action 1.7 cli command "ip add 10.1.1.1 255.255.255.0"
    !
    end
    
    Router(config-applet)#int lo0
    Router(config-if)#do show run int lo0
    Building configuration...
    
    Current configuration : 42 bytes
    !
    interface Loopback0
     no ip address
    end
    Router(config-if)#
    Router(config-if)#int lo0
    Router(config-if)#sh
    Router(config-if)#
    %LINK-5-CHANGED: Interface Loopback0, changed state to administratively down
    %HA_EM-6-LOG: Lo0: Hey Someone shutdown my loopback0 - Turning it back on
    %HA_EM-6-LOG: Lo0: I am a Smart Router, i will turn my lo0 back up again
    %HA_EM-6-LOG: Lo0: OK should be back up again
    Router(config-if)#
    %SYS-5-CONFIG_I: Configured from console by vty0
     %LINK-3-UPDOWN: Interface Loopback0, changed state to up
    Router(config-if)#do show run int lo0
    Building configuration...
    
    Current configuration : 62 bytes
    !
    interface Loopback0
     ip address 10.1.1.1 255.255.255.0
    end
    

    Cheers!
    Victor.-

  3. Hi,
    if you don’t exit the eem in the end you can finish vty lines:

    *Mar 1 01:23:30.055: %HA_EM-3-FMPD_CLI_CONNECT: Unable to establish CLI session: no tty lines available, minimum of 2 required by EEM

    R#sh users
    Line User Host(s) Idle Location
    * 0 con 0 idle 00:00:00
    98 vty 0 idle 00:14:15 EEM:L0
    99 vty 1 idle 00:05:24 EEM:L0
    100 vty 2 idle 00:04:13 EEM:L0

    Just add “end” and “exit” at the end of the script:

    action 6.0 cli command “end”
    action 7.0 cli command “exit”

    HTH

  4. Pingback: Cisco Tips: Voorbeeld EEM | Richard Rensen

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s