Skip to content

Instantly share code, notes, and snippets.

@rindeal
Last active July 26, 2018 13:49
Show Gist options
  • Save rindeal/9807d8133ad25cd6a932 to your computer and use it in GitHub Desktop.
Save rindeal/9807d8133ad25cd6a932 to your computer and use it in GitHub Desktop.
Pretty print /proc/interrupts
#!/bin/sh
sed -r -e 's/^ *//' -e 's/ {2,}/|/g' < /proc/interrupts | \
awk -F'|' '
BEGIN { cpu_n = 0; }
NR == 1 {
for(i = 1; i <= NF; i++)
if($i ~ CPU)
cpu_n++;
}
NR > 1 {
sum = 0;
for(i = 2; i <= cpu_n + 1; i++)
sum += $i;
printf("%4s %12d %-20s ", $1, sum, $6);
for(i = 1; i < 7; i++)
$i = "";
print;
}' | \
sort -nrk2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment