parallel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: BUG: swap_activity broken in v20120322


From: Thomas Sattler
Subject: Re: BUG: swap_activity broken in v20120322
Date: Fri, 30 Mar 2012 14:44:05 +0200
User-agent: Mozilla/5.0 (X11; Linux i686; rv:11.0) Gecko/20120312 Thunderbird/11.0

>> vmstat 1 2 2>/dev/null | tail -n1 | awk '{print $7*$8}' ||
>>   vm_stat 1 | head -n 3 | tail -n1 | awk '{print $9*$10}'
> 
> Better `awk` usage:
> 
> vmstat 1 2 2>/dev/null | awk 'END {print $7*$8}' ||
> vm_stat 1 | awk 'NR == 3 {print $9*$10 ; exit}'

Still the same problem: Whether 'vm_stat' is run depends on
the success of 'awk', not 'vmstat'. (At least under bash.)

>> If somebody would reply with the output of 'vm_stat', I'd offer a 
>> patch to fix the issue. (I don't have a MAC.)
> 
> osx-server$ vm_stat 1
> Mach Virtual Memory Statistics: (page size of 4096 bytes, cache hits 0%)
>    free active   spec inactive   wire   faults     copy    0fill reactive  
> pageins  pageout
>   70547 442624  29441    88468 415463   14321M  518664K 2448176K   683760  
> 1460755   367311
>   70658 442657  29440    88468 415463      139        0      136        0     
>    1        0
>   70729 442660  29440    88468 415463      145        0       73        0     
>    0        0
>   70461 442660  29440    88468 415463      388       69      134        0     
>    0        0
>   70478 442649  29440    88468 415463       16        0        6        0     
>    0        0 
> [...etc...]

This was the fourth reply with the output of 'vm_stat', so
here is some code that should do the job:

   { vmstat 1 2> /dev/null || vm_stat 1; } | awk '
     NR!=4{next}
     NF==16{print $7*$8}
     NF==11{print $10*$11}
     {exit}
   '
I'm running 'vmstat' (and 'vm_stat' in case 'vmstat' failed)
and pipe the output to 'awk' which knows where the relevant
information is:

  vmstat  (16 fields per line):  field7  * field8
  vm_stat (11 fields per line):  field10 * field11

By the way: In all four replys I got, the relevant information
("pageins" and "pageout") was in field 10 / 11, never 9 / 10.

Also I had to use line number 4 as the output of 'vmstat' and
'vm_stat' both have two lines of headers and have non-zero
values in their first data line. (see above)

Thomas

P.S.: Why do we use 'awk' within 'perl'?



reply via email to

[Prev in Thread] Current Thread [Next in Thread]