VMware Cloud Community
Vel_VMware
Enthusiast
Enthusiast

Need powerCLI script to get EXSTOP parameter

Hi,

Can some one help me with powercli script to get ESXTOP parameter and values in CSV format from all ES'Xi host in vCenter.

 

Thanks in advance.

Labels (1)
Reply
0 Kudos
8 Replies
vXav
Expert
Expert

What metrics are you after?

Reply
0 Kudos
Vel_VMware
Enthusiast
Enthusiast

Need for below parameters

1) CPU load average
2) %RDY

3) %CSTP

4)%USED

Thanks in advance.

Tags (1)
Reply
0 Kudos
vXav
Expert
Expert

You could use the Get-Stat cmdlet to do that. Below is a script that will make an average of the last 5 records (in 20 seconds intervals) as grabbing only the last record might be misleading I believe.

Although the %USED and average Usage metrics will pretty much give the same thing so you may have to tinker with the averages.

 

 

$AverageSize = 5

$Table = foreach ($VM in (Get-VM | where powerstate -eq poweredon)) {

    $USAGE =  (get-stat -Entity $VM -Stat cpu.usage.average -Realtime| where {!$_.instance}|select -last $AverageSize | Measure-Object -Property value -Average).average

    $RDY = (get-stat -Entity $VM -Stat cpu.ready.summation -Realtime| where {!$_.instance}|select -last $AverageSize | Measure-Object -Property value -Average).average/200

    $CSTP = (get-stat -Entity $VM -Stat cpu.costop.summation -Realtime| where {!$_.instance}|select -last $AverageSize | Measure-Object -Property value -Average).average/200

    $USED = (get-stat -Entity $VM -Stat cpu.used.summation -Realtime| where {!$_.instance}|select -last $AverageSize | Measure-Object -Property value -Average).average/200

    [pscustomobject]@{
        VM = $VM.name
        Usage = "$([math]::round($USAGE,2))%"
        "%RDY" = $RDY
        "%CSTP" = $CSTP
        "%USED" = $USED
    }

}

$Table | Export-Csv -Path C:\mycsv.csv -NoTypeInformation

 

 

 

Would something like that work for you? Of course you can always adapt it to your needs.

LucD
Leadership
Leadership

The Get-Stat cmdlet does not return esxtop data, for that you use the Get-EsxTop cmdlet.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
vXav
Expert
Expert

Isn't the end result similar?  Except for the fact that get-stat is "less real time" than esxtop.

And it's easier to use 🙂

Reply
0 Kudos
Vel_VMware
Enthusiast
Enthusiast

Is it enough to connect the vCenter in powercli to run this script ? Or Do I need to have access and connect to esxi host specifically to get this report?

Reply
0 Kudos
vXav
Expert
Expert

It is yes. Note that I just editted the script to fix a few things.

Also as @LucD  pointed out, this script does not use the actual esxtop on the hosts. If you absolutely need to use it for whatever reason it is a job for Get-EsxTop. I'm not too familiar with this cmdlet but I believe Luc wrote a fair bit of really good scripts with it!

Reply
0 Kudos
Vel_VMware
Enthusiast
Enthusiast

Thanks a lot for script. 

Let me check with your script first, if I am not getting desired output I will check with LuCD for how to use Get-EsxTop.

Reply
0 Kudos