2015-02-19 14:15:38 -05:00
|
|
|
#!/bin/sh
|
2015-02-21 12:18:27 -05:00
|
|
|
|
2015-02-22 14:45:57 -05:00
|
|
|
if is_osx; then
|
2015-03-21 16:19:08 -04:00
|
|
|
start () {
|
2015-03-08 15:37:56 -04:00
|
|
|
readonly __memory_os_memsize=$(sysctl -n hw.memsize)
|
|
|
|
}
|
2015-02-22 12:36:04 -05:00
|
|
|
|
|
|
|
collect () {
|
2015-03-08 07:30:00 -04:00
|
|
|
report $(vm_stat | awk -v total_memory=$__memory_os_memsize \
|
2015-03-11 17:02:00 -04:00
|
|
|
'BEGIN { FS=" *"; pages=0 }
|
|
|
|
/Pages (free|inactive|speculative)/ { pages+=$2 }
|
|
|
|
END { printf "%.1f", 100 - (pages * 4096) / total_memory * 100.0 }')
|
2015-02-22 12:36:04 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
collect () {
|
2017-10-09 08:54:57 -04:00
|
|
|
report $(free | awk '/Mem:/ {
|
|
|
|
printf "%.1f", 100 - $4 / ($3 + $4) * 100}')
|
2015-02-22 12:36:04 -05:00
|
|
|
}
|
2015-02-22 14:45:57 -05:00
|
|
|
fi
|
|
|
|
|
|
|
|
docs () {
|
|
|
|
echo "Percentage of used memory."
|
2017-10-09 08:54:57 -04:00
|
|
|
}
|