Re: vmstat -m/-z field parsing

From: John Baldwin <jhb_at_freebsd.org>
Date: Thu, 15 Oct 2009 07:47:54 -0400
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
Received on Thu Oct 15 2009 - 10:44:58 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:39:57 UTC