VMware Cloud Community
bklynjae
Contributor
Contributor

Dumping CDP info into a Report

Hi All,

Is there a way to dump the reported CDP info either into a doc or spreadsheet? Im looking to put together a report with all of our pertinent info in it..

Thank you,

0 Kudos
3 Replies
lamw
Community Manager
Community Manager

You can use this vSphere SDK for Perl cdp.pl to do so. The script allows you to specify a particular cluster, datacenter, host or vCenter and generates an html report.

Here is an example usage:

./cdp.pl --server [esx_or_esxi_or_vcenter_server_hostname] --username [USERNAME] --type [cluster|datacenter|vcenter|host]

Here is an example of running it against vCenter for all hosts:

./cdp.pl --server [esx_or_esxi_or_vcenter_server_hostname] --username [USERNAME] --type vcenter

Here is an example of running it against vCenter for a specific cluster/datacenter:

./cdp.pl --server [esx_or_esxi_or_vcenter_server_hostname] --username [USERNAME] --type cluster --cluster [CLUSTERNAME]

I'm sure there is an equivalent using PowerCLI but you'll need to wait for someone who is familiar with that tool for the snippet

0 Kudos
Virtualinfra
Commander
Commander

refer the below KB article.

Http://kb.vmware.com/kb/1007069

CDP information via PowerCLI

For more information, see VMware vSphere PowerCLI.

To display CDP information using PowerCLI:

  1. Using PowerCLI, connect to the ESX host or vCenter Server:

    Connect-VIServer <esxorvchostname>


  2. Run this script in PowerCLI:

    Get-VMHost | Where-Object {$_.State -eq "Connected"} |
    %{Get-View $_.ID} |
    %{$esxname = $_.Name; Get-View $_.ConfigManager.NetworkSystem} |
    %{ foreach($physnic in $_.NetworkInfo.Pnic){
        $pnicInfo = $_.QueryNetworkHint($physnic.Device)
        foreach($hint in $pnicInfo){
          Write-Host $esxname $physnic.Device
          if( $hint.ConnectedSwitchPort ) {
            $hint.ConnectedSwitchPort
          } else {
            Write-Host "No CDP information available."; Write-Host
          }
        }
      }
    }


  3. The CDP information for each physical network interface on each connected ESX host is displayed. For example:

    esxhostname vmnic0
    CdpVersion       : 2
    Timeout          : 0
    Ttl              : 177
    Samples          : 54732
    DevId            : example-lab-b2-c02
    Address          : 10.11.12.254
    PortId           : GigabitEthernet1/0/7     <<< Switch Port ID >>>
    DeviceCapability : VMware.Vim.PhysicalNicCdpDeviceCapability
    SoftwareVersion  : Cisco IOS Software, C3750 Softw
    HardwarePlatform : cisco WS-C3750G-24TS-1U
    IpPrefix         : 0.0.0.0
    IpPrefixLen      : 0
    Vlan             : 1          <<< VLan ID >>>
    FullDuplex       : True
    Mtu              : 0
    SystemName       :
    SystemOID        :
    MgmtAddr         : 10.11.12.254
    Location         :

CDP information via the ESX command line

To view CDP information using the ESX command line:

  1. Log in into ESX via SSH or console as root.
  2. Run this command:

    For ESX – vmware-vim-cmd hostsvc/net/query_networkhint

    For ESXi – vim-cmd hostsvc/net/query_networkhint

    Note: Log in to the ESXi host at the console. For more information, see Tech Support Mode for Emergency Support (1003677).

  3. The CDP information for each physical network interface on each connected ESX host is displayed. For example:

    (vim.host.PhysicalNic.NetworkHint) [
       (vim.host.PhysicalNic.NetworkHint) {
          dynamicType = <unset>,
          device = "vmnic3",
          subnet = (vim.host.PhysicalNic.NetworkHint.IpNetwork) [
             (vim.host.PhysicalNic.NetworkHint.IpNetwork) {
                dynamicType = <unset>,
                vlanId = 0,
                ipSubnet = "10.21.4.1-10.21.7.254",
             }
          ],
          connectedSwitchPort = (vim.host.PhysicalNic.CdpInfo) null,
       },
       (vim.host.PhysicalNic.NetworkHint) {
          dynamicType = <unset>,
          device = "vmnic1",
          subnet = (vim.host.PhysicalNic.NetworkHint.IpNetwork) [
             (vim.host.PhysicalNic.NetworkHint.IpNetwork) {
                dynamicType = <unset>,
                vlanId = 0,
                ipSubnet = "10.21.3.1-10.21.3.15",
             }
          ],
          connectedSwitchPort = (vim.host.PhysicalNic.CdpInfo) {
             dynamicType = <unset>,
             cdpVersion = 0,
             timeout = 0,
             ttl = 169,
             samples = 2982,
             devId = "PA-3210-2-R15-SW1",
             address = "10.21.10.115",
             portId = "GigabitEthernet1/0/7",     <<< Switch Port ID >>>
             deviceCapability = (vim.host.PhysicalNic.CdpDeviceCapability) {
                dynamicType = <unset>,
                router = false,
                transparentBridge = false,
                sourceRouteBridge = false,
                networkSwitch = true,
                host = false,
                igmpEnabled = true,
                repeater = false,
             },
             softwareVersion = "Cisco IOS Software, C3750 Softw",
             hardwarePlatform = "cisco WS-C3750G-48TS",
             ipPrefix = "0.0.0.0",
             ipPrefixLen = 0,
             vlan = 3,                        <<< VLan ID >>>
             fullDuplex = true,
             mtu = 0,
             systemName = "",
             systemOID = "",
             mgmtAddr = "10.21.10.115",
             location = "",
          },
       }, 
Thanks & Regards Dharshan S VCP 4.0,VTSP 5.0, VCP 5.0
0 Kudos
sajitnair
Contributor
Contributor

I guess this is what you would want. It dumps the info neatly into a xls file. I could not make the DeviceCapability ($hint.ConnectedSwitchPort.deviceCapability) info to be populated as it gave an error. But everthing else is gathered.

Another good script is at http://www.virtu-al.net/2008/12/12/detailed-vmware-host-network-information/

0 Kudos