PowerCLI

 View Only
  • 1.  Using Get-EsxTop to get NetWorld CPU

    Posted Feb 15, 2019 05:23 AM

    Hi All,

    Currently I use ESXTOP via ssh and use the expand function using the GID of a VM the get the individual worlds that make up a VM, I'm interested is capturing the %USED CPU of the 4 NetWorld processed as this VM has 4 NICs

    I'd like to know if I could use Get-EsxTop to capture CPU %USED on the NetWorld of a VM?



  • 2.  RE: Using Get-EsxTop to get NetWorld CPU
    Best Answer

    Posted Feb 15, 2019 07:30 AM

    Yes, you can, although it is not too obvious.
    See for example my Hitchhiker’s Guide To Get-EsxTop – Part 1 post.



  • 3.  RE: Using Get-EsxTop to get NetWorld CPU

    Posted Feb 15, 2019 09:16 AM

    Thanks Luc,

    So I'm making some progress I just need to figure out how to get the world for the NetWorld.. In addition I needed to change a bit of the code to get the VMXCartelID by replacing $esxcli.vms.vm.list() with $esxcli.vm.process.list() I'm on 6.7 perhaps its changed

    Would you be able to help with getting the NetWorld ?

    $vmName = "MyVMName"

    $esxcli = Get-EsxCli

    $vmxid = $esxcli.vm.process.list() | where {$_.DisplayName -eq $vmName} | Select VMXCartelID

    $esxtopInterval = 5

    $conversion = 100 / (1e6 * $esxtopInterval)

    $first = $true

    $report = @()

    for ($i = 0; $i -lt 10; $i++) {

       $stats = Get-EsxTop -CounterName VCPU | where {$_.VCPUID -eq $vmxid.VMXCartelID}

       if (!$first) {

       $row = "" | Select VCPUID, WorldName, Run, Ready

       $row.VCPUID = $stats.VCPUID

       $row.WorldName = $stats.WorldName

       $row.run = "{0:p1}" -f (($stats.RunTimeInUsec - $run) * $conversion)

       $row.ready = "{0:p1}" -f (($stats.ReadyTimeInUsec - $ready) * $conversion)

       $report += $row

      }

       else {

       $first = $false

      }

       $run = $stats.RunTimeInUsec

       $ready = $stats.ReadyTimeInUsec

      sleep $esxtopInterval

    }

    $report | ft -AutoSize



  • 4.  RE: Using Get-EsxTop to get NetWorld CPU

    Posted Feb 15, 2019 09:36 AM

    Not sure I get what you mean by "Networld"?



  • 5.  RE: Using Get-EsxTop to get NetWorld CPU

    Posted Feb 15, 2019 09:41 AM

    Hi Luc,

    You know with ESXTOP you can hit 'e' to expand all the worlds that make up the VM, if you see attached screenshot there is one world here called 'NetWorld-VM-209' I want the %USED cpu for that world if possible?



  • 6.  RE: Using Get-EsxTop to get NetWorld CPU

    Posted Feb 15, 2019 09:46 AM

    Ok, got it, these are Tx threads for VM-to-VM communication.
    Let me check.



  • 7.  RE: Using Get-EsxTop to get NetWorld CPU

    Posted Feb 15, 2019 09:51 AM

    Hey Luc,

    Exactly, I should have mentioned they were Tx threads. anyway if I manually specify the ID as per the screenshot I think it works but of course I need a way getting this ID



  • 8.  RE: Using Get-EsxTop to get NetWorld CPU

    Posted Feb 15, 2019 12:43 PM

    Try the following.
    I used a -contains operator since a VM can have more than 1 Tx thread.

    $vmName = "MyVM"

    $vm = Get-VM -Name $vmName

    $esxcli = Get-EsxCli -VMHost $vm.VMHost -V2

    $vmxid = $esxcli.vm.process.list.Invoke() | where {$_.DisplayName -eq $vmName} | Select VMXCartelID

    $group = (Get-EsxTop -TopologyInfo -Topology SchedGroup).Entries |

       where {$_.GroupName -match "vm.$($vmxid.VMXCartelID)"}

    $networldId = $group.CPUClient | where {$_.VCPUName -match "^Networld-"} | Select -ExpandProperty CPUClientID

    $esxtopInterval = 5

    $conversion = 100 / (1e6 * $esxtopInterval)

    $first = $true

    $report = @()

    for ($i = 0; $i -lt 10; $i++) {

       $stats = Get-EsxTop -CounterName VCPU | where {$networldId -contains $_.VCPUID}

       if (!$first) {

       $row = "" | Select VCPUID, WorldName, Run, Ready

       $row.VCPUID = $stats.VCPUID

       $row.WorldName = $stats.WorldName

       $row.run = "{0:p1}" -f (($stats.RunTimeInUsec - $run) * $conversion)

       $row.ready = "{0:p1}" -f (($stats.ReadyTimeInUsec - $ready) * $conversion)

       $report += $row

       }

       else {

       $first = $false

       }

       $run = $stats.RunTimeInUsec

       $ready = $stats.ReadyTimeInUsec

      sleep $esxtopInterval

    }


    $report | ft -AutoSize



  • 9.  RE: Using Get-EsxTop to get NetWorld CPU

    Posted Feb 17, 2019 12:37 AM

    Hi Luc,

    Seems to work well, just wondering though what would I need to do to get %USED rather than %RUN ?



  • 10.  RE: Using Get-EsxTop to get NetWorld CPU

    Posted Feb 17, 2019 08:51 PM

    Try like this.
    The mappings between the properties and the columns in esxtop can be found in my Hitchhiker’s Guide To Get-EsxTop – Part 2 – The Wrapper post.

    Note that the list is not an official document, something that a previous PowerCLI PM seems to have left laying around :smileygrin:

    $vmName = "MyVM"

    $vm = Get-VM -Name $vmName

    $esxcli = Get-EsxCli -VMHost $vm.VMHost -V2

    $vmxid = $esxcli.vm.process.list.Invoke() | where {$_.DisplayName -eq $vmName} | Select VMXCartelID

    $group = (Get-EsxTop -TopologyInfo -Topology SchedGroup).Entries |

       where {$_.GroupName -match "vm.$($vmxid.VMXCartelID)"}

    $networldId = $group.CPUClient | where {$_.VCPUName -match "^Networld-"} | Select -ExpandProperty CPUClientID

    $esxtopInterval = 5

    $conversion = 100 / (1e6 * $esxtopInterval)

    $first = $true

    $report = @()

    for ($i = 0; $i -lt 3; $i++) {

       $stats = Get-EsxTop -CounterName VCPU | where {$networldId -contains $_.VCPUID}

       if (!$first) {

       $row = "" | Select VCPUID, WorldName, Run, Ready, '%USED'

       $row.VCPUID = $stats.VCPUID

       $row.WorldName = $stats.WorldName

       $row.run = "{0:p1}" -f (($stats.RunTimeInUsec - $run) * $conversion)

       $row.ready = "{0:p1}" -f (($stats.ReadyTimeInUsec - $ready) * $conversion)

       $row.'%USED' = "{0:p1}" -f (($stats.UsedTimeInUsec - $used) * $conversion)

       $report += $row

       }

       else {

       $first = $false

       }

       $run = $stats.RunTimeInUsec

       $ready = $stats.ReadyTimeInUsec

       $used = $stats.UsedTimeInUsec

      sleep $esxtopInterval

    }


    $report | ft -AutoSize