show cdp global

show cdp global
import requests
import json
 
"""
Modify these please
"""
url='http://<ip_address>:<port_number>/ins''
switchuser='<user_id>'
switchpassword='<password>'
 
myheaders={'content-type':'application/json'}
payload={
"ins_api":{
  "version": "1.0",
  "type": "cli_show",
  "chunk": "0",
  "sid": "1",
  "input": "show cdp global",
  "output_format": "json"
  }
} 
response = requests.post(url,data=json.dumps(payload), headers=myheaders,auth=(switchuser,switchpassword)).json()
output = json.dumps(response, indent=4, sort_keys=True)

json_output = json.loads(output)["ins_api"]["outputs"]["output"]["body"]
print(json.dumps(json_output, indent=4, sort_keys=True))
{
    "cdp_global_enabled": "enabled",
    "deviceid_format": "DeviceID TLV in System-Name(Default) Format",
    "refresh_time": 60,
    "ttl": 180,
    "v2_advertisement": "enabled"
}
    <cdp_global_enabled>enabled</cdp_global_enabled>
    <refresh_time>60</refresh_time>
    <ttl>180</ttl>
    <v2_advertisement>enabled</v2_advertisement>
    <deviceid_format>DeviceID TLV in System-Name(Default) Format</deviceid_format>
      

The show cdp global command displays the global Cisco Discovery Protocol ( CDP ) Parameters. For command descriptions, see the Cisco MDS 9000 Series Switches Command References.

Note: This sample output is generated for Cisco MDS 9000 Series NX-OS Release 8.4(2a) or later.

CLI Output
switch# show cdp global

Global CDP information:
CDP enabled globally
Refresh time is 60 seconds
Hold time is 180 seconds
CDPv2 advertisements is enabled
DeviceID TLV in System-Name(Default) Format
ParameterDescriptionTypeSample Values
refresh_timeCisco Discovery Protocol ( CDP ) refresh time interval (in seconds). Specifies how often the Cisco software sends Cisco Discovery Protocol updatesInteger['5-254']
ttlCDP hold time advertisement. The amount of time until it retains the data (in seconds)Integer['10-255']
cdp_global_enabledCDP global status for all interfacesString['enabled', 'disabled']
v2_advertisementCDP version 2 advertisement statusString['enabled', 'disabled']
deviceid_format Device ID format for CDPString

show cdp neighbors

show cdp neighbors
import requests
import json
 
"""
Modify these please
"""
url='http://<ip_address>:<port_number>/ins'
switchuser='<user_id>'
switchpassword='<password>'
 
myheaders={'content-type':'application/json'}
payload={
"ins_api":{
  "version": "1.0",
  "type": "cli_show",
  "chunk": "0",
  "sid": "1",
  "input": "show cdp neighbors",
  "output_format": "json"
  }
} 
response = requests.post(url,data=json.dumps(payload), headers=myheaders,auth=(switchuser,switchpassword)).json()
output = json.dumps(response, indent=4, sort_keys=True)

json_output = json.loads(output)["ins_api"]["outputs"]["output"]["body"]
print(json.dumps(json_output, indent=4, sort_keys=True))
{
    "TABLE_cdp_neighbor_brief_info": {
        "ROW_cdp_neighbor_brief_info": {
            "capability": [
                "switch",
                "IGMP_cnd_filtering"
            ],
            "device_id": "SW-JWALA-ECBU-JJ22",
            "interface": "mgmt0",
            "platform_id": "cisco WS-C2960S-48TS-L",
            "port_id": "GigabitEthernet1/0/29",
            "ttl": 124
        }
    },
    "neigh_count": 1
}
    <TABLE_cdp_neighbor_brief_info>
      <ROW_cdp_neighbor_brief_info>
        <device_id>SW-JWALA-ECBU-JJ22</device_id>
        <interface>mgmt0</interface>
        <ttl>123</ttl>
        <capability>switch</capability>
        <capability>IGMP_cnd_filtering</capability>
        <platform_id>cisco WS-C2960S-48TS-L</platform_id>
        <port_id>GigabitEthernet1/0/29</port_id>
      </ROW_cdp_neighbor_brief_info>
    </TABLE_cdp_neighbor_brief_info>
    <neigh_count>1</neigh_count>
       

The show cdp neighbors command displays all the Cisco Discovery Protocol ( CDP ) neighbours. For command descriptions, see the Cisco MDS 9000 Series Switches Command References.

Note: This sample output is generated for Cisco MDS 9000 Series NX-OS Release 8.4(2a) or later.

CLI Output
switch# show cdp neighbors

Capability Codes: R - Router, T - Trans-Bridge, B - Source-Route-Bridge
S - Switch, H - Host, I - IGMP, r - Repeater,
V - VoIP-Phone, D - Remotely-Managed-Device,
s - Supports-STP-Dispute

Device-ID Local Intrfce Hldtme Capability Platform Port ID
SW-JWALA-ECBU-JJ22
mgmt0 124 S I WS-C2960S-48TS-L Gig1/0/29

Total entries displayed: 1
ParameterDescriptionTypeSample Values
ttlCDP hold time advertised. The amount of time until it retains the data (in seconds)Integer['10-255']
capabilityType of the device listed in the CDP neighbors tableString List['R - Router', ' T - Trans-Bridge', ' B - Source-Route-Bridge S - Switch', ' H - Host', ' I - IGMP', ' r - Repeater', ' V - VoIP-Phone', ' D - Remotely-Managed-Device', ' s - Supports-STP-Dispute']
interfaceLocal interface ID through which this neighbor is connectedString
device_id Name of the neighboring device, or the MAC address, or the serial number of the deviceString
port_idThe interface and port number of the neighboring deviceString
platform_idIdentifies the hardware platform for the transmitting deviceString
neigh_countNumber of neighboring devicesInteger