Cisco IOS Task Automation

If you love your server or desktop operating system’s CLI as much as myself you have probably banged out a few scripts to automate tasks at least a time or two… Did you know you can also script and automate tasks on Cisco IOS networking devices? The options are wrapped around the built in embedded event manager. The embedded event manager, or EEM for short, can track a number of sources including the syslog, SNMP, timers, counters and more. These are called event detectors. When an event is detected a policy can be trigged and some action taken. These actions can be informational or active in nature including steps such as sending an email alerts, generating a custom syslog message, dumping system information to a file or even the ability to change system configuration with CLI commands. All of these components get grouped together in an “applet”. Let’s take a look by example.

Let’s create a basic EEM applet to monitor for a syslog event and take a simple action.

event manager applet AUTO_SAVE
 event syslog pattern "SYS-5-CONFIG_I: Configured from console by"
 action 1.0 cli command "enable"
 action 1.1 cli command "wr"

The first line is the top level command used to name the applet. “AUTO_SAVE” is the name I went with… Go with something descriptive. This applet is designed to automatically save the running configuration to the startup configuration.

Next, we know that after a configuration changed a syslog message is generated indicating so. You see the “event syslog pattern” matches on the message that’s generated. When this condition hits the following actions are taken. As you can see, the actions are fairly intuitive. CLI commands are called to enter enable mode and then issue the “write” command completing the configuration save.

For some official Cisco documentation take a look at this white paper to help you get started:

http://www.cisco.com/c/en/us/products/collateral/ios-nx-os-software/ios-embedded-event-manager-eem/config_guide_eem_configuration_for_cisco_integrated_services_router_platforms.html

 

This entry was posted in Networking and tagged , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *