03-22-2018 08:45 AM - edited 03-01-2019 06:29 PM
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
Solved! Go to Solution.
03-26-2018 07:02 AM
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.
03-23-2018 01:50 AM
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 ...".
03-23-2018 06:54 AM
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.
03-23-2018 07:09 AM
That's all you need provided you have not set the suspend_quarantine_vlan environment variable.
03-26-2018 05:38 AM
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.
03-26-2018 07:02 AM
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.
03-26-2018 07:09 AM
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
03-26-2018 08:29 AM
Yes, those commands will load the current on-flash revision.
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