cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1343
Views
0
Helpful
1
Replies

EEM and TCL to Keep Track of Unused Ports

psullivan1984
Level 1
Level 1

I am looking for a way to keep track of unused ports so we can proactively install switches as data closets near capacity. I've implement's Joe Clarke's EEM policy with TCL scripts to disable unused ports after a specified period of time. I would like to add logic into the current "tm_suspend_ports.tcl" script to do the following:

1) get a total count of ports on the switch using "show interfaces status | ex DO NOT DISABLE" or similar; some way to determine all the available ports.

2) get a count of disabled ports using "show interfaces status | in disabled" and store the results to a different variable or similar; some way to determine all administratively disabled ports

(Possible combine steps 1 and 2 into a single step / clause?)

3) Take a percentage of disabled vs. total; quantity would equal the percentage of available ports

4) If the percentage is less than 10 percent - send an SNMP trap and/or generate a SYSLOG message with the word "CRITICAL"; the alerts will be collected by the NOC and a technician can be dispatched to add a switch to the stack. 

5) If the percentage is less than 20 percent - send an SNMP trap and/or generate a SYSLOG message with the word "WARNING"; 

I am in the process of learning TCL but unfortunately my timeline for the project is up and I need some help.

1 Reply 1

Joe Clarke
Cisco Employee
Cisco Employee

Here is some Tcl code that should do what you want.

set total_cnt [llength [split [run_cli [list "show int status | ex DO NOT DISABLE"]] "\n"]]
set disabled_cnt [llength [split [run_cli [list "show int status | inc disabled"]] "\n"]]
set perc [expr ( ${disabled_cnt}.0 / ${total_cnt}.0 ) * 100.0]
if { $perc < 20.0 } {
    action_syslog msg "WARNING"
}