vmstat -m/-z field parsing

John Baldwin jhb at freebsd.org
Thu Oct 15 12:44:58 UTC 2009


On Thursday 15 October 2009 2:24:00 am grarpamp wrote:
> Some of the 'first' columns in the
> output contain spaces which makes
> it hard to parse the data out. Unless I'm
> missing the reason, I propose they be
> changed to underscores '_' as
> per the rest of the ouput. Thanks.

You can also just not use whitespace for your field separator.  For example
with awk and sort:

vmstat -z | awk -F '[:,]' '/ITEM/ { next } /^$/ { next } // { printf "%s:\t%d\n", $1, $2 * ($4 + $5) }' | sort -t: -k 2 -n 

(This computes the total size of allocated memory (both used and free items)
for a zone and sorts the list so the biggest zones are last.)

-- 
John Baldwin


More information about the freebsd-current mailing list