Fix CPU core/frequency reading on Linux/SPARC systems (#1643)
This commit is contained in:
parent
07ae57453a
commit
70ad34e919
1 changed files with 38 additions and 5 deletions
37
neofetch
37
neofetch
|
@ -2213,17 +2213,50 @@ get_cpu() {
|
||||||
speed="$((speed / 1000))"
|
speed="$((speed / 1000))"
|
||||||
|
|
||||||
else
|
else
|
||||||
|
case $kernel_machine in
|
||||||
|
"sparc"*)
|
||||||
|
# SPARC systems use a different file to expose clock speed information.
|
||||||
|
speed_file="/sys/devices/system/cpu/cpu0/clock_tick"
|
||||||
|
speed="$(($(< "$speed_file") / 1000000))"
|
||||||
|
;;
|
||||||
|
|
||||||
|
*)
|
||||||
speed="$(awk -F ': |\\.' '/cpu MHz|^clock/ {printf $2; exit}' "$cpu_file")"
|
speed="$(awk -F ': |\\.' '/cpu MHz|^clock/ {printf $2; exit}' "$cpu_file")"
|
||||||
speed="${speed/MHz}"
|
speed="${speed/MHz}"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Get CPU temp.
|
# Get CPU temp.
|
||||||
[[ -f "$temp_dir" ]] && deg="$(($(< "$temp_dir") * 100 / 10000))"
|
[[ -f "$temp_dir" ]] && deg="$(($(< "$temp_dir") * 100 / 10000))"
|
||||||
|
|
||||||
# Get CPU cores.
|
# Get CPU cores.
|
||||||
|
case $kernel_machine in
|
||||||
|
"sparc"*)
|
||||||
case $cpu_cores in
|
case $cpu_cores in
|
||||||
"logical" | "on") cores="$(grep -c "^processor" "$cpu_file")" ;;
|
# SPARC systems doesn't expose detailed topology information in
|
||||||
"physical") cores="$(awk '/^core id/&&!a[$0]++{++i} END {print i}' "$cpu_file")" ;;
|
# /proc/cpuinfo so I have to use lscpu here.
|
||||||
|
"logical" | "on")
|
||||||
|
cores="$(lscpu | awk -F ': *' '/^CPU\(s\)/ {print $2}')"
|
||||||
|
;;
|
||||||
|
"physical")
|
||||||
|
cores="$(lscpu | awk -F ': *' '/^Core\(s\) per socket/ {print $2}')"
|
||||||
|
sockets="$(lscpu | awk -F ': *' '/^Socket\(s\)/ {print $2}')"
|
||||||
|
cores="$((sockets * cores))"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
|
||||||
|
*)
|
||||||
|
case $cpu_cores in
|
||||||
|
"logical" | "on")
|
||||||
|
cores="$(grep -c "^processor" "$cpu_file")"
|
||||||
|
;;
|
||||||
|
"physical")
|
||||||
|
cores="$(awk '/^core id/&&!a[$0]++{++i} END {print i}' "$cpu_file")"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue