[Ilugc] Help required....Require a script to filter information from vmstat output...Clarification INside...

zulfilee zulfilee at midascomm.com
Wed Dec 15 15:56:23 IST 2004


My vmstat shows

 procs                      memory      swap          io     system      cpu
 r  b  w   swpd   free   buff  cache   si   so    bi    bo   in    cs us sy id
 1  0  0  83256   3356   3240  41552    4   20    62    32  140   601  3  1 97

Here i get the fields using

$PROCS=`vmstat | sed -n   2,10p | tr -s " " | cut -d " " -f 1-4`
$MEMORY=`vmstat | sed -n   2,10p | tr -s " " | cut -d " " -f 5-7`

And so on

The sed is to strip the first line
Tr is to squeeze the spaces and cut to get the fileds I want

So you can just call echo $PROCS, $MEMORY, etc..
It can be made a lot easier if sed is used

Cheers
Z

On Wednesday 15 December 2004 14:57, Kirty Mohanty wrote:
> Hi All,
> Below is the output of vmstat command:
>
>   procs     memory            page            disk          faults      cpu
>  r b w   swap  free  re  mf pi po fr de sr s0 s1 s6 --   in   sy   cs us sy
> id 0 0 0   1120  1240   0   0  0  0  0  0  0  1  0  0  0 4294967196 0 0 -37
> -28 -96
>
> Could anyone of you please write and post a script which will filter
> information and show it?
> It means that:
> 1.  if i give the option as "memory" then it will show all the
> columns related to the memory heading in the vmstat output...
>
> 2.  if i give the option as "cpu" then it will show all the  columns
> related to the cpu heading in the vmstat output...
>
> ...and like this for all the headings(procs,memory,
> page,disk,faults,cpu) in the output of the vmstat command.
>
> Thanks in advance....

-- 
The highest sounds are hardest to hear. 
Going forward is a way to retreat. 
Great talent shows itself late in life. 
Even a perfect program still has bugs
	          -Tao of programming



More information about the ilugc mailing list