|
This new script is for Network Engineers and System Engineers a like. Though I must admit it is more for the System Engineers who do not have access to the command line on the CDP enabled device. Have you ever wanted to know what CDP enabled devces ( and info related to those devices ) that were directly connected to your your Core Switch? But you just do not have the access to get that info. But you do have access to the monitoring system, which has SNMP access to the Core Switch.
Well this is where my script comes into play... Stay tuned for updates, as I'm planning on adding to this script. So you can run it with the detail option and a detail port option. Please post any support related question in the forums here..http://www.linuxdynasty.org/forums/Scripting/scripting/sh_cdp_neighbor_help
Revision 1.2 9/13/2009
- Catch all CDP connected switches, even if there is more then 1 switch seen through 1 port.
Revision 1.1 9/11/2009
- Added --type option ( --type=detail )
Revision 1.0 9/10/2009
- This script is the equivalent of sho cdp nei on a cisco switch, but this is using snmp.
When you log into a switch and run a show cdp neighbor, your info might look a little like this..
show cdp neighbor Capability Codes: R - Router, T - Trans Bridge, B - Source Route Bridge S - Switch, H - Host, I - IGMP, r - Repeater, P - Phone Device ID Local Intrfce Holdtme Capability Platform Port ID 71_5th_SW1 Gig 10/15 145 S I WS-C2960G-Gig 0/48 D_M1001_V180_SW1 Gig 1/42 132 S I WS-C2960G-Gig 0/1 D_M1001_V181_SW1 Gig 1/46 136 S I WS-C2960G-Gig 0/1 D_M1001_V181_SW2 Gig 1/47 166 S I WS-C2960G-Gig 0/1 D_M1001_V180_SW3 Gig 1/43 147 S I WS-C2960G-Gig 0/1 D_M1001_V181_SW3 Gig 1/48 158 S I WS-C2960G-Gig 0/1 D_M1001_V180_SW2 Gig 1/41 141 S I WS-C2960G-Gig 0/1 D_M1001_V181_SW4 Gig 1/44 179 S I WS-C2960G-Gig 0/1 D_M1001_V180_SW4 Gig 1/40 145 S I WS-C3560G-Gig 0/1 D_M701_V177_SW4 Gig 10/7 174 S I WS-C2970G-Gig 0/25 D_M701_V177_SW1 Gig 10/6 154 S I WS-C2970G-Gig 0/25 Router Gig 10/1 162 R S WS-C6513 Gig 9/9 Router1 Gig 10/14 168 R S WS-C6513 Gig 9/16 79_18th_Fl_SW1 Gig 10/12 174 S I WS-C2960G-Gig 0/48 D_1700_V187_SW1 Gig 10/13 129 S I WS-C3560G-Gig 0/28 D_1700_V187_SW3 Gig 10/10 146 S I WS-C2960G-Gig 0/48 D_1700_V187_SW2 Gig 10/9 148 S I WS-C2960G-Gig 0/48 D_522_V176_SW1 Gig 10/3 121 S I WS-C2970G-Gig 0/25 D_522_V176_SW4 Gig 10/4 125 S I WS-C2970G-Gig 0/25 D_CL001_V200_SW1 Gig 10/11 125 S I WS-C2960G-Gig 0/24 2W_4507R Gig 7/2 147 R S I WS-C4507R Gig 3/9
Now this is how it will look if you run sh_cdp_neighbor.py script...
python sh_cdp_neighbor.py -d 192.168.1.1 -c public Capability Codes: R - Router, T - Trans Bridge, B - Source Route Bridge S - Switch, H - Host, I - IGMP, r - Repeater, P - Phone Device ID Local Interface Capability Platform Remote Interface D_M1001_V181_SW3 Gi1/48 S I cisco WS-C2960G-48TC-L GigabitEthernet0/1 Router1 Gi10/14 R S cisco WS-C6513 GigabitEthernet9/16 D_M1001_V181_SW1 Gi1/46 S I cisco WS-C2960G-48TC-L GigabitEthernet0/1 D_M1001_V181_SW2 Gi1/47 S I cisco WS-C2960G-48TC-L GigabitEthernet0/1 D_M1001_V181_SW4 Gi1/44 S I cisco WS-C2960G-48TC-L GigabitEthernet0/1 D_M1001_V180_SW1 Gi1/42 S I cisco WS-C2960G-48TC-L GigabitEthernet0/1 D_M1001_V180_SW3 Gi1/43 S I cisco WS-C2960G-48TC-L GigabitEthernet0/1 D_M1001_V180_SW4 Gi1/40 S I cisco WS-C3560G-24PS GigabitEthernet0/1 D_M1001_V180_SW2 Gi1/41 S I cisco WS-C2960G-48TC-L GigabitEthernet0/1 71_5th_SW1 Gi10/15 S I cisco WS-C2960G-48TC-L GigabitEthernet0/48 2W_4507R Gi7/2 R S I cisco WS-C4507R GigabitEthernet3/9 D_1700_V187_SW2 Gi10/9 S I cisco WS-C2960G-48TC-L GigabitEthernet0/48 D_CL001_V200_SW1 Gi10/11 S I cisco WS-C2960G-24TC-L GigabitEthernet0/24 D_1700_V187_SW3 Gi10/10 S I cisco WS-C2960G-48TC-L GigabitEthernet0/48 D_1700_V187_SW1 Gi10/13 S I cisco WS-C3560G-24PS GigabitEthernet0/28 79_18th_Fl_SW1 Gi10/12 S I cisco WS-C2960G-48TC-L GigabitEthernet0/48 D_522_V176_SW1 Gi10/3 S I cisco WS-C2970G-24TS-E GigabitEthernet0/25 Router Gi10/1 R S cisco WS-C6513 GigabitEthernet9/9 D_M701_V177_SW1 Gi10/6 S I cisco WS-C2970G-24TS-E GigabitEthernet0/25 D_M701_V177_SW4 Gi10/7 S I cisco WS-C2970G-24TS-E GigabitEthernet0/25 D_522_V176_SW4 Gi10/4 S I cisco WS-C2970G-24TS-E GigabitEthernet0/25
As you can see I was able to get about 99% of what the command line version of show cdp neighbor was able to retrieve. Here is another example of the newest feature.....
python sh_cdp_neighbor.py -d 192.168.1.1 -c public --type=detail ------------------------------ Device ID: Network_5 Entry address(es): IP address: 192.186.1.15 Platform: cisco WS-C2950T-24, Capabilities: S I Interface: Gi3/16, Port ID (outgoing port): GigabitEthernet0/1 Version : Cisco Internetwork Operating System Software IOS (tm) C2950 Software (C2950-I6K2L2Q4-M), Version 12.1(22)EA11, RELEASE SOFTWARE (fc2) Copyright (c) 1986-2008 by cisco Systems, Inc. Compiled Tue 08-Jan-08 11:12 by amvarma VTP Management Domain: test Duplex: fullDuplex Management address(es): IP address: 192.186.1.15
------------------------------
------------------------------ Device ID: I_811_V53_SW1 Entry address(es): IP address: 192.186.1.16 Platform: cisco WS-C2970G-24TS-E, Capabilities: S I Interface: Gi9/1, Port ID (outgoing port): GigabitEthernet0/25
As you can see I was able to get about 99% of what the command line version of show cdp neighbor detail was able to retrieve.
You will need the two python modules to run this script. which are pysnmp and pyasn1. To make your life easier you should do the following...
- install python-setuptools
- then run easy_install pysnmp
- and easy_install pyasn1
- or you can download the 2 modules manually.
pysnmp and pyasn1
- then unzip the 2 files and in each directory run python setup.py install
I am using the following revisions from the python cheese shop pysnmp 4.1.7a and pyasn1 0.0.6
You can download the script here... sho_cdp_neighbor.py
|