Memory: Use simpler math

This commit is contained in:
Dylan Araps 2016-11-13 22:30:14 +11:00
parent b9606cf611
commit 26809f8eca

View file

@ -1026,7 +1026,7 @@ get_memory() {
;; ;;
"Mac OS X" | "iPhone OS") "Mac OS X" | "iPhone OS")
memtotal="$(($(sysctl -n hw.memsize) / 1024 / 1024))" memtotal="$(($(sysctl -n hw.memsize) / 1024^2))"
memwired="$(vm_stat | awk '/wired/ { print $4 }')" memwired="$(vm_stat | awk '/wired/ { print $4 }')"
memactive="$(vm_stat | awk '/active / { printf $3 }')" memactive="$(vm_stat | awk '/active / { printf $3 }')"
memcompressed="$(vm_stat | awk '/occupied/ { printf $5 }')" memcompressed="$(vm_stat | awk '/occupied/ { printf $5 }')"
@ -1037,12 +1037,12 @@ get_memory() {
case "$distro" in case "$distro" in
"NetBSD"*) "NetBSD"*)
memfree="$(($(awk -F ':|kB' '/MemFree:/ {printf $2}' /proc/meminfo) / 1024))" memfree="$(($(awk -F ':|kB' '/MemFree:/ {printf $2}' /proc/meminfo) / 1024))"
memtotal="$(($(sysctl -n hw.physmem64) / 1024 / 1024))" memtotal="$(($(sysctl -n hw.physmem64) / 1024^2))"
;; ;;
*) *)
memfree="$(($(vmstat | awk 'END{printf $5}') / 1024))" memfree="$(($(vmstat | awk 'END{printf $5}') / 1024))"
memtotal="$(($(sysctl -n hw.physmem) / 1024 / 1024))" memtotal="$(($(sysctl -n hw.physmem) / 1024^2))"
;; ;;
esac esac
@ -1059,9 +1059,9 @@ get_memory() {
;; ;;
"Haiku") "Haiku")
memtotal="$(($(sysinfo -mem | awk -F '\\/ |)' '{print $2; exit}') / 1024 / 1024))" memtotal="$(($(sysinfo -mem | awk -F '\\/ |)' '{print $2; exit}') / 1024^2))"
memused="$(sysinfo -mem | awk -F '\\/|)' '{print $2; exit}')" memused="$(sysinfo -mem | awk -F '\\/|)' '{print $2; exit}')"
memused="$((${memused/max} / 1024 / 1024))" memused="$((${memused/max} / 1024^2))"
;; ;;
esac esac
memory="${memused}MB / ${memtotal}MB" memory="${memused}MB / ${memtotal}MB"