LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Other *NIX Forums > Solaris / OpenSolaris
User Name
Password
Solaris / OpenSolaris This forum is for the discussion of Solaris, OpenSolaris, OpenIndiana, and illumos.
General Sun, SunOS and Sparc related questions also go here. Any Solaris fork or distribution is welcome.

Notices


Reply
  Search this Thread
Old 05-24-2011, 04:34 AM   #1
mazeem
LQ Newbie
 
Registered: May 2011
Posts: 3

Rep: Reputation: Disabled
iostat


Hi all,
I want to run "iostat -xnmpztc 2 5 and delete first 4 set of "extended" stats and print only 5th set.

Please suggest!
 
Old 05-24-2011, 06:29 AM   #2
16pide
Member
 
Registered: Jan 2010
Posts: 418

Rep: Reputation: 83
If you want to display the 5th line of the output of a command, you can use a mix of head and tail commands. For example:
Code:
seq 7|head -5|tail -1
FYI, I did not do it with your iostat command because those options don't work on my system

Last edited by 16pide; 05-24-2011 at 06:31 AM.
 
Old 05-24-2011, 06:43 AM   #3
mazeem
LQ Newbie
 
Registered: May 2011
Posts: 3

Original Poster
Rep: Reputation: Disabled
no i don't want to display the 5th line ,i want to display the complete 5th set

iostat -xnmpztc 2 5

output:
Set1:
tty cpu
tin tout us sy wt id
1 130 9 1 0 90
extended device statistics
r/s w/s kr/s kw/s wait actv wsvc_t asvc_t %w %b device
98.3 34.2 3479.5 568.5 0.0 1.2 0.1 8.7 1 18 c0t0d0
0.1 2.7 5.4 21.4 0.0 0.0 0.1 3.5 0 0 c0t0d0s0 (/)
0.0 0.0 0.0 0.0 0.0 0.0 0.0 4.7 0 0 c0t0d0s1
0.1 0.1 0.8 0.3 0.0 0.0 0.1 17.5 0 0 c0t0d0s3 (/usr)
0.1 0.0 0.6 0.1 0.0 0.0 0.2 5.0 0 0 c0t0d0s4 (/opt)
0.1 19.6 1.9 84.1 0.0 0.0 0.1 2.4 0 3 c0t0d0s5 (/var)
97.9 11.9 3470.8 462.6 0.0 1.1 0.1 10.0 0 17 c0t0d0s7 (/export)

Set2:

tty cpu
tin tout us sy wt id
0 365 4 1 0 95
extended device statistics
r/s w/s kr/s kw/s wait actv wsvc_t asvc_t %w %b device
0.0 4.5 0.0 44.4 0.0 0.0 0.0 0.8 0 0 c0t0d0
0.0 3.5 0.0 31.9 0.0 0.0 0.0 1.0 0 0 c0t0d0s0 (/)
0.0 0.5 0.0 5.3 0.0 0.0 0.0 0.4 0 0 c0t0d0s5 (/var)
0.0 0.5 0.0 7.3 0.0 0.0 0.0 0.5 0 0 c0t0d0s7 (/export)

Set3:
tty cpu
tin tout us sy wt id
1 260 2 1 0 98
extended device statistics
r/s w/s kr/s kw/s wait actv wsvc_t asvc_t %w %b device
0.0 3.5 0.0 28.0 0.0 0.0 0.0 1.1 0 0 c0t0d0
0.0 3.0 0.0 24.0 0.0 0.0 0.0 1.2 0 0 c0t0d0s0 (/)
0.0 0.5 0.0 4.0 0.0 0.0 0.0 0.5 0 0 c0t0d0s5 (/var)

Set4:

tty cpu
tin tout us sy wt id
0 210 3 1 0 96
extended device statistics
r/s w/s kr/s kw/s wait actv wsvc_t asvc_t %w %b device

Set5:

tty cpu
tin tout us sy wt id
0 99 2 1 0 97
extended device statistics
r/s w/s kr/s kw/s wait actv wsvc_t asvc_t %w %b device
1.0 4.0 4.0 25.9 0.0 0.0 0.0 0.8 0 0 c0t0d0
0.0 3.0 0.0 23.9 0.0 0.0 0.0 1.1 0 0 c0t0d0s0 (/)
1.0 1.0 4.0 2.0 0.0 0.0 0.0 0.3 0 0 c0t0d0s7 (/export)

I just want to print the Set 5

tty cpu
tin tout us sy wt id
0 99 2 1 0 97
extended device statistics
r/s w/s kr/s kw/s wait actv wsvc_t asvc_t %w %b device
1.0 4.0 4.0 25.9 0.0 0.0 0.0 0.8 0 0 c0t0d0
0.0 3.0 0.0 23.9 0.0 0.0 0.0 1.1 0 0 c0t0d0s0 (/)
1.0 1.0 4.0 2.0 0.0 0.0 0.0 0.3 0 0 c0t0d0s7 (/export)

please suggest
 
Old 05-24-2011, 07:01 AM   #4
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
This will show the fifth set:
Code:
iostat -xnmpztc 2 5 | nawk '
/extended device statistics/ { if(++i>4) { j=1} }
{ if(j==1) print }'
 
Old 05-24-2011, 07:07 AM   #5
mazeem
LQ Newbie
 
Registered: May 2011
Posts: 3

Original Poster
Rep: Reputation: Disabled
thanks it worked but i need the output as

tty cpu
tin tout us sy wt id
0 99 2 1 0 97
extended device statistics
r/s w/s kr/s kw/s wait actv wsvc_t asvc_t %w %b device
1.0 4.0 4.0 25.9 0.0 0.0 0.0 0.8 0 0 c0t0d0
0.0 3.0 0.0 23.9 0.0 0.0 0.0 1.1 0 0 c0t0d0s0 (/)
1.0 1.0 4.0 2.0 0.0 0.0 0.0 0.3 0 0 c0t0d0s7 (/export)

instead of

extended device statistics
r/s w/s kr/s kw/s wait actv wsvc_t asvc_t %w %b device
1.0 4.0 4.0 25.9 0.0 0.0 0.0 0.8 0 0 c0t0d0
0.0 3.0 0.0 23.9 0.0 0.0 0.0 1.1 0 0 c0t0d0s0 (/)
1.0 1.0 4.0 2.0 0.0 0.0 0.0 0.3 0 0 c0t0d0s7 (/export)
 
Old 05-24-2011, 08:25 AM   #6
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
Just replace "/extended device statistics/" by "/tty cpu/" in my script. By the way, please use code tags when posting code and command output. This ease readability.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
On iostat -x ztw505xyz Linux - Newbie 1 02-27-2011 06:28 PM
iostat mohitanchlia Linux - Software 0 08-08-2009 01:13 AM
iostat -En rajaniyer123 Solaris / OpenSolaris 1 01-06-2009 08:48 PM
iostat Volcano Linux - Newbie 3 10-04-2005 09:28 AM
iostat FragInHell Solaris / OpenSolaris 2 07-02-2004 05:02 AM

LinuxQuestions.org > Forums > Other *NIX Forums > Solaris / OpenSolaris

All times are GMT -5. The time now is 02:54 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration