NMC DOiT Vol.2 Scenario 15 – Embedded Event Manager Example


I mentioned in the last post…

“Read up on the Cisco Embedded Event Manager. It’s one of those things you should have seen at least once before walking into the actual lab. I don’t know that I’m going to spend a lot of time on it, but in short, you can schedule TCL scripts to run at certain times or react to certain events.”

Here’s the code from the Scenario 15 task. The task was to create Lo166, leaving it shut. If Lo106 goes down, the router was supposed to bring Lo166 up. Then the router was to send an e-mail to “bob@netmasterclass.net”.

FYI, all of the “environment” variables were explicitly assigned right in the task. And the TCL script was canned, already there on the router as a function of installing IOS.

The code does the following:

  1. Shows the list of TCL scripts that are available to EEM.
  2. Creates Lo166 and a series of event manager environment variables that will be called by the TCL script later.
  3. Registers the available policy so that it can be used.
  4. Shuts down Lo106 as a test, showing what happens with EEM. You’ll notice that the e-mail didn’t get sent successfully, but at least you can see that the event did kick off as expected in reaction to Lo106 getting shut down.

R6#sh event manager policy available
No. Type Time Created Name
1 system Thu Feb 7 06:28:15 2036 sl_intf_down.tcl
2 system Thu Feb 7 06:28:15 2036 tm_cli_cmd.tcl
3 system Thu Feb 7 06:28:15 2036 tm_fsys_usage.tcl

R6#conf t
ip domain-name netmasterclass.com
interface lo166
event manager environment _email_server
event manager environment _email_to bob@netmasterclass.net
event manager environment _email_from candidate@netmasterclass.net
event manager environment _email_cc instructor@netmasterclass.net
event manager environment _cron_entry 0-59/2 0-23/1 * * 0-7
event manager environment _show_cmd show event manager policy registered
event manager environment _syslog_pattern .*UPDOWN.*Loopback106
event manager environment _config_cmd1 interface Loopback166
event manager environment _config_cmd2 no shut
event manager policy sl_intf_down.tcl
R6#show event manager policy registered
No. Class Type Event Type Trap Time Registered Name
1 script system syslog Off Sun Jun 2 09:11:16 2002 sl_intf_down.tcl
occurs 1 pattern {.*UPDOWN.*Loopback106}
nice 0 queue-priority normal maxrun 90.000

R6#conf t
R6(config)#interface Lo106
*Jun 2 09:16:33.038: %LINK-5-CHANGED: Interface Loopback106, changed state to administratively down
*Jun 2 09:16:34.038: %LINEPROTO-5-UPDOWN: Line protocol on Interface Loopback106, changed state to down
*Jun 2 09:16:35.122: %SYS-5-CONFIG_I: Configured from console by on vty0 (EEM:sl_intf_down.tcl)
*Jun 2 09:16:36.918: %LINK-3-UPDOWN: Interface Loopback166, changed state to up
*Jun 2 09:16:37.918: %LINEPROTO-5-UPDOWN: Line protocol on Interface Loopback166, changed state to up
*Jun 2 09:18:04.418: %HA_EM-6-LOG: sl_intf_down.tcl: Process Forced Exit
*Jun 2 09:18:04.418: %HA_EM-6-LOG: sl_intf_down.tcl: while executing
*Jun 2 09:18:04.418: %HA_EM-6-LOG: sl_intf_down.tcl: “if [catch {smtp_send_email $result} result] {
*Jun 2 09:18:04.418: %HA_EM-6-LOG: sl_intf_down.tcl: error $result $errorInfo
*Jun 2 09:18:04.418: %HA_EM-6-LOG: sl_intf_down.tcl: }”
*Jun 2 09:18:04.418: %HA_EM-6-LOG: sl_intf_down.tcl: (file “system:/lib/tcl/eem_scripts_registered/sl_intf_down.tcl” line 87)

By Ethan Banks

Ethan Banks is a podcaster and writer with a BSCS and 20+ years in enterprise IT. He's operated data centers with a special focus on infrastructure — especially networking. He's been a CNE, MCSE, CEH, CCNA, CCNP, CCSP, and CCIE R&S #20655. He's the co-founder of Packet Pushers Interactive, LLC where he creates content for humans in the hot aisle.