Hello,
I have the attached cluster report script where I am trying to report following data and need some help in getting the information through the right functions and commands.
This Category names match the overall info represented in VC Client interface
Any help on getting this additional functionality is highly appreciated.
Start with this
$report = @() # $clusterName = "MyCluster" $clusterName = "*" $report = foreach($cluster in Get-Cluster -Name $clusterName){ $esx = $cluster | Get-VMHost $ds = Get-Datastore -VMHost $esx | where {$_.Type -eq "VMFS" -and $_.Extensiondata.Summary.MultipleHostAccess} New-Object PSObject -Property @{ VCname = $cluster.Uid.Split(':@')[1] DCname = (Get-Datacenter -Cluster $cluster).Name Clustername = $cluster.Name "Number of hosts" = $esx.Count "Total Processors" = ($esx | measure -InputObject {$_.Extensiondata.Summary.Hardware.NumCpuPkgs} -Sum).Sum "Total Cores" = ($esx | measure -InputObject {$_.Extensiondata.Summary.Hardware.NumCpuCores} -Sum).Sum "Current CPU Failover Capacity" = $cluster.Extensiondata.Summary.AdmissionControlInfo.CurrentCpuFailoverResourcesPercent "Current Memory Failover Capacity" = $cluster.Extensiondata.Summary.AdmissionControlInfo.CurrentMemoryFailoverResourcesPercent "Configured Failover Capacity" = $cluster.Extensiondata.ConfigurationEx.DasConfig.FailoverLevel "Migration Automation Level" = $cluster.Extensiondata.ConfigurationEx.DrsConfig.DefaultVmBehavior "DRS Recommendations" = &{$result = $cluster.Extensiondata.Recommendation | %{$_.Reason};if($result){[string]::Join(',',$result)}} "DRS Faults" = &{$result = $cluster.Extensiondata.drsFault | %{$_.Reason};if($result){[string]::Join(',',$result)}} "Migration Threshold" = $cluster.Extensiondata.ConfigurationEx.DrsConfig.VmotionRate "target hosts load standard deviation" = "NA"
"Current host load standard deviation" = "NA" "Total Physical Memory (MB)" = ($esx | Measure-Object -Property MemoryTotalMB -Sum).Sum "Configured Memory MB" = ($esx | Measure-Object -Property MemoryUsageMB -Sum).Sum "Available Memroy (MB)" = ($esx | Measure-Object -InputObject {$_.MemoryTotalMB - $_.MemoryUsageMB} -Sum).Sum "Total CPU (Mhz)" = ($esx | Measure-Object -Property CpuTotalMhz -Sum).Sum "Configured CPU (Mhz)" = ($esx | Measure-Object -Property CpuUsageMhz -Sum).Sum "Available CPU (Mhz)" = ($esx | Measure-Object -InputObject {$_.CpuTotalMhz - $_.CpuUsageMhz} -Sum).Sum "Total Disk Space (MB)" = ($ds | where {$_.Type -eq "VMFS"} | Measure-Object -Property CapacityMB -Sum).Sum "Configured Disk Space (MB)" = ($ds | Measure-Object -InputObject {$_.CapacityMB - $_.FreeSpaceMB} -Sum).Sum "Available Disk Space (MB)" = ($ds | Measure-Object -Property FreeSpaceMB -Sum).Sum } } $report | Export-Csv "C:\Cluster-Report.csv" -NoTypeInformation -UseCulture
It will produce most properties, except for the Performance tab entries.
I didn't understand what you wanted there, the values that are presented in these graphs ?
Also note that both standard deviation properties are marked as "NA".
The exact calculation method for those 2 hasn't been published afaik.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Start with this
$report = @() # $clusterName = "MyCluster" $clusterName = "*" $report = foreach($cluster in Get-Cluster -Name $clusterName){ $esx = $cluster | Get-VMHost $ds = Get-Datastore -VMHost $esx | where {$_.Type -eq "VMFS" -and $_.Extensiondata.Summary.MultipleHostAccess} New-Object PSObject -Property @{ VCname = $cluster.Uid.Split(':@')[1] DCname = (Get-Datacenter -Cluster $cluster).Name Clustername = $cluster.Name "Number of hosts" = $esx.Count "Total Processors" = ($esx | measure -InputObject {$_.Extensiondata.Summary.Hardware.NumCpuPkgs} -Sum).Sum "Total Cores" = ($esx | measure -InputObject {$_.Extensiondata.Summary.Hardware.NumCpuCores} -Sum).Sum "Current CPU Failover Capacity" = $cluster.Extensiondata.Summary.AdmissionControlInfo.CurrentCpuFailoverResourcesPercent "Current Memory Failover Capacity" = $cluster.Extensiondata.Summary.AdmissionControlInfo.CurrentMemoryFailoverResourcesPercent "Configured Failover Capacity" = $cluster.Extensiondata.ConfigurationEx.DasConfig.FailoverLevel "Migration Automation Level" = $cluster.Extensiondata.ConfigurationEx.DrsConfig.DefaultVmBehavior "DRS Recommendations" = &{$result = $cluster.Extensiondata.Recommendation | %{$_.Reason};if($result){[string]::Join(',',$result)}} "DRS Faults" = &{$result = $cluster.Extensiondata.drsFault | %{$_.Reason};if($result){[string]::Join(',',$result)}} "Migration Threshold" = $cluster.Extensiondata.ConfigurationEx.DrsConfig.VmotionRate "target hosts load standard deviation" = "NA"
"Current host load standard deviation" = "NA" "Total Physical Memory (MB)" = ($esx | Measure-Object -Property MemoryTotalMB -Sum).Sum "Configured Memory MB" = ($esx | Measure-Object -Property MemoryUsageMB -Sum).Sum "Available Memroy (MB)" = ($esx | Measure-Object -InputObject {$_.MemoryTotalMB - $_.MemoryUsageMB} -Sum).Sum "Total CPU (Mhz)" = ($esx | Measure-Object -Property CpuTotalMhz -Sum).Sum "Configured CPU (Mhz)" = ($esx | Measure-Object -Property CpuUsageMhz -Sum).Sum "Available CPU (Mhz)" = ($esx | Measure-Object -InputObject {$_.CpuTotalMhz - $_.CpuUsageMhz} -Sum).Sum "Total Disk Space (MB)" = ($ds | where {$_.Type -eq "VMFS"} | Measure-Object -Property CapacityMB -Sum).Sum "Configured Disk Space (MB)" = ($ds | Measure-Object -InputObject {$_.CapacityMB - $_.FreeSpaceMB} -Sum).Sum "Available Disk Space (MB)" = ($ds | Measure-Object -Property FreeSpaceMB -Sum).Sum } } $report | Export-Csv "C:\Cluster-Report.csv" -NoTypeInformation -UseCulture
It will produce most properties, except for the Performance tab entries.
I didn't understand what you wanted there, the values that are presented in these graphs ?
Also note that both standard deviation properties are marked as "NA".
The exact calculation method for those 2 hasn't been published afaik.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi Luc
That was really helpful. and yes for the performance I meant getting the chart numbers to represent them in a textual format in the report.
Also i got the following error's when running the script but it did complete successfully. so not sure what these errors mean and why they popped up?
That is strange, that would mean you have a cluster with no ESX(i) hosts in it somewhere ?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Luc
Yes currently we do not have any ESX(i) hosts in our environment. but that is changing by next week.
Any ideas on the performance tab info?
Hi LucD
I need an HTML output for the cluster stastics script.
Can you help me with this?
thanks
Change the last line into
$report | ConvertTo-Html | Out-File .\report.html
This will produce a very basic HTML page.
You can get very fancy, Alan's vCheck script is a very good example.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
My datasore is divided into 3 tiers..
Is there anyways I can get report on it serperately?
Why are these crossed out? Is there a way of getting this info via powercli? I've been trying to figure it out
Resource Allocation Tab
The original author of the thread didn't seem to want these values.
But you retrieve them with PowerCLI, something like this
$cluster = Get-Cluster MyCluster
$rp = Get-View $cluster.ExtensionData.ResourcePool
Select -InputObject $cluster -Property Name,
@{N="CPU Total Capacity";E={$rp.Runtime.Cpu.MaxUsage}},
@{N="CPU Reserved Capacity";E={$rp.Runtime.Cpu.ReservationUsed}},
@{N="CPU Available Capacity";E={$rp.Runtime.Cpu.MaxUsage - $rp.Runtime.Cpu.ReservationUsed}},
@{N="Memory Total Capacity";E={$rp.Runtime.Memory.MaxUsage}},
@{N="Memory Reserved Capacity";E={$rp.Runtime.Memory.ReservationUsed}},
@{N="Memory Available Capacity";E={$rp.Runtime.Memory.MaxUsage - $rp.Runtime.Memory.ReservationUsed}}
It shouldn't be too difficult to add these values to the report.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
that worked, Thanks!
Hi LucD, I tried peicing together the two but getting errors. Seperately I was able to get it to work. I even went to a couple of book stores to find "VMware vSphere PowerCLI Reference" but it was unavailable. Any help putting together the two would be appreciated.
Try it like this
$report = @() $clusterName = "*" $report = foreach($cluster in Get-Cluster -Name $clusterName){ $esx = $cluster | Get-VMHost $ds = Get-Datastore -VMHost $esx | where {$_.Type -eq "VMFS" -and $_.Extensiondata.Summary.MultipleHostAccess} $rp = Get-View $cluster.ExtensionData.ResourcePool New-Object PSObject -Property @{ VCname = $cluster.Uid.Split(':@')[1] DCname = (Get-Datacenter -Cluster $cluster).Name
Clustername = $cluster.Name
"Number of hosts" = $esx.Count
"Total Processors" = ($esx | measure -InputObject {$_.Extensiondata.Summary.Hardware.NumCpuPkgs} -Sum).Sum
"Total Cores" = ($esx | measure -InputObject {$_.Extensiondata.Summary.Hardware.NumCpuCores} -Sum).Sum
"Current CPU Failover Capacity" = $cluster.Extensiondata.Summary.AdmissionControlInfo.CurrentCpuFailoverResourcesPercent
"Current Memory Failover Capacity" = $cluster.Extensiondata.Summary.AdmissionControlInfo.CurrentMemoryFailoverResourcesPercent
"Configured Failover Capacity" = $cluster.Extensiondata.ConfigurationEx.DasConfig.FailoverLevel
"Migration Automation Level" = $cluster.Extensiondata.ConfigurationEx.DrsConfig.DefaultVmBehavior
"DRS Recommendations" = &{$result = $cluster.Extensiondata.Recommendation | %{$_.Reason};if($result){[string]::Join(',',$result)}} "DRS Faults" = &{$result = $cluster.Extensiondata.drsFault | %{$_.Reason};if($result){[string]::Join(',',$result)}} "Migration Threshold" = $cluster.Extensiondata.ConfigurationEx.DrsConfig.VmotionRate
"target hosts load standard deviation" = "NA"
"Current host load standard deviation" = "NA" "Total Physical Memory (MB)" = ($esx | Measure-Object -Property MemoryTotalMB -Sum).Sum
"Configured Memory MB" = ($esx | Measure-Object -Property MemoryUsageMB -Sum).Sum
"Available Memroy (MB)" = ($esx | Measure-Object -InputObject {$_.MemoryTotalMB - $_.MemoryUsageMB} -Sum).Sum
"Total CPU (Mhz)" = ($esx | Measure-Object -Property CpuTotalMhz -Sum).Sum
"Configured CPU (Mhz)" = ($esx | Measure-Object -Property CpuUsageMhz -Sum).Sum
"Available CPU (Mhz)" = ($esx | Measure-Object -InputObject {$_.CpuTotalMhz - $_.CpuUsageMhz} -Sum).Sum
"Total Disk Space (MB)" = ($ds | where {$_.Type -eq "VMFS"} | Measure-Object -Property CapacityMB -Sum).Sum
"Configured Disk Space (MB)" = ($ds | Measure-Object -InputObject {$_.CapacityMB - $_.FreeSpaceMB} -Sum).Sum
"Available Disk Space (MB)" = ($ds | Measure-Object -Property FreeSpaceMB -Sum).Sum
"CPU Total Capacity" = $rp.Runtime.Cpu.MaxUsage
"CPU Reserved Capacity" = $rp.Runtime.Cpu.ReservationUsed
"CPU Available Capacity" = $rp.Runtime.Cpu.MaxUsage - $rp.Runtime.Cpu.ReservationUsed
"Memory Total Capacity" = $rp.Runtime.Memory.MaxUsage
"Memory Reserved Capacity" = $rp.Runtime.Memory.ReservationUsed
"Memory Available Capacity" = $rp.Runtime.Memory.MaxUsage - $rp.Runtime.Memory.ReservationUsed
} } $report | Export-Csv "C:\Cluster-Report.csv" -NoTypeInformation -UseCulture
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks for sharing the script, however I got this error message:
what does that means ?
Does the following also return an error ?
Get-Cluster -Name *
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
it worked, thanks again!