VMware Cloud Community
michaelbrux
Contributor
Contributor

Total of vm.provisionedSpaceGB and Datastore.provisionedGB not equal

I was looking to find the storage growth rate in my environment when I noticed something interesting.  When I query the VMs and the Datastores on provisioned space I get different numbers where I would expect the numbers to be equal.  In my environment it looks like the space provisioned by adding each VM is 185 TB and by adding each datastore is 172 TB.  I was wondering if anyone could explain the difference here.  I am including the script that I used to get the figures. 


$provisionedgb=0
$provisioned=0
$VMs=Get-VM
$stores=Get-Datastore


foreach($VM in $VMs) {
$provisioned+=$VM.ProvisionedSpaceGB
}
$provisioned=$provisioned/1024

foreach ($store in $stores){
$provisionedgb+=$store.provisionedGB
}
$provisionedgb=$provisionedgb/1024

Write-Host "VM Provisioined (TB) $provisioned"
Write-Host "Datastore Provisioned (TB) $provisionedgb"

Reply
0 Kudos
3 Replies
LucD
Leadership
Leadership

Strange, I would have expected the reverse, datastore number higher than the VM number.

There's bound to be other folders and files (dvSwitches, LUN info, HA heartbeat and other info...) on your datastores.

In any case, it would be interesting to compare the timestamps on both.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
MKguy
Virtuoso
Virtuoso

I don't have the ProvisionedGB property on datastore objects in my PowerCLI 5.1 R2/vSphere 5.1 U1 environment, only the FreeSpaceGB and CapacityGB properties. So I'm calculating ($store.capacitygb - $store.freespacegb) instead.

The main cause for this discrepancy are probably thin-provisioned disks and snapshots. Snapshots double the provisioned space of a VM for each snapshot. You need to look at UsedSpaceGB to compare the datastore and VM values.

Also the VM provisioned space property is calculated as (vmdk files + vSwap file + VM memory overhead swapfile + some other VM files like vmware.log files), but the vSwap file is only created for powered-on VMs, meaning it does not count to the datastore provisioned/freespace for currently powered-off VMs.

Besides that, take Templates, ISOs, core dumps, or whatever random files are lying around on your datastores into account too.

Based on your example, the code below displays the used space too. In my case, the VM used and datastore provisioned total values are pretty close.

$provisionedgb=0

$provisioned=0

$vmused=0

$VMs=Get-VM

$stores=Get-Datastore

foreach($VM in $VMs) {

$provisioned+=$VM.ProvisionedSpaceGB

$vmused+=$VM.UsedSpaceGB

}

$provisioned=$provisioned/1024

$vmused=$vmused/1024

foreach ($store in $stores){

$provisionedgb+=($store.capacitygb - $store.freespacegb)

}

$provisionedgb=$provisionedgb/1024

Write-Host "VM Provisioined (TB) $provisioned"

Write-Host "VM Used (TB) $vmused"

Write-Host "Datastore Provisioned (TB) $provisionedgb"

-- http://alpacapowered.wordpress.com
Reply
0 Kudos
michaelbrux
Contributor
Contributor

Looks like the ProvisionedGB was a custom VI property that I imported.  See calculation below.  Even with using 'VM used' my totals are 14TB off.

VM Provisioined (TB) 185.5294361954238411271944642

VM Used (TB) 90.74842126356998051051050425

Datastore Provisioned (TB) 76.7400119781494140625

# ProvisionedGB
New-VIProperty -Name ProvisionedGB -ObjectType Datastore -Value {
  
param($ds)

  [
Math]::Round(($ds.ExtensionData.Summary.Capacity - $ds.ExtensionData.Summary.FreeSpace + $ds.ExtensionData.Summary.Uncommitted)/1GB,1)
} -BasedONextensionProperty
'Summary' -Force

Reply
0 Kudos