PowerCLI

 View Only
  • 1.  Get CPU MHz of a VM

    Posted Dec 03, 2019 12:39 PM

    Hi All.

    I found some hints to get CPU MHz Infos. All of them (until now) based on the VM host values. They are wrong from guest point of view. The host values are more less statistic values, if I follow those example:

              Get-VM "<guest name>" | Select-Object -Property Name,@{Name='MaxHostCpuMhz';Expression={$_.NumCpu * $_.VMHost.CpuTotalMhz / $_.VMHost.NumCpu}}

              ProcessorType: Intel(R) Xeon(R) Gold 6146 CPU @ 3.20GHz

    If I have a look on the guest side with dmiodecode --type processor, I have complete different values:

              Manufacturer: GenuineIntel

              Version:        Intel(R) Xeon(R) CPU E7- 4807  @ 1.87GHz

    How can I get the real / current guest values with the Power CLI and there options?

    Thanks for a short example, I guess with Invoke-Script... A link to more detailed tutorial using Invoke-Script on guest systems would perhaps help also.

    Volker



  • 2.  RE: Get CPU MHz of a VM

    Posted Dec 03, 2019 01:28 PM

    Not sure if im understanding exactly what youre wanting but if youre looking for current utilization values then you could use get-stat e.g.

    Get-stat -entity $_ -Stat cpu.usage.average -Realtime -MaxSamples 1



  • 3.  RE: Get CPU MHz of a VM

    Posted Dec 04, 2019 11:28 AM

    Hi T180985.

    I want no monitoring values about a VM. I want only get the CPU values (MHz / Type) from VM point of view. To calculate values based on the host  data is perhaps not the real view.



  • 4.  RE: Get CPU MHz of a VM

    Posted Dec 03, 2019 02:28 PM

    Do you get different values when you run this?

    Get-VM <MyVM> |

    Select-Object -Property Name,

        @{N='vCPUMhz';E={$_.ExtensionData.Runtime.MaxCpuUsage/$_.NumCpu}},

        @{Name='HostCpuMhz';Expression={$_.VMHost.CpuTotalMhz / $_.VMHost.NumCpu}}

    I get (on an Ubuntu box with 2 vCPU)

    And this corresponds with what dmidecode tells me.



  • 5.  RE: Get CPU MHz of a VM

    Posted Dec 04, 2019 10:53 AM

    Hi LucD

    I get vCPUMhz = 0 and HostCpuMhz is empty (or null)



  • 6.  RE: Get CPU MHz of a VM

    Posted Dec 04, 2019 11:26 AM

    What is this returning?

    Get-VM MyVM |

    Select-Object -Property Name,NumCpu,CoresPerSocket,

        @{N='MaxCPUMhz';E={$_.ExtensionData.Runtime.MaxCpuUsage}},

        @{N='VMHostNumCpu';E={$_.VMHost.NumCpu}},

        @{N='HostCpuMhz';E={$_.VMHost.CpuTotalMhz}}



  • 7.  RE: Get CPU MHz of a VM

    Posted Dec 04, 2019 11:32 AM
    Name       : my vm name
    NumCpu     : 2

    CoresPerSocket : 1

    MaxCPUMhz  : 6384

    VMHostNumCpu   : 16

    HostCpuMhz : 51072


  • 8.  RE: Get CPU MHz of a VM
    Best Answer

    Posted Dec 04, 2019 11:53 AM

    I don't understand why you would be getting 0 if the individual values are what you show here.

    There are 2 types of objects in PowerCLI.

    1. The .Net objects, which are returned by PowerCLI cmdlets, and which are documented in the Types online help.
    2. The vSphere objects, reachable from the .Net objects via the ExtensionData property (or via the Get-View cmdlet). They are documented in the vSphere API Reference.


  • 9.  RE: Get CPU MHz of a VM

    Posted Dec 04, 2019 12:39 PM

    I "solved" for now with the values from:

    $cpuType   = $vm.VMHost.ProcessorType
    $cpuMaxMhz = [String] ([convert]::ToInt32($vm.ExtensionData.Runtime.MaxCpuUsage) / [convert]::ToInt32($vm.NumCpu))

    inside my script.

    It's ok for now, but in fact I would prefer the values from a dmidecode. I guess, I need to do it anyway with Invoke-Script, because I also need the guests BIOS values...



  • 10.  RE: Get CPU MHz of a VM

    Posted Dec 04, 2019 01:07 PM

    Yes, that would be the way to go.



  • 11.  RE: Get CPU MHz of a VM

    Posted Dec 04, 2019 11:43 AM

    Hi LucD.

    Exist somewhere a link to a full description abount the data model useable by PowerCLI? I think, (no, I know :smileywink:) if I a have look at this, I know than what is possible and what not?