Tuesday, July 9, 2013

vmware powercli Script to get the wwn of esxi5.x host in cluster

To get the all the wwn of the host in cluster use the below simple script.



#Input Cluster
$cluster = Read-Host "Enter Cluster name"
#will fetch the list of host in the cluster
$esxi = get-cluster -name $cluster | get-vmhost
#will get the wwn of host in the cluster,
Get-VMHostHba -VMHost $esxi| Select VMHost,Device,@{N="WWN";E={"{0:X}" -f $_.PortWorldWideName}}



copy this to a notepad and Save this as script_wwn.ps1 to any location and point to the location from  vmware powercli console and run the script , as follows.

it will ask for cluster name, enter the cluster name and output will be as follows;

VMHost                                            Device                                            WWN
------                                            ------                                            ---
ESX01                                       vmhba0                                            218000E08B000186
ESX01                                       vmhba1                                            218100E08B200186

VMware Powercli command to get the esxi5.x host wwn number

Take VMware powercli console and connect to vCenter, use the following vmware power cli command to get the wwn number.

PowerCLI C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI> Connect-VIServer vcenterserver (vcenter servername)

PowerCLI C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI>Get-VMHostHba -VMHost ESXi01 | Select VMHost,Device,@{N="WWN";E={"{0:X}" -f $_.PortWorldWideName}}

output will be as follows

VMHost                                            Device                                            WWN
------                                            ------                                            ---
ESXi01                                        vmhba0                                            218000E08B000186
ESXI01                                        vmhba1                                           218100E08B200186

To get the status of HBA


Get-VMHostHba -VMHost (hostname).


Monday, July 8, 2013

Check the network link status and adapter model, firmware version in vsphere 5.X ESXI5.x

To trouble Network Link status on esxi 5.0.

Take SSH to ESXI and use following commands to list the available nic cards and link status.

~ # esxcfg-nics -l
Name    PCI           Driver      Link Speed     Duplex MAC Address       MTU    Description
vmnic0  0000:01:00.00 bnx2        Up   1000Mbps  Full   00:1a:64:76:04:10 1500   Broadcom Corporation Broadcom NetXtreme II BCM5709 1000Base-SX
vmnic1  0000:01:00.01 bnx2        Up   1000Mbps  Full   00:1a:64:76:04:11 1500   Broadcom Corporation Broadcom NetXtreme II BCM5709 1000Base-SX
vmnic2  0000:07:00.00 bnx2x       Up   10000Mbps Full   00:1a:64:76:04:14 1500   Broadcom Corporation NetXtreme II 57711 10Gigabit Ethernet
vmnic3  0000:07:00.01 bnx2x       Up   10000Mbps Full   00:1a:64:76:04:16 1500   Broadcom Corporation NetXtreme II 57711 10Gigabit Ethernet

Also you can use this as a alternatetive to get the same output.
~ # esxcli network nic list
Name    PCI Device     Driver  Link  Speed  Duplex  MAC Address         MTU  Description
------  -------------  ------  ----  -----  ------  -----------------  ----  --------------------------------------------------------------
vmnic0  0000:001:00.0  bnx2    Up     1000  Full    00:1a:64:76:04:10  1500  Broadcom Corporation Broadcom NetXtreme II BCM5709 1000Base-SX
vmnic1  0000:001:00.1  bnx2    Up     1000  Full    00:1a:64:76:04:11  1500  Broadcom Corporation Broadcom NetXtreme II BCM5709 1000Base-SX
vmnic2  0000:007:00.0  bnx2x   Up    10000  Full    00:1a:64:76:04:14  1500  Broadcom Corporation NetXtreme II 57711 10Gigabit Ethernet
vmnic3  0000:007:00.1  bnx2x   Up    10000  Full    00:1a:64:76:04:16  1500  Broadcom Corporation NetXtreme II 57711 10Gigabit Ethernet


Use the following command to get the network adapter driver, firmware, linkstatu and network adapter properties informaiton.

~ # esxcli network nic get -n vmnic0
   Advertised Auto Negotiation: true
   Advertised Link Modes: 1000baseT/Full
   Auto Negotiation: true
   Cable Type: FIBRE
   Current Message Level: -1
   Driver Info:
         Bus Info: 0000:01:00.0
         Driver: bnx2
         Firmware Version: bc 6.2.0 NCSI 2.0.11
         Version: 2.0.15g.v50.11-5vmw

   Link Detected: true
   Link Status: Up
   Name: vmnic0
   PHYAddress: 2
   Pause Autonegotiate: true
   Pause RX: false
   Pause TX: false
   Supported Ports: FIBRE
   Supports Auto Negotiation: true
   Supports Pause: true
   Supports Wakeon: true
   Transceiver: internal
   Wakeon: MagicPacket(tm)