VMware Cloud Community
wamatha
Contributor
Contributor

Overallocated datastore (Thin provisioned)

Hallo,

I need help with a powerCLI script that  generate a report on overallocated thin provisioned datastores.

Thank you in advance

Joseph

Reply
0 Kudos
17 Replies
Troy_Clavell
Immortal
Immortal

Reply
0 Kudos
RvdNieuwendijk
Leadership
Leadership

Hi Joseph,

the next PowerCLI script will show you the overallocated datastores. The code was taken from Alan Renouf's vCheck script.

Get-Datastore | Get-View | ForEach-Object {
  $Datastore = $_
  if ($Datastore.Summary.Uncommitted -gt "0") {
    $Report = "" | Select-Object -Property Datastore, Overallocation
    $Report.Datastore = $Datastore.name
    $Report.Overallocation = [math]::round(((($Datastore.Summary.Capacity - $Datastore.Summary.FreeSpace) + $Datastore.Summary.Uncommitted)*100)/$Datastore.Summary.Capacity,0)
    if ($Report.Overallocation -gt 100) {
      $Report
    }
  }
}

Regards, Robert

Blog: https://rvdnieuwendijk.com/ | Twitter: @rvdnieuwendijk | Author of: https://www.packtpub.com/virtualization-and-cloud/learning-powercli-second-edition
Reply
0 Kudos
wamatha
Contributor
Contributor

Hi Robert,

I tried the script, no out put, just runs too fast with no results..have you tried it out?

Reply
0 Kudos
LucD
Leadership
Leadership

Could it be that none of your datastores is overcommitted ?

Alan's script only shows datastores where more than 100% of the capacity has been committed.


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

Reply
0 Kudos
LucD
Leadership
Leadership

Run this version of the script and check if there any datastores with a commit percentage above 100.

Get-Datastore | ForEach-Object {
  $Datastore = $_.Extensiondata
  if ($Datastore.Summary.Uncommitted -gt "0") {
    $Report = "" | Select-Object -Property Datastore, CommittedPercent
   
$Report.Datastore = $Datastore.name     $Report.CommittedPercent = [math]::round(((($Datastore.Summary.Capacity - $Datastore.Summary.FreeSpace) + $Datastore.Summary.Uncommitted)*100)/$Datastore.Summary.Capacity,0)     $Report
  } }


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

Reply
0 Kudos
wamatha
Contributor
Contributor

I have a couple of datastores that are over 100% overallocated, but the script does not show any of them.

Is there a way to make the script generate a txt or csv file?

- Joseph

Reply
0 Kudos
wamatha
Contributor
Contributor

Hi Luc

still no output, the script runs pretty fast with zero output

Reply
0 Kudos
LucD
Leadership
Leadership

Which PowerCLI version are you using ?

Do a

Get-PowerCLIVersion

The Extensiondata property came with PowerCLI 4.1.

Does 'Get-Datastore' on it's own return anything in your session ?


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

Reply
0 Kudos
wamatha
Contributor
Contributor

PowerCLI Version
----------------
   VMware vSphere PowerCLI 4.1 U1 build 332441
---------------
Snapin Versions
---------------
   VMWare vSphere PowerCLI 4.1 U1 build 332441
   VMware vCenter Update Manager PowerCLI 4.1 build 266648

Reply
0 Kudos
wamatha
Contributor
Contributor

yes, Get-Datastore returns the datastores name, FreeSpace and CapcityMB

Reply
0 Kudos
LucD
Leadership
Leadership

That all looks good and up to date.

Does the Uncommitted property display values ?

Run this as a test

Get-Datastore | Select Name,@{N="Uncommitted";E={$_.Extensiondata.Summary.Uncommitted}}


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

Reply
0 Kudos
wamatha
Contributor
Contributor

When I run the test, Uncommitted displays a value of 0 (zero) for all the datastores

Reply
0 Kudos
LucD
Leadership
Leadership

That explains why you have no output from the original script.

The only explanation I see why that is so, is that there no 'thin' disks present on those datastores.

In other words, all the guests use 'thick' disks.


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

Reply
0 Kudos
wamatha
Contributor
Contributor

Hmm, strange all our luns are thin provioned from the EMC VMAX before we add then to the VC

Since I have not enabled the alarm for overallocation, whould this cause the result to zero?

Reply
0 Kudos
LucD
Leadership
Leadership

We're mixing 2 things here.

1) Your EMC vMAX can provide Thin provisioned disk.

The vCenter will see the LUN with allocated size of the LUN.

vCenter has no knowledge afaik of that type of Thin provisioning.

2) When you create a disk for a guest, you have the option to define that virtualdisk as being Thick or Thin.

When you select Thin, the allocated space will not be assigned to the virtualdisk.

The virtualdisk will get space when the guest OS writes new data.

That is what is reflected in the UnCommitted property.

You can for example assign a virtualdisk of 10 GB, but the guest has only used 2 GB till now.

That means there is 8 GB uncommitted.

This also allows you to overcommit the space of your datastore.

You can have allocated for example 200 GB to guest's virtualdisks, while the datastore is only 150 GB.

As long as the virtualdisks do not actually use more than 150 GB there is no problem.

Alan's script shows the overcommitment percentage.

In the example you have committed 133% of the datastore, or a 33% overcommitment.


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

Reply
0 Kudos
wamatha
Contributor
Contributor

I understand, all our VM's are thin provisioned ..I will continue invetigating.

Reply
0 Kudos
wamatha
Contributor
Contributor

33% overcommittment

Reply
0 Kudos