cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
4301
Views
20
Helpful
9
Replies

Auto port description update with Circuit ID's and other info

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 !

1 Accepted Solution

Accepted Solutions

As I said in my previous reply, I do not see a way to obtain this information.

View solution in original post

9 Replies 9

Joe Clarke
Cisco Employee
Cisco Employee

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]"

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 !!!

 

 

As I said in my previous reply, I do not see a way to obtain this information.

Can you help me understand the script in the below link of your old post,

https://supportforums.cisco.com/t5/network-infrastructure-documents/automatically-set-port-descriptions/ta-p/3119769

Tommy Vindvik
Tommy Vindvik Community Member
‎04-05-2013 03:40 AM
Improved even further, please comment and/or improve further:

Trim domain name - now with regexp
Verifiy switch or router remote end. I don't want this script to update decription on AP's and so on.
Do not update description if remote host and interface is unchanged. This will retain additional information in description like circuit id, vendor and so on even after a link failure
If description is changed, show old description in syslog message
regexp in the event are for the uplink module on 3750-X/3560-X, adapt to your own need.

event manager applet auto-update-port-description authorization bypass
description "Auto-update port-description based on CDP neighbors info"
action 0.0 comment "Event line regexp: Deside which interface to auto-update description on"
event neighbor-discovery interface regexp .*GigabitEthernet[1-9]/1/[1-4]$ cdp add

action 1.0 comment "Verify CDP neighbor to be Switch or Router"

action 1.1 regexp "(Switch|Router)" $_nd_cdp_capabilities_string

action 1.2 if $_regexp_result eq 1

action 2.0 comment "Trim domain name"

action 2.1 regexp "^([^\.]+)\." $_nd_cdp_entry_name match host

action 3.0 comment "Convert long interface name to short"

action 3.1 string first "Ethernet" "$_nd_port_id"

action 3.2 if "$_string_result" eq 7

action 3.21 string replace "$_nd_port_id" 0 14 "Gi"

action 3.3 elseif "$_string_result" eq 10

action 3.31 string replace "$_nd_port_id" 0 17 "Te"

action 3.4 elseif "$_string_result" eq 4

action 3.41 string replace "$_nd_port_id" 0 11 "Fa"

action 3.5 end

action 3.6 set int "$_string_result"

action 4.0 comment "Check old description if any, and do no change if same host:int"

action 4.1 cli command "enable"

action 4.11 cli command "config t"

action 4.2 cli command "do show interface $_nd_local_intf_name | incl Description:"

action 4.21 set olddesc "<none>"

action 4.22 set olddesc_sub1 "<none>"

action 4.23 regexp "Description: ([a-zA-Z0-9:/\-]*)([a-zA-Z0-9:/\-\ ]*)" "$_cli_result" olddesc olddesc_sub1

action 4.24 if "$olddesc_sub1" eq "$host:$int"

action 4.25 syslog msg "EEM script did NOT change desciption on $_nd_local_intf_name, since remote host and interface is unchanged"

action 4.26 exit 10

action 4.27 end

action 4.3 cli command "interface $_nd_local_intf_name"

action 4.4 cli command "description $host:$int"

action 4.5 cli command "do write"

action 4.6 syslog msg "EEM script updated description on $_nd_local_intf_name from $olddesc to Description: $host:$int and saved config"

action 5.0 end

action 6.0 exit 1
Description would be something like: my-test-sw:Gi1/1/1 instead of my-test-sw.my.domain.name:GigabitEthernet1/1/1

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.

I was just curious about the words of that author,

" This will retain additional information in description like circuit id, vendor and so on even after a link failure
If description is changed, show old description in syslog message"

Leaving them aside. How can I add a static circuit ID for a particular interface alone manually.

Shall I go in to the particular interface and add the circuit ID. I think that may fade away in the next CDP discovery.

Is there any other way you could suggest me ?

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

Regards, Tommy V

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

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"

Review Cisco Networking for a $25 gift card