Skip to content

Instantly share code, notes, and snippets.

@karoltheguy
Created January 11, 2024 06:57
Show Gist options
  • Save karoltheguy/0e332b6745c1d9322c1c95b54d630a65 to your computer and use it in GitHub Desktop.
Save karoltheguy/0e332b6745c1d9322c1c95b54d630a65 to your computer and use it in GitHub Desktop.
Bash All Core Average CPU Usage
#!/bin/bash
# extract average CPU usage of all cores
idle_time=$(mpstat 1 1 | awk '/Average:/ {print $NF}' | sed 's/\,/./' )
cpu_usage=$(echo "(100 - $idle_time)" | bc -l )
echo $cpu_usage
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment