VMware Cloud Community
panhvr
Contributor
Contributor
Jump to solution

ESXi host CPU and Memory Utilization report

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

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

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

View solution in original post

0 Kudos
4 Replies
panhvr
Contributor
Contributor
Jump to solution

Like  we get the report if we export if from the VC ,Unable to extract same format from get-vmhost power cli command 

Name

StateStatus% CPU% Memory
0 Kudos
LucD
Leadership
Leadership
Jump to solution

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

0 Kudos
panhvr
Contributor
Contributor
Jump to solution


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

0 Kudos
LucD
Leadership
Leadership
Jump to solution

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

0 Kudos