Hi,
i am looking for a script that provides cluster information; for example:
1. a total capicity of the data stores just for the cluster and the free space just for the cluster.
2. how many vms there are on the cluster
3. how many hosts
4. memory utilization on the cluster i.e. total memory and used memory.
5. cpu utilization on the cluster.
is there a script out there that gives that, i ahve seen a lot and most of them provide global information, however i need the globalinformation for the cluster and more basic so managers can see o ok we are using 300 gb of 500 gb total in the cluster, they don't care that this lun has this much etc, i do they don't
thanks
The following script should provide the information you're after.
$clusterName = <cluster-name> $clusterImpl = Get-Cluster $clusterName $cluster = $clusterImpl | Get-View # Datastores foreach($dsMoRef in $cluster.Datastore){ $ds = Get-View -Id $dsMoRef Write-Host "Datastore : " $ds.Summary.Name "`tCapacity : " ($ds.Summary.Capacity/1Mb) "Mb`tFree space : " ($ds.Summary.FreeSpace/1Mb) "Mb" } # VM number $totalVM = 0 $memoryEffectiveUsed = 0 $cpuEffectiveUsed = 0 foreach($hostMoRef in $cluster.Host){ $esx = Get-View -Id $hostMoRef $totalVM += $esx.Vm.Count $memoryEffectiveUsed += $esx.Summary.QuickStats.OverallMemoryUsage $cpuEffectiveUsed += $esx.Summary.QuickStats.OverallCpuUsage } Write-Host "Number of VMs : " $totalVM # Host Number Write-Host "Number of hosts : " $cluster.Summary.NumHosts "`tEffective hosts : " $cluster.Summary.NumEffectiveHosts # Memory utilisation Write-Host "Total memory : " ("{0:N0}" -f ($cluster.Summary.TotalMemory/1Mb)) "Mb`tEffective :" $cluster.Summary.EffectiveMemory "Mb`tUsed: " $memoryEffectiveUsed "Mb" # CPU utilisation Write-Host "Total CPU : " ("{0:N0}" -f $cluster.Summary.TotalCpu) "Mhz`tEffective :" $cluster.Summary.EffectiveCpu "Mhz`tUsed :" $cpuEffectiveUsed "Mhz"
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
This is great information and almsot there thank you lUCD, just one thing tho (always one thing isn't it) the datastore will show each datastore i just want it to add it all up and say like thememory and cpu, the cluster has .
ie. cluster : datastore capticy 500gig free 200 gig
thank you in advance.
That's not a big deal, instead of writing the info for each datastore we just sum the total and free capacity numbers and display them after the loop through all the datastores.
$clusterName = <cluster-name> $clusterImpl = Get-Cluster $clusterName $cluster = $clusterImpl | Get-View # Datastores $dsTotalCapacity = 0 $dsTotalFree = 0 foreach($dsMoRef in $cluster.Datastore){ $ds = Get-View -Id $dsMoRef $dsTotalCapacity += $ds.Summary.Capacity $dsTotalFree += $ds.Summary.FreeSpace } Write-Host "DS Capacity : " ($dsTotalCapacity/1Gb) "Gb`tTotal free : " ($dsTotalFree/1Gb) "Gb" # VM number $totalVM = 0 $memoryEffectiveUsed = 0 $cpuEffectiveUsed = 0 foreach($hostMoRef in $cluster.Host){ $esx = Get-View -Id $hostMoRef $totalVM += $esx.Vm.Count $memoryEffectiveUsed += $esx.Summary.QuickStats.OverallMemoryUsage $cpuEffectiveUsed += $esx.Summary.QuickStats.OverallCpuUsage } Write-Host "Number of VMs : " $totalVM # Host Number Write-Host "Number of hosts : " $cluster.Summary.NumHosts "`tEffective hosts : " $cluster.Summary.NumEffectiveHosts # Memory utilisation Write-Host "Total memory : " ("{0:N0}" -f ($cluster.Summary.TotalMemory/1Mb)) "Mb`tEffective :" $cluster.Summary.EffectiveMemory "Mb`tUsed: " $memoryEffectiveUsed "Mb" # CPU utilisation Write-Host "Total CPU : " ("{0:N0}" -f $cluster.Summary.TotalCpu) "Mhz`tEffective :" $cluster.Summary.EffectiveCpu "Mhz`tUsed :" $cpuEffectiveUsed "Mhz"
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Excellent thanks, i think i can work out how to export it to cvs or graph it etc wow thanks this helps, i never knew what the += did now i do
I'm using this (parts of it at least) to collect data on the clusters but I'd like to do the same for a single host, not in a cluster. I can't seem to access things like $host.Summary.EffectiveCPU, EffectiveMemory, etc
I'm mssing something here. An object I need to initialize?
Lucid,
This is data that is "realtime". What about the cluster data on a 30 day average for example? Like you would see in Virtual Center. Is that stored somewhere or is it a calculated field?
Thanks for the excellent infomation.
For historical performance data you would have to use the Get-Stat cmdlet.
Have a look at the script in .
That show how you can use the Get-Stat cmdlet to get network usage statistics over the last 2 hours.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference