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,
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
refer the below KB article.
Http://kb.vmware.com/kb/1007069
For more information, see VMware vSphere PowerCLI.
To display CDP information using PowerCLI:
Connect-VIServer <esxorvchostname>
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
}
}
}
}
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 :
To view CDP information using the ESX command line:
(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 = "",
},
},
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/