Automation

 View Only
  • 1.  Get-stat each esx physcial CPU usage

    Posted Jul 11, 2017 04:37 AM

    Hi,

    I have esxi server with 32 processor (logical, HT enabled) and how do I get per processor usage average using powercli (same as displayed in vcenter CPU realtime usage stats)



  • 2.  RE: Get-stat each esx physcial CPU usage

    Posted Jul 11, 2017 04:41 AM

    Try like this

    Get-VMHost |

    Get-Stat -Realtime -Stat 'cpu.usage.average' -MaxSamples 1 -Instance '' |

    Select @{N='ESXi';E={$_.Entity.Name}},Value



  • 3.  RE: Get-stat each esx physcial CPU usage

    Posted Jul 11, 2017 07:24 AM

    Thanks for replying Luc.

    This script gives only one value per ESXi, I believe its average of all processor usage.

    But my requirement was CPU usage "per processor" in my ESXi at the time I run the script. Basically i'm trying to get something like PCPU USED% in ESXTOP where it shows up all 32 processor usage individually in a line and a average atlast. This can also been seen in vcenter when we select a ESXi host and then performance CPU in realtime. We can see all the processor named as 0,1,2.... and we can see the average for every processor.



  • 4.  RE: Get-stat each esx physcial CPU usage

    Posted Jul 11, 2017 08:00 AM

    Yes, that is correct, the above lines give the average per ESXi.

    If you want to see values for all cores, you could do

    Get-VMHost |

    Get-Stat -Realtime -Stat 'cpu.usage.average' -MaxSamples 1 |

    where{$_.Instance -ne ''} |

    Select @{N='ESXi';E={$_.Entity.Name}},Timestamp,Instance,Value

    Since you mentioned esxtop and PCPU, you might also want to have a look at Get-EsxTop – Another Look



  • 5.  RE: Get-stat each esx physcial CPU usage

    Posted Jul 11, 2017 10:36 AM

    Thanks Luc, its this one I was looking for.

    Just one question how to "numeric" sort the field Instance? When I use sort-object on instance it sorts like 0,1,11,12... Instead I need 0,1,2,3,4....

    Should we declare "instance" as [int] ?



  • 6.  RE: Get-stat each esx physcial CPU usage
    Best Answer

    Posted Jul 11, 2017 10:39 AM

    Yes, something like this for example

    Get-VMHost |

    Get-Stat -Realtime -Stat 'cpu.usage.average' -MaxSamples 1 |

    where{$_.Instance -ne ''} |

    Select @{N='ESXi';E={$_.Entity.Name}},Timestamp,@{N='Instance';E={[int]$_.Instance}},Value |

    Sort-Object -Property ESXi,Instance



  • 7.  RE: Get-stat each esx physcial CPU usage

    Posted Jul 13, 2017 03:33 AM

    Thanks Luc, works good.