# cpu.sh LABEL SECONDS -- busy/total /proc/stat delta over SECONDS, plus ps for the exhibition's processes s() { awk '/^cpu /{print $2+$3+$4+$7+$8, $2+$3+$4+$5+$6+$7+$8}' /proc/stat; } echo "$1 start $(date -u +%T)Z"; a=$(s); sleep "$2"; b=$(s) echo "$1 end $(date -u +%T)Z" echo "$a $b" | awk -v l="$1" '{printf "%s busy %.2f%% (%d/%d jiffies)\n", l, 100*($3-$1)/($4-$2), $3-$1, $4-$2}' ps -eo pid,pcpu,cputime,comm | awk 'NR==1 || /foot|sway|ttfx|python3/'