02-16-2018 02:40 AM - edited 03-01-2019 06:24 PM
This script provides neighbor device name and local port connected in the interface description:
event manager applet update-port-description
event neighbor-discovery interface regexp GigabitEthernet.* cdp add
action 1.0 cli command "enable"
action 2.0 cli command "config t"
action 3.0 cli command "interface $_nd_local_intf_name"
action 4.0 cli command "description $_nd_cdp_entry_name:$_nd_port_id"
Output :
description SDCC_IDF_1.11:TenGigabitEthernet0/1
For example we have 24 Interfaces in a switch
1> Along with the above obtained output I need to add Circuit ID only in certain Interfaces.
Example :
switch 11 # sh int gi1/0/6 description
Desxcription : switch 12 : gi1/0/12 : Circuit ID 12345XXX
2> Along with this I need to add time of the latest description updated to this interface.
Example :
switch 11 # sh int gi1/0/6 description
Desxcription : switch 12 : gi1/0/12 : Circuit ID 12345XXX : 8:31:40 11 Feb 2018
Can Someone help me modifying the script !
Solved! Go to Solution.
02-16-2018 06:36 AM
As I said in my previous reply, I do not see a way to obtain this information.
02-16-2018 06:28 AM
I'm not sure how you'd obtain the circuit ID. This policy is designed to be completely automatic and obtain dynamic data that is available for each port. The circuit ID is more of a static thing, and has nothing to do with the CDP neighbor that is learned on the port.
The date and time is doable, however.
action 4.0 cli command "description $_nd_cdp_entry_name:$_nd_port_id [$_event_pub_time]"
02-16-2018 06:34 AM
Thank you so much for the reply Joe,
Can you please suggest me an idea for adding Circuit ID in the Description.
That time addition to the script was so helpful !!!
02-16-2018 06:36 AM
As I said in my previous reply, I do not see a way to obtain this information.
02-16-2018 06:45 AM
02-16-2018 08:23 AM
This policy applies modifies the description text a bit to achieve sorter overall descriptions. The author of the policy provided an example that shows the difference in the result between his and mine.
02-16-2018 08:30 AM
02-26-2018 06:46 AM
Hi,
In the script I have taken the assumption that if the remote end hostname and interface has not changed after a link down event, the script will NOT rewrite the description.
See action 4.2 - 4.27 in the script.
So any additional information you have entered manually in the description (behind host:int) will be retained for all future cdp updates given that the remote end host and interface does not change. This would be the case for a normal outage on the circuit or remote end.
We have the same need for circuit id's as you describe, and we just enter them manually once. Then they are retained.
If however the remote end hostname and/or interface changes, the script WILL rewrite the description.
My assumption here is that a remote end change usually means that the interface on the local switch is repurposed for a new use and thus a new circuit id.
I tinkered a bit with retaining the additional description even if remote end changed, but my conclusion was that for my need this could lead to more bad than good. Repurposed interfaced with a wrong circuit id, and so on.
Also tinkered with the idea of mailing our NOC if the script changed the description and there was any additional information, but we did not see the need for that function.
Hopes this explains.
Regards
Tommy V
07-10-2018 04:12 AM
My idea to add a static description (either Circuit ID or something else)
would be:
You add a description manually and make it finish with ":"
Then the script adds the automatic parts, only after the ":"
everything in front remains the same.
So you manually add:
int x
description LNK MPLS CID9854518:
and the scripts adds the rest:
description LNK MPLS CID9854518:SWITCHA:Te1/0/1
07-10-2018 02:13 PM
This is certainly doable. The simplest approach is to use the append action to add the dynamic data:
append descr "$device:$port"
To reset, use regexp to get the root:
regexp "(^[:]+:)" $descr match root
cli command "description $root"
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