关于mpstat和vmstat的区别

来源:互联网 发布:饥荒数据修改 编辑:程序博客网 时间:2024/06/14 01:54

写本文的原因是http://blog.csdn.net/msdnchina/article/details/53926867

在该链接中,提到了用mpstat看到各个物理cpu使用的不均衡(有的已经在使用,有的基本没有用),然后我的疑问就出来了:mpstat是查看物理cpu使用率的?还是查看逻辑cpu使用率的?

于是我就做了一个实验:

[oracle@localhost ~]$ lscpuArchitecture:          x86_64CPU op-mode(s):        32-bit, 64-bitByte Order:            Little EndianCPU(s):                4On-line CPU(s) list:   0-3Thread(s) per core:    1Core(s) per socket:    2 ---->>>每个插槽2个Core.Socket(s):             2 ---->>>两个CPU插槽.NUMA node(s):          1Vendor ID:             GenuineIntelCPU family:            6Model:                 58Stepping:              9CPU MHz:               2494.399BogoMIPS:              4988.79Hypervisor vendor:     VMwareVirtualization type:   fullL1d cache:             32KL1i cache:             32KL2 cache:              256KL3 cache:              3072KNUMA node0 CPU(s):     0-3[oracle@localhost ~]$ mpstat -P ALL 1 5Linux 2.6.32-573.el6.x86_64 (localhost.localdomain) 12/27/2016 _x86_64_(4 CPU)05:07:25 PM  CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest   %idle05:07:26 PM  all    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00  100.0005:07:26 PM    0    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00  100.0005:07:26 PM    1    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00  100.0005:07:26 PM    2    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00  100.0005:07:26 PM    3    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00  100.0005:07:26 PM  CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest   %idle05:07:27 PM  all    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00  100.0005:07:27 PM    0    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00  100.0005:07:27 PM    1    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00  100.0005:07:27 PM    2    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00  100.0005:07:27 PM    3    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00  100.0005:07:27 PM  CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest   %idle05:07:28 PM  all    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00  100.0005:07:28 PM    0    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00  100.0005:07:28 PM    1    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00  100.0005:07:28 PM    2    0.00    0.00    1.00    0.00    0.00    0.00    0.00    0.00   99.0005:07:28 PM    3    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00  100.0005:07:28 PM  CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest   %idle05:07:29 PM  all    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00  100.0005:07:29 PM    0    0.00    0.00    0.99    0.00    0.00    0.00    0.00    0.00   99.0105:07:29 PM    1    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00  100.0005:07:29 PM    2    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00  100.0005:07:29 PM    3    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00  100.0005:07:29 PM  CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest   %idle05:07:30 PM  all    0.00    0.00    0.25    0.00    0.00    0.00    0.00    0.00   99.7505:07:30 PM    0    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00  100.0005:07:30 PM    1    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00  100.0005:07:30 PM    2    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00  100.0005:07:30 PM    3    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00  100.00Average:     CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest   %idleAverage:     all    0.00    0.00    0.05    0.00    0.00    0.00    0.00    0.00   99.95Average:       0    0.00    0.00    0.20    0.00    0.00    0.00    0.00    0.00   99.80Average:       1    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00  100.00Average:       2    0.00    0.00    0.20    0.00    0.00    0.00    0.00    0.00   99.80Average:       3    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00  100.00[oracle@localhost ~]$ --->>>从上面的结果看,mpstat是显示的逻辑cpu,而不是物理cpu.[oracle@localhost ~]$ uname -a Linux localhost.localdomain 2.6.32-573.el6.x86_64 #1 SMP Wed Jul 1 18:23:37 EDT 2015 x86_64 x86_64 x86_64 GNU/Linux[oracle@localhost ~]$ 
而vmstat只是所有逻辑cpu的一个总体使用率,如下:
[oracle@localhost ~]$ vmstat 1 5procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu----- r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st 1  0      0 1731664  15580  71568    0    0    27     1   27   16  0  1 98  1  0 0  0      0 1731616  15580  71596    0    0     0     0   31   23  0  0 100  0  0 0  0      0 1731616  15580  71596    0    0     0     0   22   17  0  0 100  0  0 0  0      0 1731616  15580  71596    0    0     0     0   17   17  0  0 100  0  0 0  0      0 1731616  15580  71596    0    0     0     0   25   24  0  0 100  0  0[oracle@localhost ~]$ 


0 0