ESXI 如何查看 CPU 使用率

问题描述

我正在尝试获取运行 VMware ESXi 6.7.0 Update 3 的服务器的总 cpu 使用率以监控性能

我能够使用命令查看内存使用情况 - vsish -e get /memory/comprehensive

但是,我找不到 cpu 使用率的命令。没有顶部命令或 /proc/stat 文件

有什么方法可以获得这些信息吗?

谢谢

解决方法

我使用的是 ESXi 6.0.0U2,在浏览了 vsish 节点后,我在电源/pcpu 树中找到了一些相关信息。

[root@server:~] vsish -e ls power
policy/
pcpu/
hardwareSupport
hostStats
resetStats
currentPolicy
[root@server:~] vsish -e ls power/pcpu
0/
1/
2/
3/
4/
5/
6/
7/
8/
9/
10/
11/
12/
13/
14/
15/

我的服务器有 8 个超线程 CPU,因此 ESXi 中显示 16 个虚拟核心。下面是它显示的关于第一个核心的内容:

[root@server:~] vsish -e ls power/pcpu/0
cstate/
tstate/
pstate/
cres
perf
state
[root@server:~] vsish -e get power/pcpu/0/perf
PCPU performance statistics {
   PCPU core busy (current frequency): 40 %
   PCPU core busy (maximum frequency): 40 %
   APERF/MPERF ratio: -1 %
   Halted time: 176111536370 usec
}

也许有更好的方法可以做到这一点,但这会显示所有内核的信息:

[root@server:~] vsish -e get $(printf 'power/pcpu/%sperf ' $(vsish -e ls power/pcpu))
PCPU performance statistics {
   PCPU core busy (current frequency): 100 %
   PCPU core busy (maximum frequency): 100 %
   APERF/MPERF ratio: -1 %
   Halted time: 175721833728 usec
}
PCPU performance statistics {
   PCPU core busy (current frequency): 100 %
   PCPU core busy (maximum frequency): 100 %
   APERF/MPERF ratio: -1 %
   Halted time: 188174562097 usec
}
PCPU performance statistics {
   PCPU core busy (current frequency): 24 %
   PCPU core busy (maximum frequency): 24 %
   APERF/MPERF ratio: -1 %
   Halted time: 174102490208 usec
}
PCPU performance statistics {
   PCPU core busy (current frequency): 20 %
   PCPU core busy (maximum frequency): 20 %
   APERF/MPERF ratio: -1 %
   Halted time: 187428554783 usec
}
PCPU performance statistics {
   PCPU core busy (current frequency): 65 %
   PCPU core busy (maximum frequency): 65 %
   APERF/MPERF ratio: -1 %
   Halted time: 172642150099 usec
}
PCPU performance statistics {
   PCPU core busy (current frequency): 55 %
   PCPU core busy (maximum frequency): 55 %
   APERF/MPERF ratio: -1 %
   Halted time: 185952136508 usec
}
PCPU performance statistics {
   PCPU core busy (current frequency): 100 %
   PCPU core busy (maximum frequency): 100 %
   APERF/MPERF ratio: -1 %
   Halted time: 172496627680 usec
}
PCPU performance statistics {
   PCPU core busy (current frequency): 100 %
   PCPU core busy (maximum frequency): 100 %
   APERF/MPERF ratio: -1 %
   Halted time: 185168370294 usec
}
PCPU performance statistics {
   PCPU core busy (current frequency): 100 %
   PCPU core busy (maximum frequency): 100 %
   APERF/MPERF ratio: -1 %
   Halted time: 174843857000 usec
}
PCPU performance statistics {
   PCPU core busy (current frequency): 100 %
   PCPU core busy (maximum frequency): 100 %
   APERF/MPERF ratio: -1 %
   Halted time: 188132157292 usec
}
PCPU performance statistics {
   PCPU core busy (current frequency): 32 %
   PCPU core busy (maximum frequency): 32 %
   APERF/MPERF ratio: -1 %
   Halted time: 174204368068 usec
}
PCPU performance statistics {
   PCPU core busy (current frequency): 63 %
   PCPU core busy (maximum frequency): 63 %
   APERF/MPERF ratio: -1 %
   Halted time: 185497348425 usec
}
PCPU performance statistics {
   PCPU core busy (current frequency): 43 %
   PCPU core busy (maximum frequency): 43 %
   APERF/MPERF ratio: -1 %
   Halted time: 172301626490 usec
}
PCPU performance statistics {
   PCPU core busy (current frequency): 44 %
   PCPU core busy (maximum frequency): 44 %
   APERF/MPERF ratio: -1 %
   Halted time: 185424645378 usec
}
PCPU performance statistics {
   PCPU core busy (current frequency): 40 %
   PCPU core busy (maximum frequency): 40 %
   APERF/MPERF ratio: -1 %
   Halted time: 172333434508 usec
}
PCPU performance statistics {
   PCPU core busy (current frequency): 41 %
   PCPU core busy (maximum frequency): 41 %
   APERF/MPERF ratio: -1 %
   Halted time: 184481550403 usec
}

如果您正在寻找所有内核的平均 CPU 使用率百分比,我还没有直接找到,但您可以计算它:

[root@server:~] vsish -e get $(printf 'power/pcpu/%sperf ' $(vsish -e ls power/pcpu)) | awk '/current/ {cpus+=1;total+=$6} END {print total/cpus "%"}'
78.125%

我也一直想知道这一点,但我不知道 vsish 命令,所以感谢您指出。

,

但是,我找不到 CPU 使用率的命令。没有顶部命令或...

有一个 top 命令,但它是“esxtop”。有关最新文档,请参阅 https://docs.vmware.com/en/VMware-vSphere/7.0/com.vmware.vsphere.monitoring.doc/GUID-D89E8267-C74A-496F-B58E-19672CAB5A53.html。请注意,尽管这是 ESXi 7.0 esxtop 的文档已经存在了十多年,因此您应该可以在 ESXi 6.7 中使用。