Fix cpu usage bug on MacOSX/darwin
This commit is contained in:
parent
fbb1c6b929
commit
6757a53299
1 changed files with 4 additions and 1 deletions
|
@ -23,7 +23,10 @@ get_percent()
|
|||
;;
|
||||
|
||||
Darwin)
|
||||
percent=$(ps -A -o %cpu | awk '{s+=$1} END {print s "%"}')
|
||||
cpuvalue=$(ps -A -o %cpu | awk -F. '{s+=$1} END {print s}')
|
||||
cpucores=$(sysctl -n hw.logicalcpu)
|
||||
cpuusage=$(( cpuvalue / cpucores ))
|
||||
percent="$cpuusage%"
|
||||
echo $percent
|
||||
;;
|
||||
|
||||
|
|
Loading…
Reference in a new issue