Capturing VMware ESXtop performance data with PowerShell

Performance is a hot topic with the Intel security flaws Meltdown and Spectre. What is the impact of the patch on your environment? Is there enough server capacity available? Performance testing is key, and any valuable data helps to determine the overall impact. In this blog post, I will share how to capture VMware ESXtop data with PowerShell, fully automated!

Requirement for SSH

Like my previous post (XenServer) an SSH connection is required to fully automate the data capture. With the Posh-SSH PowerShell module, we are able to connect to the ESX host and invoke the command to capture the ESXtop data.

Please note: an internet connection is required.

You also can download the package to use it in an offline scenario.

SSH key

To create an SSH session to an ESX host requires an SSH key. So before we can start capturing the performance data we need to generate the key. The following knowledge base article explains how to generate the SSH key. In order to add the correct key to the authorized_keys file, you can use the following command. For more information please check this blog post.

Capture the ESXtop data

So right now we have the generated key and should be able to set up an SSH session to the ESX host. There are a couple variables in the script below that need to be assigned. First, it is important to specify the ESX host, username, password and the generated key. The credentials and key will be used to set up the SSH session. The test name will be used as the primary name for the CSV which will contain the ESXtop data. In the example, the data will be captured for 1 hour with an interval of 30 seconds. The CSV file will be captured in the “/tmp/” location. It is recommended to use a PowerShell job to capture the data so other tasks can be executed during the ESXtop capture.

This example captures the default ESXtop data set. More information about ESXtop can be found here.

Download the ESXtop data

Once the capture is done it is useful to automatically download the CSV file. The Posh-SSH module comes with the Get-SCPFile command which allows you to download the file. The following example will download the CSV file to %tmp%.

A quick tip! With the PPD you can quickly create charts in Microsoft Excel out of the ESXtop performance data! More info here.

Conclusion

To do proper performance research you need to have valuable data. It is common to include the performance data from a hypervisor like VMware ESX. With PowerShell, you are able to start and download the data capture fully automated. This way you can automate your test process to have consistent data. If you have any comments or questions, please leave them below.

 

Photo by Thomas Kvistholt on Unsplash