cpustat
是一个用于显示 CPU 统计信息的工具,它是 sysstat
包的一部分。要使用 cpustat
查看 CPU 中断情况,请按照以下步骤操作:
sysstat
包。在基于 Debian 的系统(如 Ubuntu)上,可以使用以下命令安装:sudo apt-get update
sudo apt-get install sysstat
在基于 RHEL 的系统(如 CentOS)上,可以使用以下命令安装:
sudo yum install sysstat
cpustat
命令查看 CPU 统计信息。要查看 CPU 中断情况,请使用 -i
选项:cpustat -i
这将显示类似于以下内容的输出:
Linux 5.4.0-42-generic (hostname) 05/01/2021 _x86_64_ (4 CPU)
avg-cpu: %user %nice %system %iowait %steal %idle
12.34 0.01 1.23 0.05 0.00 86.37
Device: rrqm/s wrqm/s r/s w/s rkB/s wkB/s avgrq-sz avgqu-sz await r_await w_await svctm %util
sda 0.00 0.00 1.00 1.00 9.60 9.60 19.20 0.00 0.00 0.00 0.00 1.00 0.01
在这个输出中,%idle
列显示了 CPU 空闲时间百分比,avgqu-sz
列显示了平均 I/O 请求队列长度,await
列显示了 I/O 操作的平均等待时间,svctm
列显示了 I/O 操作的平均服务时间,%util
列显示了设备的利用率。
要查看每个 CPU 核心的中断情况,请使用 -C
选项:
cpustat -i -C ALL
这将显示类似于以下内容的输出:
Linux 5.4.0-42-generic (hostname) 05/01/2021 _x86_64_ (4 CPU)
avg-cpu: %user %nice %system %iowait %steal %idle
12.34 0.01 1.23 0.05 0.00 86.37
CPU %usr %sys %irq %soft %steal %guest %gnice %idle
0 12.34 1.23 0.01 0.00 0.00 0.00 86.37
1 11.22 1.11 0.02 0.00 0.00 0.00 87.55
2 13.45 1.34 0.01 0.00 0.00 0.00 85.10
3 10.56 1.09 0.01 0.00 0.00 0.00 88.24
在这个输出中,%irq
列显示了每个 CPU 核心的中断时间百分比。