SUMMARY: script quest

From: Patricio Mora <pmora_at_cgob.junta-andalucia.es>
Date: Fri Jul 12 2002 - 09:23:04 EDT
Consensus: awk. I've not done it yet, but sure there will be no problem. Many thanks.

thanks to:
Johan Hartzenberg <jhartzen@csc.com>
Bertrand_Hutin@notes.amdahl.com
Jonas Bleberg <jonas.blaberg@cellnetwork.com>
"Glass, David (UDB)" <GlassD@bp.com>
Darren Dunham <ddunham@taos.com>
Gert-Jan Hagenaars <gj@hagenaars.com>

-----------------------------------------------------------------------
use awk
-----------------------------------------------------------------------
you may eliminate one pipe using:
iostat -xpctn 10 | nawk '0.0  0.0    0.0    0.0  0.0  0.0    0.0    0.0   0
0 /{next};/c0t10d0s4/{print $0 "  mount point" }'
-----------------------------------------------------------------------
I used perl with $| = 1; to cause autoflush.
-----------------------------------------------------------------------
Why use both when an awk will do:
-----------------------------------------------------------------------
Many programs tend to not autoflush the buffer if the output is to
another program rather than to the screen.  grep appears to be doing
that to you.
I can think of some alternatives.
1) Don't use grep.  Use iostat into awk.  Everything that grep can do
   can be done in awk directly, so that is possible.
2) Use something else.  Perl for instance could also be used as a
   one-liner and be set to autoflush the output.
-----------------------------------------------------------------------
iostat -xpctn 10 \
        | awk '
                ! / 0.0  0.0    0.0    0.0  0.0  0.0    0.0 0.0   0 0 /
                { if ( $11 == "c0t10d0s4" ) print $0 "  mount point" }'
You might have to escape the bang, like this "awk '\! / 0.0 ...".  If you
want to be safer, you can use a regex for the filter, but you'd have to
use nawk.
        nawk '\! / 0.0 *0.0 *0.0 *0.0 *0.0 *0.0 *0.0 *0.0/ { if ... }'

------------------------ Original question -----------------------------
I'm trying to see mount points in iostat -p instead of partitions in Solaris 2.6. The command is something
like:
iostat -xpctn 10 | egrep -v " 0.0  0.0    0.0    0.0  0.0  0.0    0.0    0.0   0   0 " | awk '{ if ( $11
== "c0t10d0s4" ) print $0 "  mount point" }'
I've tried with sed 's/c0t10d0s4/c0t10d0s4 mountpoint/' with the same results. The problem is awk/sed
don't show the output until its buffer has reached some length, i.e., doesn't give line by line echo of
its input treated with my command. Is there any way to make it flush to stdout immediately, or any other
workaround? Thanks.

Sorry, but I've found additional details:
"iostat | grep" behaves as I expect,
"iostat | awk" also
"iostat | grep | awk" combination is which is not addecuate
_______________________________________________
sunmanagers mailing list
sunmanagers@sunmanagers.org
http://www.sunmanagers.org/mailman/listinfo/sunmanagers
Received on Fri Jul 12 10:01:32 2002

This archive was generated by hypermail 2.1.8 : Thu Mar 03 2016 - 06:42:48 EST