Created
January 4, 2013 12:00
-
-
Save faicker/4452115 to your computer and use it in GitHub Desktop.
get the interface interrupts per CPU. http://stackoverflow.com/questions/11608323/reading-a-tuple-from-a-file-with-awk
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
FILE="/proc/interrupts" | |
output=$(awk 'NR==1 { | |
core_count = NF | |
for (i = 1; i <= core_count; i++) | |
names[i-1] = $i | |
next | |
} | |
/eth/ { | |
for (i = 2; i <= 2+core_count; i++) | |
totals[i-2] += $i | |
} | |
END { | |
for (i = 0; i < core_count; i++) | |
printf("%s=%d\n", names[i], totals[i]) | |
} | |
' ${FILE}) | |
core_count=$(echo "${output}" | wc -l) | |
totals=( ${output} ) | |
for x in "${totals[@]}"; do | |
name=${x%=*} | |
value=${x#*=} | |
echo "${name} -> ${value}" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment