Shutdown Ports Script

Answered Question
Sep 29th, 2009
User Badges:

I'm using the TCL scripts that Joe Clarke produced in the conversation on shutting down unused ports from Aug 25. It appears like the script is running, and it even produces the susp_ports.dat file, but none of the ports are shut down. I tried it by setting the suspend_ports_days variable to 2 days, but after 4 days no ports have been shut down. Any suggestions?




Attachment: 
Correct Answer by Joe Clarke about 7 years 6 months ago

Found the problem. This version should fix that problem.



  • 1
  • 2
  • 3
  • 4
  • 5
Overall Rating: 5 (2 ratings)
Loading.
Joe Clarke Tue, 09/29/2009 - 07:42
User Badges:
  • Cisco Employee,
  • Hall of Fame,

    Founding Member

Can you post your exact version of IOS, and the exact script you're using?

Joe Clarke Tue, 09/29/2009 - 09:27
User Badges:
  • Cisco Employee,
  • Hall of Fame,

    Founding Member

Post the output of:


show run | inc event manager environment

breisinger Tue, 09/29/2009 - 09:39
User Badges:

event manager environment suspend_ports_days 2

event manager environment suspend_ports_config flash:/susp_ports.dat


Joe Clarke Tue, 09/29/2009 - 09:51
User Badges:
  • Cisco Employee,
  • Hall of Fame,

    Founding Member

Okay, you have the policies configured to shutdown ports which have been operationally down for 2 days. But in the config file, these ports have only been down since 9/29 09:50:00. So they would need to still be down on 10/1 at 09:50:00 before they are shutdown.

breisinger Tue, 09/29/2009 - 10:04
User Badges:

I had the policy start at 00:00 on 9/26 and it has ran every day at midnight since then. Today when there were still no port shut down, I changed the cron time to 8:50 and ran it again to see if there would be some kind of error message to help troubleshoot. So, the policy has ran 5 times now, with no ports shutdown.

Joe Clarke Tue, 09/29/2009 - 10:27
User Badges:
  • Cisco Employee,
  • Hall of Fame,

    Founding Member

Ugh, I had a typo which I never noticed as I was catching the error. This new version should work for you.



breisinger Tue, 09/29/2009 - 10:57
User Badges:

Thanks, I'll give it a try and let you know the result.

breisinger Thu, 10/01/2009 - 04:37
User Badges:

The script ran, and there are syslog messages indicating that the ports were shutdown, but they are still enabled.



Attachment: 
breisinger Thu, 10/01/2009 - 10:56
User Badges:

It looks like there is something in the script that the cli doesn't like. I turned on debug and ran the script, then advanced the clock 2 days and ran it again. The debug shows that it's trying to run "{interface FastEthernet0/1} shut" with the braces and the command is rejected. This is in lines 152 and 165 of the attachment.



Attachment: 
Joe Clarke Thu, 10/01/2009 - 10:58
User Badges:
  • Cisco Employee,
  • Hall of Fame,

    Founding Member

Yeah, I have the analysis on my todo list. I should have some time to analyze the code in a little while. I'll post another update.

Actions

This Discussion