środa, 19 marca 2008


I wrote about it in my Polish blog, but have seen it a few times since then on English channels that I decided to post it here also.
A person at #opensolaris channel had a problem, that

prstat -m | nawk '{print $10}' | nawk '{sum+=$1;} END {print sum;}'

just happily sat there printing nothing. It helps to know, that prstat, as the last arguments, takes interval between measurements and a count of measurements. If the count is omitted, prstat will take measurements waiting for ^C, thus the END will never be satisfied.
The version below works, taking one measurement and then printing the output.

prstat -m 1 1 | nawk '{print $10}' | nawk '{sum+=$1;} END {print sum;}'

One more thing worth knowing is that prstat, similarly to other tools, as a first measurement prints averages since system boot. Next measurements are closer to the actual state of system.

Brak komentarzy: