cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2725
Views
0
Helpful
7
Replies

Adding port description in the TCL script

VRizk
Level 1
Level 1

My goal is to get this TCL file Joe Clarke wrote to not only shutdown not connected ports after x amount of days but to also put a description signifying the port was shutdown due to this script. I've been messing around with the script and can't seem to get it to do this. Is there an easy way to add it in ? I assume the modification would be in the tm_suspend_ports not the sl_suspend_ports file

1 Accepted Solution

Accepted Solutions

After you made the modification, did you re-register the policy?  you have to unconfigure it, and then reconfigure it in order for the changes to take effect.

View solution in original post

7 Replies 7

Joe Clarke
Cisco Employee
Cisco Employee

The section of code that modifies the config is the following:

set cli [list "config t"]

foreach port [array name suspend_ports] {

    if { [info exists suspend_quarantine_vlan] } {

        set cli [concat $cli [list "interface $port" "switchport access vlan $suspend_quarantine_vlan"]]

        action_syslog msg "Moving port $port into quarantine VLAN $suspend_quarantine_vlan since it was last used on [clock format $suspend_ports($port)]"

    } else {

        set cli [concat $cli [list "interface $port" "shut"]]

        action_syslog msg "Shutting down port $port since it was last used on [clock format $suspend_ports($port)]"

    }

}

So just add on to the list any additional config you want.  For example, add "description FOO" as another item after "shut" or the "switchport access vlan ...".

Thanks for the reply Joe! I tried that before making this post but I only put it in one spot, should I put it in both? This is what I did which I colored in red:

 

set cli [list "config t"]
foreach port [array name suspend_ports] {
    if { [info exists suspend_quarantine_vlan] } {
        set cli [concat $cli [list "interface $port" "switchport access vlan $suspend_quarantine_vlan"]]
        action_syslog msg "Moving port $port into quarantine VLAN $suspend_quarantine_vlan since it was last used on [clock format $suspend_ports($port)]"
    } else {
        set cli [concat $cli [list "interface $port" "shut""description SHUTDOWN PER POLICY"]]
        action_syslog msg "Shutting down port $port since it was last used on [clock format $suspend_ports($port)]"
    }
}

 

I am not defining suspend_quarantine_vlan so I put it after the else statement. Should that have worked? It ended up still shutting down the interfaces, but didn't add a description.

That's all you need provided you have not set the suspend_quarantine_vlan environment variable.

Not sure why it isn't working then. It shuts down the port still but skips the description part. I'll have to look into this further because I have it entered exactly as put above, didn't touch anything else.

After you made the modification, did you re-register the policy?  you have to unconfigure it, and then reconfigure it in order for the changes to take effect.

Ahhh no! Good catch! Is that just doing this in the switch CLI?

no event manager policy tm_suspend_ports.tcl
event manager policy tm_suspend_ports.tcl

Yes, those commands will load the current on-flash revision.

Review Cisco Networking for a $25 gift card