02-02-2024 12:05 PM
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 }
Solved! Go to Solution.
02-02-2024 02:55 PM
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:
02-02-2024 02:55 PM
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:
02-05-2024 06:06 AM
Thank you for pointing me in the right direction. I will try this script.
02-05-2024 06:32 AM
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.
02-02-2024 03:39 PM
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.
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide