Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to discard zero values in (awk) columns in iostat -xtc display 2

Status
Not open for further replies.

marrow

Technical User
Jul 20, 2001
425
US
I have displayed & tabbed 4 important columns of output from "iostat -xtc 2 10" as follows

iostat -xtc 2 10 | awk '{printf("%\t%s\t%s\t%s\t%s\n",$1,$2,$3,$8)}'

1) I would now like to discard all lines that show
0.0 0.0 0.0 0.0
2) or, only display anything greater than 30 in any column

Any help appreciated
 
What have you tried so far and where in your code are you stuck ?
A starting point for 1)
Code:
iostat -xtc 2 10 | awk '$1+$2+$3+$8{printf "%s\t%s\t%s\t%s\t%s\n",$1,$2,$3,$8}'

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Can you include some sample iostat -xtc output because you haven't mentioned the OS type and the output format varies on different OS.

Annihilannic.
 
OK > O/S = Solaris8, sample listing below
# iostat -xtc 2 10 | awk '{printf("%\t%s\t%s\t%s\t%s\n",$1,$2,$3,$8)}'
extended device statistics
device r/s w/s svc_t
md0 2.2 0.3 5.0
md1 0.4 0.1 5.5
md2 0.0 0.0 19.4
md3 3.6 1.3 2.8
md4 10.6 0.5 1.7
md5 1.2 0.0 0.8
md10 1.1 0.3 1.3
md11 0.2 0.1 1.0
md12 0.0 0.0 5.9
md13 1.8 1.3 0.9
md14 5.3 0.5 0.7
md15 0.6 0.0 0.6
md20 1.1 0.3 5.9
md21 0.2 0.1 5.6
md22 0.0 0.0 11.1
md23 1.8 1.3 3.8
md24 5.3 0.5 1.9
md25 0.6 0.0 1.0
sd30 0.0 0.0 0.0
 
iostat -xtc 2 10 | nawk '$2$3$8!="0.00.00.0"{printf "%s\t%s\t%s\t%s\n",$1,$2,$3,$8}'

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
This has worked very well but I'd like to go a bit further. All zero lines are ignored but I am still getting output of lines that have small numbers which I don't need

10.6 0.5 1.7

I would like to add the 3 x columns and only print a line if it has a total of less than 40.

Thanks in advance

Marrow
 
Code:
iostat -xtc 2 10 | nawk '$2+$3+$8 > 40 {printf "%s\t%s\t%s\t%s\n",$1,$2,$3,$8}'

Annihilannic.
 
Thanks for your reply Annie that's perfect
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top