Find the answer to your Linux question:
Results 1 to 2 of 2
iostat -xnmpztc 2 Output tty cpu tin tout us sy wt id 1 131 9 1 0 90 extended device statistics r/s w/s kr/s kw/s wait actv wsvc_t asvc_t %w ...
  1. #1
    Just Joined!
    Join Date
    May 2011
    Posts
    1

    print output of iostat -xnmpztc 2

    iostat -xnmpztc 2
    Output

    tty cpu
    tin tout us sy wt id
    1 131 9 1 0 90
    extended device statistics
    r/s w/s kr/s kw/s wait actv wsvc_t asvc_t %w %b device
    93.4 34.4 3479.2 576.0 0.0 1.1 0.1 9.0 1 18 c0t0d0
    0.1 2.7 5.5 21.3 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.7 0 0 c0t0d0s3 (/usr)
    0.1 0.0 0.6 0.1 0.0 0.0 0.2 4.9 0 0 c0t0d0s4 (/opt)
    0.1 19.5 1.9 84.1 0.0 0.0 0.1 2.4 0 3 c0t0d0s5 (/var)
    93.0 12.1 3470.4 470.3 0.0 1.1 0.1 10.3 0 17 c0t0d0s7 (/export)

    tty cpu
    tin tout us sy wt id
    22 29104 17 2 0 81
    extended device statistics
    r/s w/s kr/s kw/s wait actv wsvc_t asvc_t %w %b device
    10.5 0.0 5459.9 0.0 0.0 0.1 0.1 6.6 0 5 c0t0d0
    10.5 0.0 5460.0 0.0 0.0 0.1 0.1 6.6 0 5 c0t0d0s7 (/export)

    tty cpu
    tin tout us sy wt id
    21 32871 11 4 0 85
    extended device statistics
    r/s w/s kr/s kw/s wait actv wsvc_t asvc_t %w %b device
    6.5 4.0 1102.6 36.0 0.0 0.1 0.0 7.3 0 6 c0t0d0
    0.5 3.0 4.0 24.0 0.0 0.0 0.0 4.1 0 1 c0t0d0s0 (/)
    0.0 0.5 0.0 4.0 0.0 0.0 0.0 0.4 0 0 c0t0d0s5 (/var)
    6.0 0.5 1098.6 8.0 0.0 0.1 0.0 9.6 0 5 c0t0d0s7 (/export)


    tty cpu
    tin tout us sy wt id
    30 46695 14 5 0 81
    extended device statistics
    r/s w/s kr/s kw/s wait actv wsvc_t asvc_t %w %b device
    15.0 86.1 3873.6 377.9 0.0 0.3 0.0 3.3 0 26 c0t0d0
    0.0 3.0 0.0 24.0 0.0 0.0 0.0 1.4 0 0 c0t0d0s0 (/)
    5.5 83.1 5.5 353.9 0.0 0.2 0.0 1.8 0 16 c0t0d0s5 (/var)
    9.5 0.0 3868.0 0.0 0.0 0.2 0.0 18.2 0 16 c0t0d0s7 (/export)

    tty cpu
    tin tout us sy wt id
    16 11026 10 4 0 86
    extended device statistics
    r/s w/s kr/s kw/s wait actv wsvc_t asvc_t %w %b device
    220.7 191.1 2988.2 792.6 0.0 1.6 0.0 3.8 1 69 c0t0d0
    0.0 191.1 0.0 792.6 0.0 0.3 0.0 1.5 0 28 c0t0d0s5 (/var)
    220.7 0.0 2988.2 0.0 0.0 1.3 0.0 5.9 1 65 c0t0d0s7 (/export)


    I need the save the 4th iteration of the ouput (not all output)of iostat -xnmpztc 2 to a file
    iostat -xnmpztc 2 >> iostat.log
    the above command will apend the whole output to iostat.log but i need to save just the 4th iteration to file

    tty cpu
    tin tout us sy wt id
    30 46695 14 5 0 81
    extended device statistics
    r/s w/s kr/s kw/s wait actv wsvc_t asvc_t %w %b device
    15.0 86.1 3873.6 377.9 0.0 0.3 0.0 3.3 0 26 c0t0d0
    0.0 3.0 0.0 24.0 0.0 0.0 0.0 1.4 0 0 c0t0d0s0 (/)
    5.5 83.1 5.5 353.9 0.0 0.2 0.0 1.8 0 16 c0t0d0s5 (/var)
    9.5 0.0 3868.0 0.0 0.0 0.2 0.0 18.2 0 16 c0t0d0s7 (/export)

  2. #2
    Just Joined!
    Join Date
    Oct 2007
    Posts
    8

    RE: capture nth pattern of iostat output

    Since nobody replied to your post let me take a crack at it.

    I've had the need to capture the nth pattern from a file and I've found awk/nawk/gawk to be my friend for this. If you make an awk script file that does something like this:
    Code:
    BEGIN {counter = -1; flag = 0; num=num_test;}
    {
     if (/^tty cpu/)
      {
       if (flag) exit;
       counter++;
       if (counter == num) flag = 1;
      }
     if (flag) print $0;
    }
    END {}
    then use it like this:
    Code:
    iostat -xnmpztc 2 | awk -f awk-script.awk  -v num-test=4
    it should end up with only the 4th block from that output.

    Bests,

    Way

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...