Disk space taken up by every VM, and all VMs in total, in the Nutanix AHV cluster

  • 20 October 2020
  • 0 replies

Userlevel 2

Nutanix customers using AHV as their Hypervisor often run into disk space issues on their cluster and need to evaluate how much disk space is being consumed by each entity.  And one of the more important factors that needs to be considered is how much space is being taken up by each VM.  There needs to be an easy way of running one single command and get a listing of the space consumed by each VM, so that at one glance you can figure out which are the VMs that can be removed from the cluster right away in order to get some space reclamation.  As a bonus I have also included the command string that will add up all these numbers and give you the grand total of how much disk space has been consumed by all these VMs put together.

I have come up with the following string manipulation to be able to get those numbers:

nutanix@CVM:$ for Q in `acli vm.list | awk '{print $1}'`;do echo -n "$Q    "; acli vm.get "$Q" | grep vmdisk_size | awk '{sum+=$2} END {print sum}' | awk '{ byte =$1 /1024/1024/1024; echo; print byte  " GB" }';done

nutanix@CVM:$ for Q in `acli vm.list | awk '{print $NF}' | egrep -v UUID`; do acli vm.get "$Q" | grep vmdisk_size | awk '{sum+=$2} END {print sum}' | awk '{ byte =$1 /1024/1024/1024; echo; print byte " GB" }'; done | awk '{total += $1} END {print "\nTotal space consumed by the VMs:", total, "GigaBytes"}'; echo

As you can see above, using the string manipulation in conjunction with the standard Linux operations like grep and awk, and involving a bit of mathematics, we can produce the output on how much disk space every VM in the cluster has taken up.  You are also able to see how much total disk space has been taken up by all these VMs put together.  This gets you one step closer to getting rid of the low hanging fruits, and taking a cognizant approach to whether to delete the other VMs.   You decide whether you want to look at the forest or at the individual trees in the forest!!!!!

Please note that the above commands are for monitoring and evaluation purposes only, they do not make any changes in your Nutanix cluster.  This gives you a handle on the VMs, let us tackle the other candidate for deletions i.e. the Snapshots in a later post.

Delete whatever VMs you can get rid of immediately, take a deep breath and think twice before you delete the other VMs.

This topic has been closed for comments