diff options
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/get_cpu_status | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/bin/get_cpu_status b/bin/get_cpu_status index 18b5c16..d8580db 100755 --- a/bin/get_cpu_status +++ b/bin/get_cpu_status @@ -4,7 +4,11 @@ IFS=$'\n\t' proc_output="" -proc_output=$(grep 'cpu ' /proc/stat | awk '{usage=($2+$4)*100/($2+$4+$5)} END {printf("%5.1f", usage)}') +if [ "$(uname)" == "Darwin" ]; then + proc_output=$(ps -A -o %cpu | awk '{s+=$1} END {print s}') +else + proc_output=$(grep 'cpu ' /proc/stat | awk '{usage=($2+$4)*100/($2+$4+$5)} END {printf("%5.1f", usage)}') +fi proc_output=${proc_output#" "} echo "$proc_output%" |