mpstat 解释可以通过 man mpstat
查看。
描述:mpstat (multiprocessor state) 可以查看所有cpu的平均负载,也可以查看指定cpu的负载。所以mpstat其实就是主要查看CPU负载的一个工具。
tangs@ubuntu:~$ mpstat
Linux 4.15.0-36-generic (ubuntu) Wednesday, January 09, 2019 _x86_64_ (2 CPU)
10:29:37 PST CPU %usr %nice %sys %iowait %irq %soft %steal %guest %gnice %idle
10:29:37 PST all 0.22 0.11 1.73 0.62 0.00 0.11 0.00 0.00 0.00 97.22
- 显示参数解释
paramter | 描述 |
---|---|
CPU | 显示是某个CPU,还是全部CPU |
%usr | 用户空间程序CPU的占用 |
%nice | 用户空间具有高优先级的程序CPU占用,应该是指nice小于0的程序 |
%sys | 内核空间CPU占用,不包括软中断和硬中断上的消耗 |
%iowait | CPU在系统收到外部IO请求时空闲的时间占比 |
%irq | CPU硬中断占比 |
%soft | CPU软终端的占比 |
%steal | 显示虚拟机管理程序为另一个虚拟处理器提供服务时虚拟CPU或CPU在非自愿等待中花费的时间百分比,翻译的,暂时理解不了 |
%guest | CPU运行虚拟器的占比 |
%gnice | CPU运行niced guest虚拟机所花费的时间百分比, 这个待定,对应是高优先级的虚拟器程序? |
%idle | CPU空间并且没有IO等待的占比 |
- 指定查看某个CPU的占用,从0计数,
mpstat -P { cpu_list | ON | ALL }
### cpu_list 指CPU编号,从0开始
### ON 显示每个CPU和所有CPU的负载
### ALL 显示所有CPU的负载
tangs@ubuntu:~$ mpstat -P 0
Linux 4.15.0-43-generic (ubuntu) Tuesday, January 22, 2019 _x86_64_ (4 CPU)
01:20:37 PST CPU %usr %nice %sys %iowait %irq %soft %steal %guest %gnice %idle
01:20:37 PST 0 3.31 0.01 7.10 0.36 0.00 0.40 0.00 0.00 0.00 88.81
- 通过json输出
tangs@ubuntu:~$ mpstat -o JSON -P 0
{"sysstat": {
"hosts": [
{
"nodename": "ubuntu",
"sysname": "Linux",
"release": "4.15.0-43-generic",
"machine": "x86_64",
"number-of-cpus": 4,
"date": "Tuesday, January 22, 2019",
"statistics": [
{
"timestamp": "01:27:03 PST",
"cpu-load": [
{"cpu": "0", "usr": 3.28, "nice": 0.01, "sys": 7.00, "iowait": 0.35, "irq": 0.00, "soft": 0.40, "steal": 0.00, "guest": 0.00, "gnice": 0.00, "idle": 88.96}
]
}
]
}
]
}}
-------------------------- 分割线 --------------------------
- -N:关于NUMA暂时不清楚
- -I: 解释没看完