SCRIPTING HELP NEEDED - ALL INPUT IS HELPFUL
I have an alert that lets me know when an interface hasn't been used in over 30 days. Currently, we are manually configuring these interfaces into shutdown ports. I want an NCM action to do this for us as we have found no exceptions to the policy so far. I need to script the actions to impact only the specific interface on the specific node from the alert. Here are my desired results:
Active Alert Details - Interface is down - on [interface number] - [interface alias] - on [switch hostname]
Alert Action
Execute an NCM Action
Execute a Script
config t
default int gi[interface number]
int gi[interface number]
description SHUTDOWN
shut
end
wr mem
Alternatively, I think you can identify the interface based on the alias and then configure it from there but that seems like a really roundabout way of solving the problem.
Additionally, I want to stop monitoring the interface after the action has been completed. And I would like give it user interface configs with a variable voice vlan depending on the [switch hostname] or copying it over from a different user interface when it is alerted on a L2 switch. I think something like this could work:
all_int_conf_lines = sh run | section interface
user_conf_lines = all_int_conf_lines(from "description USER ACCESS PORTS", before "interface")
default int [interface number]
int [interface number]
user_conf_lines
shut
no shut
end
wr mem
DELETE from [switch hostname] where interface_alias = "[interface alias]"
I know it's not even code but hopefully it gets my idea across for how a script like this might be possible.
USE CASE:
If someone moved a trunk to a new interface during troubleshooting and forgot to reconfigure the old interface that is no longer in use, this would fix the mistake for them
This will also unlock the possibility of comparing the interface alias to the results from "show lldp neighbors" or identifying vlan assignments of interfaces to automate interface descriptions