Linux mpstat命令详解
本文讲解基于centos8进行,mpstat用法和其他linux系统基本一致,只是安装命令不同。
mpstat是MultiProcessor Statistics的缩写,是实时系统监控工具。其报告与CPU的一些统计信息,这些信息存放在/proc/stat文件中。在多CPUs系统里,其不但能查看所有CPU的平均状况信息,而且能够查看特定CPU的信息。
mpstat命令安装
安装命令:
sudo yum install sysstat
mpstat 常用参数
常用命令:
查看当前主机所有cpu 负载情况
mpstat -P ALL
查看当前主机某一个cpu 负载
mpstat -P 0
每隔5秒内输出cpu负载信息,并采样10次
mpstat -P ALL 5 10
输出参数解释
输出参数 | 备注 |
---|---|
cpu | 表示cpu序号 |
%user | Show the percentage of CPU utilization that occurred while executing at the user level (application) 执行用户层(应用)发生的CPU使用率百分比 |
%nice | Show the percentage of CPU utilization that occurred while executing at the user level with nice priority. 执行用户层(带有nice优先级应用)发生的CPU使用率百分比 |
%sys | Show the percentage of CPU utilization that occurred while executing at the system level (kernel). Note that this does not include time spent servicing hardware and software interrupts执行内核层(不包含硬件中断和软中断)发生的cpu使用率百分比 |
%iowait | how the percentage of time that the CPU or CPUs were idle during which the system had an outstanding disk I/O request CPU在等待磁盘I/O请求时的空闲时间百分比 |
%irq | Show the percentage of time spent by the CPU or CPUs to service hardware interrupts.硬件中断的CPU利用率百分比 |
%soft | Show the percentage of time spent by the CPU or CPUs to service software interrupts 软中断的cpu利用率百分比 |
%steal | Show the percentage of time spent in involuntary wait by the virtual CPU or CPUs while the hypervisor was servicing another virtual processor CPU花在非自愿等待宿主机为其他虚拟CPU提供服务的时间百分比 |
%guest | Show the percentage of time spent by the CPU or CPUs to run a virtual processor 运行虚拟CPU的时间百分比 |
%g | Show the percentage of time spent by the CPU or CPUs to run a niced guest 运行带有nice优先级的虚拟CPU |
%idle | Show the percentage of time that the CPU or CPUs were idle and the system did not have an outstanding disk I/O request.CPU空间时间占比 |
不包含虚拟化的情况下:总cpu时间片 = user + nice + system + iowait + irq + softirq + idle