Fix memory usage on BSD

This commit is contained in:
Dylan 2016-01-18 17:45:32 +11:00
parent b6b4e09287
commit 04ba1d2c3b
1 changed files with 12 additions and 14 deletions

26
fetch
View File

@ -641,25 +641,23 @@ getmemory () {
memory="${memused}MB / ${memtotal}MB"
;;
"FreeBSD")
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")
"BSD")
memtotal=$(dmesg | awk '/real mem/ {printf $5}')
memtotal=${memtotal/\(/}
memtotal=${memtotal/MB\)/}
memfree=$(top -d 1 | awk '/Real:/ {print $6}')
case "$distro" in
"FreeBSD")
memfree=$(top -d 1 | awk '/Mem:/ {printf $10}')
;;
*)
memfree=$(top -d 1 | awk '/Real:/ {print $6}')
;;
esac
memfree=${memfree/M/}
memused=$((memtotal - memfree))
memory="${memused}MB / ${memtotal}MB"
;;