Discovery 22: Configuring Cisco IOS Embedded Event Manager (EEM)
Discovery 22: Configuring Cisco IOS Embedded Event Manager (EEM)
com/content/xtrac/2
Detector Details
SNMP Monitoring SNMP objects.
Syslog Responds to various syslog messages, allowing for matching on regular expressions.
Counter Monitoring and responding to interface counter when cross threshold settings.
CLI events Screening CLI input for a regular expression match.
None This event detector is used to test EEM script/applet using "event manager run" command.
Timers (Countdown, watchdog and CRON)
IP SLA and Netflow events
To help troubleshoot an issue—When you need to troubleshoot problems of an intermittent nature, EEM scripts can be particularly useful. They allow you to automate the collection process of show command outputs and debug commands which allows you to capture data that would
otherwise be extremely hard to gather.
To help provide a solution—In cases where a temporary workaround is required while the Technical Assistance Center (TAC) does a root cause analysis. Take, for example, a situation where the problem is intermittent, but the reset of an interface fixes the problem. EEM scripts can be used to
trigger this action when the problem begins.
*Nov 26 02:59:37.214: %HA_EM-3-FMPD_SMTP: Error occurred when sending mail to SMTP server: 192.168.1.1 : error in connecting to SMTP server
*Nov 26 02:59:37.214: %HA_EM-3-FMPD_ERROR: Error executing applet interface_Shutdown statement 4.0
R1(config-if)#
*Nov 26 02:59:37.214: %HA_EM-6-LOG: interface_Shutdown : DEBUG(cli_lib) : : CTL : cli_close called.
*Nov 26 02:59:37.214:
*Nov 26 02:59:37.214: tty is now going through its death sequence
The output that is highlighted above shows that the commands that were listed in the EEM script were carried out in the order that they were listed. The interface state was changed to “up.” You can also observe that there was an error when connecting to the SMTP server, as this lab has
limited connectivity. If using email alerts in a production environment you should ensure that emails are being sent to your corporate email server, and that the router has permissions to send email to that server. The lab has no email server configured, so the last lines show that the
email has failed to be delivered.
Step 5: Disable all debugging on the R1 using the following commands:
R1(config-if)# end
R1# undebug all
[output omitted]
No. Class Type Event Type Trap Time Registered Name
2 applet user cli Off Mon Oct 21 20:19:34 2019 Stop_Debug
pattern {debug} sync no skip yes
maxrun 20.000
action 1.0 cli command "enable"
action 2.0 cli command "sh users | append unix:Debug"
action 3.0 cli command "sh clock | append unix:Debug_clock"
[output omitted]
Step 4: From the R1 console, trigger the EEM event by attempting to enable the debug all command and verify that the debug all command did not take effect.
Enter the following command:
R1# debug all
R1# show debugging
R1#
Even though the debug all command appeared to be taken successfully the EEM script had the instruction to “skip” the command. As shown from the show debugging command no debugging has been enabled on the router.
Step 5: Verify that the Debug and Debug_clock files were created in Flash using the following command:
dir unix: | include Debug
Enter the following command and observe the output:
R1# dir unix: | inc Debug
2106575 -rw- 36 Nov 25 2019 19:17:23 -08:00 Debug_clock
2106574 -rw- 269 Nov 25 2019 19:17:23 -08:00 Debug
R1#
Step 6: Inspect the contents of the Debug and Debug_clock files that were created or appended in Flash using the following command:
more unix:Debug
more unix:Debug_clock
Enter the following command and observe the output:
R1# more unix:Debug
Line User Host(s) Idle Location
0 con 0 idle 00:00:00
* 2 vty 0 idle 00:00:00 EEM:Stop_Debug
R1#more unix:Debug_clock
*19:17:23.484 PST Mon Nov 25 2019
In the output from the first file, you can see the line that was used when the EEM event was triggered. If a user was authenticated to that line their username would also be shown.
In the output from the second file, you can see the date and time that the event was triggered. If more than one event populated the files you would match the first event in one file to the first event in the second file, the second event in the first file to the second event in the second file,
and so on.
Summary and Next Steps
EEM can be a very useful tool for the network engineer. An engineer can use EEM for monitoring and correcting many events on Cisco network devices. In this lab, you demonstrated the use of EEM event detectors and associated actions that can be taken.