cpustat 是一个用于显示 CPU 统计信息的工具,它是 sysstat 包的一部分。要使用 cpustat 监控中断请求,你可以运行以下命令:
cpustat -i
这将显示 CPU 的中断统计信息。输出示例:
Linux 5.4.0-42-generic (hostname) 01/01/2021 _x86_64_ (4 CPU)
avg-cpu: %user %nice %system %iowait %steal %idle
12.34 0.01 1.23 0.02 0.00 86.40
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 0.00 9.00 0.00 18.00 0.00 0.00 0.00 0.00 0.00
sdb 0.00 0.00 0.00 1.00 0.00 9.00 18.00 0.00 0.00 0.00 0.00 0.00
在这个示例中,%user、%nice、%system、%iowait、%steal 和 %idle 列显示了 CPU 的使用情况。avgqu-sz 列显示了平均请求队列长度,await 列显示了平均等待时间。
要监控中断请求,你可以关注 irq 列。这个列显示了每秒发生的中断次数。例如:
intr/s: 123456789
这将显示每秒发生的中断次数。如果你想监控特定中断,可以使用 watch 命令结合 grep,如下所示:
watch -n 1 "cat /proc/interrupts | grep 'irq_number'"
将 irq_number 替换为你想要监控的中断号。这将每秒刷新一次指定中断的统计信息。