Last active
April 27, 2016 19:10
-
-
Save jschaub30/f898a9bd9f556dc0e70956154122c373 to your computer and use it in GitHub Desktop.
Bash script to convert /proc/interrupts to csv format
This file contains hidden or 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 | |
[ $# -ne 1 ] && echo USAGE: $0 INTERRUPTS_FN && exit 1 | |
FN=$1 | |
NUM_CPU=$(cat /proc/cpuinfo | grep processor | wc -l) | |
head -n 1 $FN | perl -pe "s/^/queue/" | perl -pe "s/\h+/,/g" | perl -pe "s/$/label/" > ${FN}.csv | |
grep "[0-9]:" $FN | perl -pe "s/ *([0-9]+):\s+/\1,/" | perl -pe "s/\h+/,/g" > ${FN}.tmp | |
cut -d',' -f1-$((NUM_CPU+1)) ${FN}.tmp > ${FN}.tmp1 # data | |
cut -d',' -f$((NUM_CPU+2))- ${FN}.tmp | perl -pe "s/,/_/g" > ${FN}.tmp2 # queue labels | |
paste -d',' ${FN}.tmp1 ${FN}.tmp2 >> ${FN}.csv | |
rm ${FN}.tmp ${FN}.tmp1 ${FN}.tmp2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment