You can use the Get-EsxTop cmdlet to retrieve
real-time data for troubleshooting performance problems on your ESXi hosts.
The Get-EsxTop
cmdlet exposes the esxtop functionality that provides real-time
monitoring and performance analysis of an ESXi
host's resources. You can use esxtop to gain insights into the
performance and resource utilization of virtual machines and the underlying
hardware.Prerequisites
Verify that you are connected
to a server that runs ESX 4.1,
vCenter
Server
5.0 or later.
Procedure
-
Get the group to which
the virtual machine belongs and save it as a variable.
$group = Get-EsxTop -CounterName SchedGroup | where {$_.VMName -eq $vm.Name}
-
Get the IDs of all
virtual CPUs of the virtual machine and store them in an array.
$gr = Get-EsxTop -TopologyInfo -Topology SchedGroup | %{$_.Entries} | where {$group.GroupID -contains $_.GroupId} $group.GroupID
$cpuIds = @()
$gr.CpuClient | %{$cpuIds += $_.CPUClientID}
-
Get the CPU statistics
for the virtual machine.
$cpuStats = Get-EsxTop -CounterName VCPU | where {$cpuIds -contains $_.VCPUID}
-
Calculate the used and
ready for use percentage by using the
UsedTimeInUsec and
ReadyTimeInUsec stats.
$result = @()
$cpuStats | %{ `
$row = "" | select VCPUID, Used, Ready; `
$row.VCPUID = $_.VCPUID; `
$row.Used = [math]::Round(([double]$_.UsedTimeInUsec/[double]$_.UpTimeInUsec)*100, 2); `
$row.Ready = [math]::Round(([double]$_.ReadyTimeInUsec/[double]$_.UpTimeInUsec)*100, 2);`
$result += $row
}
-
View the used and ready
for use percentage for each virtual CPU of the virtual machine.
$result | Format-Table –AutoSize