Automate network responses with EEM applets and extend automation using Guest Shell Python scripting.
event manager policy EEM-INTF-DOWN-ALERTshow event manager policy registeredevent manager run EEM-OSPF-HEALTH-CHECKshow app-hosting detail appid guestshellguestshell run python3 /flash/collect_health.pyshow event manager policy registered detailEEM (Embedded Event Manager) provides an event-driven framework built into IOS XE. Events can be syslog patterns, CLI commands, SNMP OID thresholds, timers, or interface state changes. Actions include CLI commands, syslog messages, email notifications, and Tcl/Python script execution. EEM runs in the router process space — no external server needed.
Guest Shell is a Linux container (based on CentOS) running inside IOS XE. It provides a full Python 3 environment with the 'cli' module for executing IOS XE commands programmatically. Guest Shell has access to the management VRF and can make API calls, run scripts, and access the Linux filesystem — bridging IOS CLI automation with Python programmability.
EEM variables like $_cli_username, $_cli_remote_host, and $_syslog_msg allow dynamic responses based on event context. The 'action cli command' sends CLI to the exec prompt; 'action syslog' writes to the syslog buffer. Complex logic is possible with if/elseif/else/end constructs and set/string operations.
Syslog pattern matching is case-sensitive and uses regex. Test with 'debug event manager' and trigger the event. Verify 'logging buffered' includes the message level you're matching.
Requires 'iox' command and sufficient memory/storage. Check 'show app-hosting list'. If install fails, ensure IOS XE 16.8+ and IOx enabled in 'show iox-service'.
Guest Shell Python CLI module path: 'from cli import cli, execute'. Some IOS XE versions need 'import subprocess' instead. Check with 'guestshell run python3 -c "import cli; print(cli.__file__)"'.
Attempt the tasks yourself before viewing solutions.
Type SOLUTION to unlock.
CORE-1 EEM Config
! See solution-configs/CORE-1.cfg
Python Script
! See netconf_restconf_example.py for Python examples
Research and direction by Ioannis (John) Konstas; compiled and finalized with AI assistance.