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
|
|
|
|
declare -r __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-02-22 14:45:57 -05: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 () {
|
2015-03-08 07:30:00 -04:00
|
|
|
report $(free | awk '/buffers\/cache/{printf "%.1f", 100 - $4 / ($3 + $4) * 100.0}')
|
2015-02-22 12:36:04 -05:00
|
|
|
}
|
2015-02-22 14:45:57 -05:00
|
|
|
fi
|
|
|
|
|
|
|
|
docs () {
|
|
|
|
echo "Percentage of used memory."
|
|
|
|
}
|