Hi All
I am looking for a script which exports ESX host CPU and MEM utilization in below format
HOST CPU% usage MEM %usage
host1 70 30
host2 30 50
Regards
Pankaj
Try something like this
Get-VMHost | Sort-Object -Property Name |
Select Name,State,
@{N="Status";E={$_.ExtensionData.Summary.OverallStatus}},
@{N="CPU%";E={[Math]::Round(100*$_.ExtensionData.Summary.QuickStats.OverallCpuUsage/($_.ExtensionData.Summary.Hardware.CpuMhz*$_.ExtensionData.Summary.Hardware.NumCpuCores),0)}},
@{N="Mem%";E={[Math]::Round(100*$_.ExtensionData.Summary.QuickStats.OverallMemoryUsage*1MB/$_.ExtensionData.Summary.Hardware.MemorySize,0)}}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Like we get the report if we export if from the VC ,Unable to extract same format from get-vmhost power cli command
Name | State | Status | % CPU | % Memory |
Try something like this
Get-VMHost | Sort-Object -Property Name |
Select Name,State,
@{N="Status";E={$_.ExtensionData.Summary.OverallStatus}},
@{N="CPU%";E={[Math]::Round(100*$_.ExtensionData.Summary.QuickStats.OverallCpuUsage/($_.ExtensionData.Summary.Hardware.CpuMhz*$_.ExtensionData.Summary.Hardware.NumCpuCores),0)}},
@{N="Mem%";E={[Math]::Round(100*$_.ExtensionData.Summary.QuickStats.OverallMemoryUsage*1MB/$_.ExtensionData.Summary.Hardware.MemorySize,0)}}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks for the code LucD .When I tried Get-VMHost | get-view or get-member I was not able to see the "ExtensionData.Summary.OverallStatus" part ......not sure how I can get these attributes
Regards
Pankaj
Strange, with Get-Member you should see the ExtensionData property.
You can also try with
Get-VMHost | Format-Custom -Depth 3
that will show the properties (3 levels deep) and their values.
In fact ExtensionData maps the HostSystem object.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference