06-18-2021 03:59 AM
Hey.
I would like make a EEM script of sorts to i.e. shutdown all interfaces in a vlan. Say vlan 101 for instance.
My thought process would be to display all the ports in a vlan with for examples:
show vlan id 101
or
show vlan brief | sec 101
where I would then take all those interfaces one by one(looping through them) and do a shutdown on them.
But I can't quite figure out how to make a list of variables with all the interfaces to go through them one after the other to the shutdown command.
I imagine this being quite easy with a python script, but I would like to have an EEM command I can launch on any switch to do the shutdowns for me.
any help is appreciated
06-18-2021 04:09 AM
You can certainly achive this out of the box with Python scipting.
can yo explain what is the mean of Looping :
where I would then take all those interfaces one by one(looping through them) and do a shutdown on them.
You can sort interface belong to VLAN, make List UP ports and Down Ports.
check the down ports - make sure there is never up, or user might have disconnected for temporatly, you can do based on the traffic on the port when was the last time it seen the traffic (but shutdown you see otehr admin issue to unshut the port with user complaints)
06-18-2021 04:17 AM
When I use "show vlan id 101" it will give me a list of all "Gi0/X" interfaces in that vlan. I would like to through all those Gi0/X interfaces to do a shutdown on them all, one at a time. Normally I would achieve this by putting them in an array/list in another scripting language and doing the shutdown command inside each iteration of the loop. It does not matter if the ports are up or down for me.
06-18-2021 05:02 AM
You can use below example start build script :
http://pennington.net/tutorial/ciscoconfparse/ccp_tutorial.html#slide7
https://pubhub.devnetcloud.com/media/pyats/docs/aetest/examples.html
06-21-2021 01:32 AM
I would like to make it with EEM, and not Python etc. The idea is to have the EEM script ready available on a switch for when I need to launch it.
06-21-2021 02:28 AM
Same process will work on your EEM Script, the concept is same, get VLAN associated interace and shutdown the ports .
some time EEM alone can not do what you looking, so in this case you may need TCL.
here is start with :
https://www.cisco.com/c/en/us/products/ios-nx-os-software/ios-embedded-event-manager-eem/index.html
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