6.6 Construct an EEM applet that automates a task, a troubleshooting step or data collection

ENCOR 350-401 v1.2 · 6.0 Automation and Artificial Intelligence

Embedded Event Manager (EEM) lets IOS react to its own events: a syslog message, an interface counter, a CLI command, a timer, a tracked object. An applet pairs one event with a list of actions, such as running commands, sending a syslog message or an email. ENCOR expects you to build one for automation, troubleshooting or data collection.

What you must know

An applet that collects data

event manager applet OSPF-DOWN
 event syslog pattern "%OSPF-5-ADJCHG.*FULL to DOWN"
 action 1.0 cli command "enable"
 action 2.0 cli command "show ip ospf neighbor | append flash:ospf-down.txt"
 action 3.0 cli command "show logging | include OSPF | append flash:ospf-down.txt"
 action 4.0 syslog msg "OSPF neighbor lost: data saved to flash:ospf-down.txt"

Actions run in string order of their labels (1.0, 2.0, 10.0 sorts before 2.0, so use consistent numbering). cli command "enable" is needed first because applets start in user EXEC.

The adjacency drops, the applet captures the state to flash and announces it (1), so you have evidence even if the problem clears before anyone looks.

Other events

event manager applet NIGHTLY-BACKUP
 event timer cron cron-entry "0 2 * * *"
 action 1.0 cli command "enable"
 action 2.0 cli command "copy running-config tftp://10.0.50.30/r1.cfg" pattern "Address"
 action 3.0 cli command ""
!
event manager applet UPLINK-TRACK
 event track 1 state down
 action 1.0 syslog priority critical msg "Uplink probe failed"

event none creates an applet you run by hand with event manager run NAME, a handy way to package a troubleshooting routine.

Commands

show event manager policy registeredRegistered applets and their events.
show event manager history eventsWhen each applet ran.
event manager run NAMERuns an applet with event none.
debug event manager action cliShows each CLI action and its output.

Exam traps

Check yourself

Which event detector reacts to a log message?
event syslog pattern "…".
Why does an applet's show running-config fail?
The applet runs in user EXEC; it needs cli command "enable" first.
How do you create an applet you trigger by hand?
Use event none and run it with event manager run <name>.

Labs

Try it live: Automate the router: RESTCONF, NETCONF, JSON and EEM

More topics in 6.0 Automation and Artificial Intelligence