Fix memory usage on BSD
This commit is contained in:
parent
b6b4e09287
commit
04ba1d2c3b
24
fetch
24
fetch
|
@ -641,25 +641,23 @@ getmemory () {
|
||||||
memory="${memused}MB / ${memtotal}MB"
|
memory="${memused}MB / ${memtotal}MB"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
"FreeBSD")
|
"BSD")
|
||||||
memtotal=$(dmesg | awk '/real mem/ {printf $5}')
|
|
||||||
memtotal=${memtotal/\(/}
|
|
||||||
memtotal=${memtotal/)MB/}
|
|
||||||
memfree=$(top -d 1 | awk '/Mem:/ {printf $10}')
|
|
||||||
memfree=${memfree/M/}
|
|
||||||
memused=$((memtotal - memfree))
|
|
||||||
|
|
||||||
memory="${memused}MB / ${memtotal}MB"
|
|
||||||
;;
|
|
||||||
|
|
||||||
*"BSD")
|
|
||||||
memtotal=$(dmesg | awk '/real mem/ {printf $5}')
|
memtotal=$(dmesg | awk '/real mem/ {printf $5}')
|
||||||
memtotal=${memtotal/\(/}
|
memtotal=${memtotal/\(/}
|
||||||
memtotal=${memtotal/MB\)/}
|
memtotal=${memtotal/MB\)/}
|
||||||
|
|
||||||
|
case "$distro" in
|
||||||
|
"FreeBSD")
|
||||||
|
memfree=$(top -d 1 | awk '/Mem:/ {printf $10}')
|
||||||
|
;;
|
||||||
|
|
||||||
|
*)
|
||||||
memfree=$(top -d 1 | awk '/Real:/ {print $6}')
|
memfree=$(top -d 1 | awk '/Real:/ {print $6}')
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
memfree=${memfree/M/}
|
memfree=${memfree/M/}
|
||||||
memused=$((memtotal - memfree))
|
memused=$((memtotal - memfree))
|
||||||
|
|
||||||
memory="${memused}MB / ${memtotal}MB"
|
memory="${memused}MB / ${memtotal}MB"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
|
Reference in New Issue