AIX : ksh : Show free pages in Mb

This is a quick script that is handy when monitoring memory usage
on AIX. Vmstat shows memory in pages, which are 4096-bytes per page; no
overly helpful when trying to determine how much of your physical
memory is being used, so this script converts that field in Mb.


# Quick script to output free memory pages in Mb

echo "Crtl-C to exit"

while :

do

val=vmstat 1 2 | tail -1 | awk ‘{print $4}’

(( val1 = val * 4096 ))

(( val1 = val1 / 1024 ))

(( val1 = val1 / 1024 ))

echo $val1

sleep 2

done

And, yes, I know, there’s probably so quicker way to do the sums, but it works for me!