观察中断的脚本 /proc/interrupts
CPU太多,中断太大,屏幕太小。
mpstat,也不是很方便。弄了个脚本。
丑陋。但有效
#! /bin/bash function dump() { cat /proc/interrupts |sed 's/^ //g' | awk ' NR==1 { # 第一行获取CPU核心数量(从标题行计算) cpu_count = NF - 1 next } { # 保存原始行的中断名称等信息(从第(1 + cpu_count + 1)列开始) info = "" for (i = 1 + cpu_count + 1; i <= NF; i++) { info = info " " $i } # 对所有CPU核心的中断计数求和 total = 0 for (i = 2; i <= 1 + cpu_count; i++) { gsub(/,/, "", $i) # 去除数字中的逗号(如1,000 -> 1000) total += $i } # 输出:中断号 + 总中断数 + 原始信息 printf "%-8s %'"'"'d %s\n", $1, total, info }' } function dodo() { sleep 2 dump |grep -E '^[0-9]+' > /tmp/dump_123456789_2 printf '\033c' diff --suppress-common-lines /tmp/dump_123456789_1 /tmp/dump_123456789_2 cp /tmp/dump_123456789_2 /tmp/dump_123456789_1 } while : do dodo done
浙公网安备 33010602011771号