Total CPU usage - multicore system

☆樱花仙子☆ 提交于 2021-02-08 15:54:32

问题


I am using xen and with xen top I get the total CPU usage in percentage:

      NAME  STATE   CPU(sec) CPU(%)     MEM(k) MEM(%)  MAXMEM(k) MAXMEM(%) VCPUS NETS NETTX(k) NETRX(k) VBDS   VBD_OO   VBD_RD   VBD_WR  VBD_RSECT  VBD_WSECT SSID

      VM1 -----r      25724  299.4    3025244   12.0   20975616      83.4    12    1 14970253 27308358    1        3   146585    92257   10835706    9976308    0

As you can see from above I see the CPU usage is 299 %, but how I can get the total CPU usage from a VM ? Top doesn't show me the total usage.


回答1:


We usually see 100% cpu per core. I guess there are at least 3 cores/cpus.

try this to count cores:

grep processor /proc/cpuinfo | wc -l

299% is the total cpu usage.

sar and mpstat are often used to display cpu usage of a system. Check that systat package is installed and display total cpu usage with:

$ mpstat 1 1
Linux 2.6.32-5-amd64 (debian)   05/01/2016      _x86_64_        (8 CPU)

07:48:51 PM  CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest   %idle
07:48:52 PM  all    0.12    0.00    0.50    0.00    0.00    0.00    0.00    0.00   99.38
Average:     all    0.12    0.00    0.50    0.00    0.00    0.00    0.00    0.00   99.38

If you agree that CPU utilisation is (100 - %IDLE):

$ mpstat 1 1 | awk '/^Average/ {print 100-$NF,"%"}'
0.52 %


来源:https://stackoverflow.com/questions/36952812/total-cpu-usage-multicore-system

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!