How do I get a list of VMs with snapshots on the Nutanix platform?
Customers keep asking – where do I find how much space is being taken by snapshots or how do I get a list of VMs with a snapshot
Snapshots are mysterious “eaters” of storage space in any system. There are several ways to find out information about snapshots on the Nutanix platform. You can use Prism Element or Prism Central or the command line to list Virtual machine snapshots.
NOTE: you can monitor snapshot usage on the Nutanix platform – see my blog for more details
Prism Central
If you have the modern version of Prism Central, 2021.9 or newer, you will be able to find out very quickly VMs with snapshots.
To find a summary overview of how much storage is being used by snapshots, go to VM view in Prism Central –> Metrics –> Storage usage
The middle widget will show how much space is being taken by snapshots and how many VMs are contributing to it.
To get more details about snapshot sizes, create a custom view. Go to VM View –> List in Prism Central –> View by –> Add custom. Add two fields to the view – Acropolis VM and Snapshot Usage
In the new view, you can see all Vms with snapshots and the size of the snapshot
If you want, you can export the view to CSV format, just click on the Export button in the top right corner.
Prism Element
In Prism Element, you can find out even more information about the snapshot for a particular VM. Go to VM view –> Click on VM –> VM Snapshots tab. You can view the date and time, and the name of the snapshot. In addition, you can perform actions like Delete, Clone, Restore
Command-line
Yet another method is to use the command line. it is complex command line and gives you clean output
ncli pd ls-snaps|egrep "Size.*\)|VM Name" |grep --no-group-separator -A1 'VM Name' |grep --no-group-separator -B1 Size | tr -d '(,' |awk '/Snapshot\ Size/{print $6}1'|grep -v Snapshot |awk '/.*VM\ Name.*$/{printf $0":";next;}1' |awk -F : '{print $2 ":" $3}' |sed -e 's/^\ //' -e 's/\ /_/g' |sort |awk -F : 'BEGIN { tag = -1; sum = 0} {if (tag != $1) {if (tag > -1) {print tag, sum;}tag = $1; sum = $2} else { sum += $2 }} END {print tag, sum}' | awk '{ split( "K M G T P" , v ); s=0; while( $2>1024 ){ $2/=1024; s++ } {printf $1 ": " "%.2f %s\n", $2, v[s] }}'
The output from the command below:
ERA_1.0.1.5: 279.06 M
ERA1.2: 150.28 M
Era-1.2.1: 94.43 M
Man-era: 106.17 M
Master-Win2016: 4.52 G
Move-VM: 341.14 M
rx_autodeploy: 17.97 M
RX-NFSVM-1: 191.47 M
RX-PHX-AUTODEPLOY: 105.81 G
SAL-ERA-ENG1: 423.77 M
SAL-ERA-ENG2: 101.72 M
WIN-SQL-001A: 739.94 M