VMware Cloud Community
jpoconnor
Contributor
Contributor
Jump to solution

Confused about how to get CpuTotalMHz for a VMHost (not a VM)

I am new to PowerCLI and have been trying for a few days to get a list of Clusters, associated VMHosts in the cluster, with details about each VMHost, but I can't get all of the details.  I'm looking for CPU info at the VMHost level, not the VMGuest level.  he script returns blanks instead of data.

Can someone point me in the right direction here?

For example, when I run the script below, the two last fields (CpuTotalMhz and NumCpu) are blank!

Cluster.Name and VMHost.Name are populated correctly.

When I look at the PowerCLI Cmdlet Reference (vSphere 5.5) for VMHost it shows a bunch of properties, but most of them seem unaccessible.

No error messages, just empty fields.

$report = @()

foreach($Cluster in Get-Cluster){
     Get-VMHost -Location $cluster | %{
         $info = "" | select Cluster, VMhost, CpuTotalMhz, NumCpu
         $info.Cluster = $cluster.Name
         $info.VMHost = $_.Name
         $info.CpuTotalMhz = $_.CpuTotalMhz
         $info.NumCpu = $_.NumCpu
         $report += $info
     }
}

$report | Export-Csv "C:\tmp\vmware-reports\Cluster-Host.csv" -NoTypeInformation -UseCulture

I've tried drilling down at the command line on the object generated by Get-View, but can't find where VMHost level CPU, RAM, etc information is available.

[VI Toolkit] C:\tmp\vmware-reports>$VMHost = get-view -viewtype HostSystem -filter @{"Name"="esxhost.company.com"}

[VI Toolkit] C:\tmp\vmware-reports>$VMHost

Runtime             : VMware.Vim.HostRuntimeInfo
Summary             : VMware.Vim.HostListSummary
Hardware            : VMware.Vim.HostHardwareInfo
Capability          : VMware.Vim.HostCapability
ConfigManager       : VMware.Vim.HostConfigManager
Config              : VMware.Vim.HostConfigInfo
Vm                  : {VMware.Vim.ManagedObjectReference, VMware.Vim.ManagedObjectReference, VMware.Vim.ManagedObjectRe
                      ference, VMware.Vim.ManagedObjectReference...}
Datastore           : {VMware.Vim.ManagedObjectReference, VMware.Vim.ManagedObjectReference, VMware.Vim.ManagedObjectRe
                      ference, VMware.Vim.ManagedObjectReference...}
Network             : {VMware.Vim.ManagedObjectReference, VMware.Vim.ManagedObjectReference}
DatastoreBrowser    : VMware.Vim.ManagedObjectReference
SystemResources     : VMware.Vim.HostSystemResourceInfo
Parent              : VMware.Vim.ManagedObjectReference
CustomValue         : {}
OverallStatus       : green
ConfigStatus        : green
ConfigIssue         : {}
EffectiveRole       : {-2}
Permission          : {}
Name                : esxhost.company.com
DisabledMethod      : {ExitMaintenanceMode_Task, PowerUpHostFromStandBy_Task, ReconnectHost_Task}
RecentTask          : {}
DeclaredAlarmState  : {alarm-1.host-738, alarm-12.host-738, alarm-13.host-738, alarm-14.host-738...}
TriggeredAlarmState : {}
Value               : {}
AvailableField      : {Bad Memory module}
MoRef               : VMware.Vim.ManagedObjectReference
Client              : VMware.Vim.VimClient

[VI Toolkit] C:\tmp\vmware-reports> $VMHost.HArdware


SystemInfo      : VMware.Vim.HostSystemInfo
CpuInfo         : VMware.Vim.HostCpuInfo
CpuPkg          : {0 1 2 3, 4 5 6 7}
MemorySize      : 51537383424
NumaInfo        : VMware.Vim.HostNumaInfo
PciDevice       : {12:00.0, 12:00.1, 00:1d.0, 00:1d.1...}
CpuFeature      : {VMware.Vim.HostCpuIdInfo, VMware.Vim.HostCpuIdInfo, VMware.Vim.HostCpuIdInfo, VMware.Vim.HostCpuIdIn
                  fo...}
