«

»

May 12 2017

List number of VMs per Nutanix AHV host

“VMTurbo"
Got a question a few days ago about how to list number of virtual machines (VMs) per Nutanix AHV host. From the top of my head I can think of two ways:

PRISM

It’s really simple to either view VMs per AHV Hosts direct in the UI and even export the information to a CSV or JSON file.

  1. Log in to PRISM
  2. Click Select the VM view
  3. Click Table
  4. Click Host and you’ll sort the output based on the AHV Hosts and you need to count the VMs per AHV Host.

The PRISM exports option requires you to follow thew above first three steps but instead of clicking the HOST link you’ll select the drop down option Export CSV or Export JSON.

When you got your file, just make a summary in your preferred CSV and or JSON editor.

Script

However, if you need this information every X seconds, minutes, hours and so on based on the work you’re currently doing you can run a script via REST API or acli. I used the below script during a live migration test the other days to keep track of the number of VMs per AHV Host every 30 seconds.

If needed you can redirect the output to a log file if needed but for me it was ok to have the output printed to the terminal. I used the below command (just copy and paste into the SSH session) to run the script as long as I needed. Just press “ctrl + c” to stop the script.

The below figure is a script output from my test cluster.

This script was tested and verified on AOS 5.1.0.1 and AHV 20160925.44

 

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">