Skip to content

Instantly share code, notes, and snippets.

@edr3x
Created April 15, 2023 12:58
Show Gist options
  • Save edr3x/5476bed36159a0e37cfba83c69ebefb5 to your computer and use it in GitHub Desktop.
Save edr3x/5476bed36159a0e37cfba83c69ebefb5 to your computer and use it in GitHub Desktop.
print current cpu usae of a system
#!/usr/bin/env bash
cat /proc/stat | grep cpu | tail -1 | awk '{print ($5*100)/($2+$3+$4+$5+$6+$7+$8+$9+$10)}' | awk '{print 100-$1}' | xargs printf "%.1f"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment