cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
704
Views
1
Helpful
4
Replies

EEM Applet Help

tony12
Level 1
Level 1

I am a beginner with EEM and would like some help with this applet. There are several syntax errors I connect figure out. I am trying to run a daily applet that will check for ports unused for 30 days+ to shut and remove any description.

Thank you for any help in advance.

 

event manager applet disable_ports
event timer cron name daily-cron-entry cron-entry "0 0 * * *"

action 0 cli command "enable"
action 1 cli command "show interfaces | include (up|admin)"
action 2 regexp "(\\S+) is (up|down)(.*Description: (.+))?" "$_cli_result" match interface status _ interface_description

action 3 set current_date [clock format [clock seconds] -format "%Y-%m-%d"]

action 4 foreach interface_index interface status interface_description {
action 4.0 if {$interface_description ne ""} {
action 4.1 set last_change [exec "show interfaces $interface_index | include Last input"]
action 4.2 regexp "Last input (\d+)w\d+d ago" "$last_change" match weeks_ago

action 4.3 if {$weeks_ago > 30} {
action 4.4 cli command "configure terminal"
action 4.5 cli command "interface $interface_index"
action 4.6 cli command "shutdown"
action 4.7 cli command "no description"
action 4.8 cli command "end"
action 4.9 syslog msg "Interface $interface_index has been disabled and description cleared due to inactivity for more than 30 days."
action 4.10 }
action 4.11 }
action 4.12 }

1 Accepted Solution

Accepted Solutions

Hello,

this script looks like it is generated by...AI ? Either way, it doesn't work. There is a very good TCL script available written by @Joe Clarke , here is the link to the post:

https://community.cisco.com/t5/network-management/eem-script-is-not-removing-the-disable-port-from-suspend-port/td-p/2359996

View solution in original post

4 Replies 4

Hello,

this script looks like it is generated by...AI ? Either way, it doesn't work. There is a very good TCL script available written by @Joe Clarke , here is the link to the post:

https://community.cisco.com/t5/network-management/eem-script-is-not-removing-the-disable-port-from-suspend-port/td-p/2359996

Thank you for pointing me in the right direction. I will try this script.

Hello,

If you have never run a TCL script from flash, the process might be a bit confusing. Let us know if you need any help. Basically  you need to copy the TCL script to the device flash, then configure environment variables (two in this case) , then wrap it into an EEM script with a cron timer.

balaji.bandi
Hall of Fame
Hall of Fame

If this is only 1 switch that is to look EEM/TCL  Script, but how frequent you want to run on box ?

again if you looking 30days, you run the script everyday once's ?

in this case if you have multiple switches, i would run python script on other box connecting to all switches and screen and shutdown the ports.

BB

***** Rate All Helpful Responses *****

How to Ask The Cisco Community for Help