Just another WordPress site

Main menu

Post navigation

List Virtual Machines on ESXi

ESXi is popular hypervisor product from VMware. It comes with several management GUIs including Vsphere and VCenter. Command line tools are also bundled, though they are used more rarely. This article describes a short script to list all virtual machines on the system.

The script is below. It is intended to run under the Busybox shell, the default environment when you ssh directly into the system hosting ESXi.

Showvms.sh Script

A surprising number of Unix tools are available under the ESXi implementation of Busybox. For example sed, egrep and awk. So it is quite easy to write useful scripts. This one involves a long pipeline, which I have broken into lines, indented and commented separately.

The above output was taken from an HP BL460c G8 blade server running ESXi 5.1. I haven’t tested it on other versions. We have 14 virtual machines on there, each sized at 8 GB. The blade has 256GB of memory, of which 112GB (ie. 14 x 8) is allocated to the VMs as shown.

Run Remotely

Rather than put the script on each ESXi server, I find it easier to just put it on a linux box and run it from there, via ssh: