How much SAN storage are my ESX hosts using?
As part of some monthly stats I need to collate, I had to find out how much SAN storage was being used by my ESX hosts. Luckily we have a pretty good naming convention for our datastores so it’s pretty easy to filter out local storage figures. We simply query Virtual Centre for datastores, filter out any local ones, total up their capacity and then convert the figure into Terabytes.
(Note this gives you the total amount of storage allocated to you by your storage team, not how much is actually in use as part of that. If that’s what you need then use the ‘FreeSpaceMB figure to work it out)
Connect-VIServer virtualcenter | Out-Null $datastores = Get-Datastore | Where-Object {$_.name -notlike “*local*”} $sum = $datastores | Measure-Object capacitymb -sum $result = [math]::round(($sum.sum * 1MB / 1GB) / 1024,1) Write-Host ‘Total SAN Storage’ $result ‘Terabytes’
(Note: I don’t normally use Write-Host for output, but for the purposes of this example it works)
If you don’t have such a clear naming convention for your datastores then Carter Shanklin has a post over on the PowerCLI blog which will return only those on SAN storage.
More stat collections to follow…….