EEM Scripts

Deny switchport trunk allowed vlan N

Applet allows only switchport trunk allowed vlan add|remove VLAN_IDbut denies switchport trunk allowed vlan VLAN_ID thus it can help you with this often mistake.

event manager applet DENY-SWITCHPORT-TRUNK-ALLOWED-VLAN
 event cli pattern "switchport trunk allowed vlan [0-9]+" sync no skip yes
 action 1.0 puts "==> Command execution aborted. Add or remove keywords are required."
circle-exclamation

Action in interface shutdown example

event manager applet monitorShutdown
 descriptionMonitors interface shutdown.”
 event cli match “conf t; interface *; shutdown
 action 1.0 cli show interface e 3/1
 copy running-config startup-config

Watch Loopback state

event manager applet WatchLo0
 event syslog pattern "Interface Loopback0.* down" period 1
 action 2.0 cli command "enable"
 action 2.1 cli command "config t"
 action 2.2 cli command "interface lo0"
 action 2.3 cli command "no shutdown"
 action 3.0 syslog msg "Interface Loopback0 was brought up via EEM"

Catch CLI commands and log them

Last updated