ESXi virtual machine network statistics

How to display network statistics for virtual machines on ESXi vSwitch. Verify the total number of packets sent or received as well as the amounts of broadcast and multicast frames for a specific VM on a virtual switch.

vmware-vm-network-stat-cisco-1

On many physical switches it is easy to retrieve interface statistics including number of transmitted and received packets, the number of broadcast and multicast frames as well as error reporting.

Corresponding statistics are however not directly available in the GUI for VMware ESXi standard vSwitch, but they are possible to view from the ESXi command line e.g. through SSH.

vmware-vm-network-stat-1

The classic ESXTOP (above) is a great tool, but does only show real-time values and no cumulated statistics. If we would like to see the total amount of sent/received or other statistics we could use the esxcli tool.

We must first find the virtual switch port ID for the VM we are investigating. This could be seen in ESXTOP if few VMs are running, but could also be retrieved through two other commands:

vmware-vm-network-stat-2

First find the VM “world id” with the command:

esxcli network vm list

If you have large amounts of VMs displayed a grep filter could be attached with (parts of) the VM name, as displayed above. Note/copy the number first on the line.

vmware-vm-network-stat-3

Use the command:

esxcli network vm port list -w WORLD-id

This will display the name of the vSwitch, the name of the portgroup, the MAC address, the outgoing physical adapter (vmnic) and also the so called Port ID. The port id is the internal reference to the port for the VM on the virtual switch.

Make a note/copy of the Port ID which will be used in the final esxcli command. (The port ID could also be taken from ESXTOP.)

vmware-vm-network-stat-4

The command for displaying port statistics is:

esxcli network port stats get -p PORT-id

Note that statistics for standard vSwitch are per host, so if a virtual machine is migrated to another ESXi host the statistics will be renewed. If the virtual machine is rebooted the statistics will be kept, but is lost if doing a VM shutdown.