Cisco IOS Embedded Event Manager (EEM)

Hi Thomas,

Glad to hear you like it :slight_smile: Let’s take a closer look at this config:

event manager applet SHOW_RUN_NO_INTERFACES
event cli pattern “show run” sync yes
action 1.0 cli command “enable”
action 2.0 cli command “show run | exclude interface”
action 3.0 puts “$_cli_result”
action 4.0 set $_exit_status “0”

Let’s take a look at it line-by-line:

event cli pattern “show run” sync yes

We want to match the “show run” command so that’s out pattern. The “sync yes” part means that EEM will run before this command is executed.

action 1.0 cli command “enable”
action 2.0 cli command “show run | exclude interface”

These are the commands that we will run when we have a match for “show run”. We go to enable and then run “show run | exclude interface”.

action 3.0 puts “$_cli_result”

This line is required to print the output of the commands we run to the active TTY, we need it since we want to see the output of “show run | exclude interface”.

action 4.0 set $_exit_status “0”

The exit status determines if we want to run the command or not. If you set this to 0, then we don’t run the “show run” command. If you set it to 1 then it will run “show run”.

In our example, we don’t want the user to run “show run” but we want them to see “show run | exclude interface” instead. That’s why you need the 0, we need to prevent them from running “show run”. If you set it to 1 then “show run” will also be executed.

Does this help?

Rene

2 Likes