INPUT: 0:root@server:/root # vmstat 60 2System configuration: lcpu=52 mem=131072MB ent=10.00kthr    memory              page              faults              cpu          ----- ----------- ------------------------ ------------ ----------------------- r  b   avm   fre  re  pi  po  fr   sr  cy  in   sy  cs us sy id wa    pc    ec 5  0 13254063 12378057   0   0   0   0    0   0 3411 22516 9063 10  2 88  0  1.94  19.4 5  0 13341251 12290955   0   0   0   0    0   0 3507 20192 9062  9  2 89  0  1.88  18.80:root@server:/root # NEEDED OUTPUT: 0It is zero, since the average r < lcpu. The id values are not important in this case. another INPUT: 0:root@server:/root # vmstat 60 2System configuration: lcpu=52 mem=131072MB ent=10.00kthr    memory              page              faults              cpu          ----- ----------- ------------------------ ------------ ----------------------- r  b   avm   fre  re  pi  po  fr   sr  cy  in   sy  cs us sy id wa    pc    ec 52  0 13254063 12378057   0   0   0   0    0   0 3411 22516 9063 10  2 6  0  1.94  19.4 53  0 13341251 12290955   0   0   0   0    0   0 3507 20192 9062  9  2 4  0  1.88  18.80:root@server:/root # NEEDED OUTPUT: 95It is 95, because the average r > lcpu. And it is 95, because id means idle, but we need the cpu consumption. So 6+4 is the idle value, the average from them is 5. So 100-5 = 95% is the cpu load. Average is needed in the r's too! Not just in id. In the last example it is 52.5, so it was greater than 52. This is a general UNIX problem to measure CPU consumption. If r > lcpu and the cpu usage % is very high, then we have a CPU bottleneck. It is interesting that there is no solution for the processing of the vmstat output, that's why I'm asking the awk grandmasters about it. Question: So I need something like this: vmstat 60 2 | GODLY-AWK-MAGIC-HEREFor more details, please see (I couldn't find a better link): http://aix4admins.blogspot.com/2011/09/vmstat-t-5-3-shows-3-statistics-in-5.htmlIf runnable threads (r) divided by the number of CPU is greater than  one -> possible CPU bottleneck
Only output value if x > y in awk
awk;aix
Very crude:awk '    BEGIN { d = -1 }    /lcpu/ { lcpu = substr($3, 6); next }    $1 == r { ++d; next }    d < 0 { next }    {        ++d        r += $1        id += $16        next    }    END {        if (r / d > lcpu)            print 100 - id / d        else            print 0    }'or if you like:awk '    /lcpu/ { lcpu=substr($3, 6) }    $1 ~ /[0-9]+/ {        ++d        r += $1        id += $16        next    }    END {        print (r/d>lcpu) ? 100 - id / d : 0    }'to:awk '/lcpu/{lcpu=substr($3,6)}$1~/[0-9]+/{++d;r+=$1;id+=$16;next;}END{print(r/d>lcpu)?100-id/d:0}'Does it give the results you want?