Skip to content

Instantly share code, notes, and snippets.

@lazidoca
Created December 10, 2019 00:05
Show Gist options
  • Save lazidoca/196341fced610a7f8ab4a989c8f8ce3c to your computer and use it in GitHub Desktop.
Save lazidoca/196341fced610a7f8ab4a989c8f8ce3c to your computer and use it in GitHub Desktop.
View CPU percentage usage
awk '{u=$2+$4; t=$2+$4+$5; if (NR==1){u1=u; t1=t;} else print ($2+$4-u1) * 100 / (t-t1) "%"; }' \
<(grep 'cpu ' /proc/stat) <(sleep 1;grep 'cpu ' /proc/stat)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment