Administrators may need to perform a deep-dive audit of physical network interface (pNIC) statistics across multiple ESXi hosts to troubleshoot packet loss, CRC errors, or performance degradation. Standard vCenter performance charts may not provide the granular hardware-level error counters (e.g., FIFO errors, Heartbeat errors) required for root cause analysis.
7.x, 8.x, 9.x
Diagnostic requirement for low-level NIC statistics (Receive/Transmit drops and errors) across a specific cluster.
Prerequisites:
Script:
Connect-VIServer -Server <VCENTER_FQDN_OR_IP>
# 1. Define the Cluster target
$clusterName = Read-Host "Enter the name of the Cluster you want to audit"
$cluster = Get-Cluster -Name $clusterName -ErrorAction SilentlyContinue
if (-not $cluster) {
Write-Host "Could not find a cluster named '$clusterName'." -ForegroundColor Red
return
}
# 2. Retrieve connected hosts
$esxiHosts = Get-VMHost -Location $cluster | Where-Object { $_.ConnectionState -eq "Connected" }
Write-Host "`nAuditing Cluster: $($cluster.Name) ($($esxiHosts.Count) Hosts Found)" -ForegroundColor Green
foreach ($vmhost in $esxiHosts) {
Write-Host "`n" + ("=" * 60)
Write-Host " HOST: $($vmhost.Name)" -ForegroundColor Cyan
Write-Host ("=" * 60)
try {
$esxcli = Get-EsxCli -VMHost $vmhost -V2
$pnics = $vmhost.ExtensionData.Config.Network.Pnic
foreach ($pnic in $pnics) {
$nicName = $pnic.Device
$s = $esxcli.network.nic.stats.get.Invoke(@{nicname = $nicName})
Write-Host "`n [ NIC: $nicName ]" -ForegroundColor Yellow
$output = @"
Packets received: $($s.PacketsReceived)
Packets sent: $($s.PacketsTransmitted)
Bytes received: $($s.BytesReceived)
Bytes sent: $($s.BytesTransmitted)
Receive packets dropped: $($s.ReceivePacketsDropped)
Transmit packets dropped: $($s.TransmitPacketsDropped)
Multicast packets received: $($s.MulticastPacketsReceived)
Broadcast packets received: $($s.BroadcastPacketsReceived)
Multicast packets sent: $($s.MulticastPacketsTransmitted)
Broadcast packets sent: $($s.BroadcastPacketsTransmitted)
Total receive errors: $($s.ReceiveErrors)
Receive length errors: $($s.ReceiveLengthErrors)
Receive over errors: $($s.ReceiveOverErrors)
Receive CRC errors: $($s.ReceiveCRCErrors)
Receive frame errors: $($s.ReceiveFrameErrors)
Receive FIFO errors: $($s.ReceiveFIFOErrors)
Receive missed errors: $($s.ReceiveMissedErrors)
Total transmit errors: $($s.TransmitErrors)
Transmit aborted errors: $($s.TransmitAbortedErrors)
Transmit carrier errors: $($s.TransmitCarrierErrors)
Transmit FIFO errors: $($s.TransmitFIFOErrors)
Transmit heartbeat errors: $($s.TransmitHeartbeatErrors)
Transmit window errors: $($s.TransmitWindowErrors)
"@
Write-Host $output
}
}
catch {
Write-Host " [!] Error accessing host $($vmhost.Name): $($_.Exception.Message)" -ForegroundColor Red
}
}
For trend analysis, run this script daily and compare ReceiveCRCErrors or ReceivePacketsDropped. Frequent increments in these counters typically indicate physical layer issues (cabling, SFP, or switch port configuration).