Merge pull request #896 from rage311/master

Fixes for OpenBSD CPU temperature and memory used values
This commit is contained in:
Herdiansyah 2018-01-23 07:21:03 +07:00 committed by GitHub
commit aeec963430
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1086,8 +1086,9 @@ get_cpu() {
deg="${deg/C}"
;;
"OpenBSD"* | "Bitrig"*)
deg="$(sysctl -n hw.sensors.lm0.temp0)"
deg="${deg/ degC}"
deg="$(sysctl hw.sensors | \
awk -F '=| degC' '/lm0.temp|cpu0.temp/ {print $2; exit}')"
deg="${deg/00/0}"
;;
esac
;;
@ -1465,9 +1466,10 @@ get_memory() {
# Mem used.
case "$kernel_name" in
"OpenBSD"*)
mem_used="$(vmstat | awk 'END{printf $4}')"
mem_used="$((${mem_used/M} / 1024))"
mem_used="$(vmstat | awk 'END{printf $3}')"
mem_used="${mem_used/M}"
;;
*) mem_used="$((mem_total - mem_free))" ;;
esac
;;