A customer wanted to modify all “trunking” interfaces description to add the CDP neighbor name to it.
Not a problem for NetMRI
- We run a show command to get all the Trunking interfaces
- Then run another show command to get the CDP details for all the trunking interfaces
- Once we have the CDP details, we will parse that looking for the neighbor name and add it to the interface description
This script will grab the CDP neighbor’s name and add it to the interface that it’s configured on.
Script-Filter:
$vendor eq "Cisco" and $sysdescr like /IOS/ ####################################################################### #
Action:
Execute Command Batch
Action-Commands:
sh int trunk | inc trunking
Output-Triggers:
Parse Output
####################################################################### #
Trigger:
Parse Output
Trigger-Variables:
#This regex finds the interfaces
$cdpport /((Gi|Fa)+\d+(\/\d{1,2}|\/\d{1,2}\/\d+|\/\d{1,2}\.\d+|\/\d{1,2}\:\d+)?|\w+-\w+\d{1,3})/
Trigger-Template:
[[$cdpport]]\s.+on\s.+802.1q\s.+trunking\s.+
Trigger-Commands:
sh cdp ne $cdpport
Output-Triggers:
Show CDP
#################### #
Trigger:
Show CDP
Trigger-Variables:
$cdpname /\w.+/
Trigger-Template:
Device.+[[$cdpname]]\..+\..+.+
Trigger-Commands:
DEBUG: conf t
DEBUG: int $cdpport
DEBUG: desc $cdpname
Now you can change the description to anything you choose not just CDP
Additional scripts can be found on our GitHub Repo