Commit 7d65ae51 authored by Dylan Araps's avatar Dylan Araps

CPU Usage: re-detect cores if set to physical or off

parent abbf9100
......@@ -967,7 +967,7 @@ get_cpu_usage() {
*)
# Get CPU cores if unset.
if [[ "$cpu_cores" == "off" ]]; then
if [[ "$cpu_cores" != "logical" ]]; then
case "$os" in
"Linux" | "MINIX") cores="$(grep -c "^processor" /proc/cpuinfo)" ;;
"Mac OS X") cores="$(sysctl -n hw.logicalcpu_max)" ;;
......@@ -978,7 +978,7 @@ get_cpu_usage() {
esac
fi
cpu_usage="$(ps aux | awk 'BEGIN {sum=0} {sum+=$3 }; END {print sum}')"
cpu_usage="$(ps aux | awk 'BEGIN {sum=0} {sum+=$3}; END {print sum}')"
cpu_usage="$((${cpu_usage/\.*} / ${cores:-1}))"
;;
esac
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment