Automation

 View Only
  • 1.  Need powerCLI script to get EXSTOP parameter

    Posted Feb 22, 2021 09:00 AM

    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.



  • 2.  RE: Need powerCLI script to get EXSTOP parameter

    Posted Feb 22, 2021 09:43 AM

    What metrics are you after?



  • 3.  RE: Need powerCLI script to get EXSTOP parameter

    Posted Feb 22, 2021 09:51 AM

    Need for below parameters

    1) CPU load average
    2) %RDY

    3) %CSTP

    4)%USED

    Thanks in advance.



  • 4.  RE: Need powerCLI script to get EXSTOP parameter

    Posted Feb 22, 2021 11:43 AM

    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.



  • 5.  RE: Need powerCLI script to get EXSTOP parameter

    Posted Feb 22, 2021 11:45 AM

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



  • 6.  RE: Need powerCLI script to get EXSTOP parameter

    Posted Feb 22, 2021 11:55 AM

    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



  • 7.  RE: Need powerCLI script to get EXSTOP parameter

    Posted Feb 23, 2021 09:16 AM

    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?



  • 8.  RE: Need powerCLI script to get EXSTOP parameter

    Posted Feb 23, 2021 09:31 AM

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

    Also as   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!



  • 9.  RE: Need powerCLI script to get EXSTOP parameter

    Posted Feb 23, 2021 09:41 AM

    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.