觀察中斷的腳本 /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號