BiosInfo        : VMware.Vim.HostBIOSInfo
DynamicType     :
DynamicProperty :

[VI Toolkit] C:\tmp\vmware-reports> $VMHost.Hardware.CpuFeature


Level           : 0
Vendor          :
Eax             : 0000:0000:0000:0000:0000:0000:0000:1010
Ebx             : 0111:0101:0110:1110:0110:0101:0100:0111
Ecx             : 0110:1100:0110:0101:0111:0100:0110:1110
Edx             : 0100:1001:0110:0101:0110:1110:0110:1001
DynamicType     :
DynamicProperty :

Level           : 1
Vendor          :
Eax             : 0000:0000:0000:0001:0000:0110:0111:0110
Ebx             : 0000:0000:0000:0100:0000:1000:0000:0000
Ecx             : 0000:0000:0000:1100:1110:0011:1011:1101
Edx             : 1011:1111:1110:1011:1111:1011:1111:1111
DynamicType     :
DynamicProperty :

Level           : -2147483648
Vendor          :
Eax             : 1000:0000:0000:0000:0000:0000:0000:1000
Ebx             : 0000:0000:0000:0000:0000:0000:0000:0000
Ecx             : 0000:0000:0000:0000:0000:0000:0000:0000
Edx             : 0000:0000:0000:0000:0000:0000:0000:0000
DynamicType     :
DynamicProperty :

Level           : -2147483647
Vendor          :
Eax             : 0000:0000:0000:0000:0000:0000:0000:0000
Ebx             : 0000:0000:0000:0000:0000:0000:0000:0000
Ecx             : 0000:0000:0000:0000:0000:0000:0000:0001
Edx             : 0010:0000:0000:0000:0000:1000:0000:0000
DynamicType     :
DynamicProperty :

Level           : -2147483640
Vendor          :
Eax             : 0000:0000:0000:0000:0011:0000:0010:0110
Ebx             : 0000:0000:0000:0000:0000:0000:0000:0000
Ecx             : 0000:0000:0000:0000:0000:0000:0000:0000
Edx             : 0000:0000:0000:0000:0000:0000:0000:0000
DynamicType     :
DynamicProperty :

Thanks

-- Joe

Reply
0 Kudos
1 Solution

Accepted Solutions
sneddo
Hot Shot
Hot Shot
Jump to solution

Your script works for me (PowerCLI 6.0 R2 and 5.5 hosts)...

I've tried drilling down at the command line on the object generated by Get-View, but can't find where VMHost level CPU, RAM, etc information is available.

You were close, you can look at $vmhost.hardware.Memorysize for size in Bytes. CPU info is $vmhost.hardware.CPUInfo, where you will find socket and core count, threads and speed in Hz

View solution in original post

Reply
0 Kudos
2 Replies
sneddo
Hot Shot
Hot Shot
Jump to solution

Your script works for me (PowerCLI 6.0 R2 and 5.5 hosts)...

I've tried drilling down at the command line on the object generated by Get-View, but can't find where VMHost level CPU, RAM, etc information is available.

You were close, you can look at $vmhost.hardware.Memorysize for size in Bytes. CPU info is $vmhost.hardware.CPUInfo, where you will find socket and core count, threads and speed in Hz

Reply
0 Kudos
jpoconnor
Contributor
Contributor
Jump to solution

>> PowerCLI 6.0 R2 and 5.5 hosts

Ahhh.... that was the clue.  I was running a really old version of PowerCLI.  (Toolkit 1.5... yikes!)

Thanks!  Upgraded to PowerCLI 6.0 R1 and it works fine.  A whole lot fast too!

Reply
0 Kudos