CPU: Added cpu_temp support for BSDs

This commit is contained in:
Muhammad Herdiansyah 2016-11-26 14:43:59 +07:00
parent 8fbb7dee58
commit 4d939690a8
2 changed files with 20 additions and 2 deletions

View file

@ -787,6 +787,20 @@ get_cpu() {
# Get cpu cores # Get cpu cores
cores="$(sysctl -n hw.ncpu)" cores="$(sysctl -n hw.ncpu)"
# Get cpu temp
if [[ "$cpu_temp" == "on" ]]; then
case "$distro" in
"FreeBSD"* | "PacBSD"* | "DragonFly"* | "PCBSD"*)
temp="$(sysctl -n dev.cpu.0.temperature)"
temp="[${temp/C/°C}]"
;;
"OpenBSD"* | "Bitrig"*)
temp="$(sysctl -n hw.sensors.lm0.temp0)"
temp="[${temp/ degC/°C}]"
;;
esac
fi
;; ;;
"Solaris") "Solaris")
@ -2934,7 +2948,9 @@ usage() { printf "%s" "
NOTE: 'physical' doesn't work on BSD. NOTE: 'physical' doesn't work on BSD.
--cpu_speed on/off Hide/Show cpu speed. --cpu_speed on/off Hide/Show cpu speed.
--cpu_temp on/off Hide/Show cpu temperature. --cpu_temp on/off Hide/Show cpu temperature.
NOTE This only works on linux. NOTE: This only works on Linux and BSD.
NOTE: For FreeBSD-based systems, you need to enable coretemp
kernel module.
--distro_shorthand on/off Shorten the output of distro (tiny, on, off) --distro_shorthand on/off Shorten the output of distro (tiny, on, off)
NOTE: This option won't work in Windows (Cygwin) NOTE: This option won't work in Windows (Cygwin)
--kernel_shorthand on/off Shorten the output of kernel --kernel_shorthand on/off Shorten the output of kernel

View file

@ -48,7 +48,9 @@ Hide/Show cpu speed.
.B \--cpu_temp 'on/off' .B \--cpu_temp 'on/off'
Hide/Show cpu temperature. Hide/Show cpu temperature.
.br .br
NOTE This only works on linux. NOTE: This only works on Linux and BSD.
.br
NOTE: For FreeBSD-based systems, you need to enable coretemp kernel module.
.TP .TP
.B \--distro_shorthand 'on/off' .B \--distro_shorthand 'on/off'
Shorten the output of distro (tiny, on, off) Shorten the output of distro (tiny, on, off)