Created
January 11, 2024 06:57
-
-
Save karoltheguy/0e332b6745c1d9322c1c95b54d630a65 to your computer and use it in GitHub Desktop.
Bash All Core Average CPU Usage
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 | |
# 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