Advertisement
Guest User

collectl to iostat via awk

a guest
Mar 21st, 2012
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Awk 2.00 KB | None | 0 0
  1. #
  2. # Awk script to convert collectl output into an iostat format.
  3. #
  4. # Requirements:
  5. #   Your collectl output is generated via the command:
  6. #       /usr/bin/collectl --playback (your files) --subsys cD -oT -P -f (output files)
  7. #
  8. #   Then you take the output and sort it to put together the CPU and disk output:
  9. #         gunzip -c (output files) | sort  > intermediate_file
  10. #
  11. #   Feed intermediate_file to this script and it will produce iostat output in the format:
  12. #       avg-cpu:  %user   %nice %system %iowait  %steal   %idle
  13. #                  0.08    0.01    0.10    0.02    0.00   99.79
  14. #
  15. #       Device:         rrqm/s   wrqm/s   r/s   w/s    rkB/s    wkB/s avgrq-sz avgqu-sz   await  svctm  %util
  16. #       sda               0.01     3.38  0.06  0.28     0.77    14.67    89.72     0.00    6.62   0.27   0.01
  17. #       sda1              0.00     0.00  0.00  0.00     0.00     0.00     7.99     0.00    0.65   0.63   0.00
  18. #       sda2              0.01     3.38  0.06  0.28     0.76    14.67    89.77     0.00    6.62   0.27   0.01
  19. #
  20. #
  21. BEGIN { FS = " " }
  22.  
  23. # CPU records have 21 fields.
  24. NF == 21 {
  25.     printf("\navg-cpu:  %%user   %%nice %%system %%iowait  %%steal   %%idle\n");
  26.     printf("         %6.2f  %6.2f  %6.2f  %6.2f  %6.2f  %6.2f\n\n", $3, $4, $5+$7+$8, $6, $9, $10 )
  27.     }
  28.  
  29. # DISK records may have hundreds of fields
  30.  NF > 21 {
  31. #  Print the header for the disk report
  32.     printf("Device:         rrqm/s   wrqm/s    r/s      w/s    rkB/s    wkB/s avgrq-sz avgqu-sz   await  svctm  %%util\n");
  33.  
  34. # Read this line into an array
  35.     disks = split($0,diskstat," ")
  36.  
  37. # Loop through the array for disk data. Skip the first 2 items (date & time) and print a return after each row.
  38.     for ( stat = 3; stat <= disks; stat = stat+12 )
  39.         printf("%-13s %8.2f %8.2f %7.2f %7.2f %8.2f %8.2f %8.2f %8.2f %7.2f %6.2f %6.2f\n", diskstat[stat], diskstat[stat+2], diskstat[stat+5], diskstat[stat+1], diskstat[stat+4], diskstat[stat+3], diskstat[stat+6], diskstat[stat+7], diskstat[stat+8], diskstat[stat+9], diskstat[stat+10], diskstat[stat+11] )
  40.    }
  41.  
  42.  
  43.  
  44. END { }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement