Advertisement
Guest User

shell script for plotting bonnie output

a guest
Sep 27th, 2010
1,088
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 4.85 KB | None | 0 0
  1. #!/bin/bash
  2. #
  3. # script formats bonnie output and calls gnuplot to create a png graph
  4. # of various bonnie parameters.
  5. #
  6. # feed script bonnie++ output - it will attempt to find the last line of bonnie output
  7. # which is all it really cares about anyway
  8. #
  9. # eg: Using uid:65534, gid:65534.
  10. # Writing a byte at a time...done
  11. # Writing intelligently...done
  12. # Rewriting...done
  13. # Reading a byte at a time...done
  14. # Reading intelligently...done
  15. # start 'em...done...done...done...done...done...
  16. # Create files in sequential order...done.
  17. # Stat files in sequential order...done.
  18. # Delete files in sequential order...done.
  19. # Create files in random order...done.
  20. # Stat files in random order...done.
  21. # Delete files in random order...done.
  22. # Version  1.96       ------Sequential Output------ --Sequential Input- --Random-
  23. # Concurrency   1     -Per Chr- --Block-- -Rewrite- -Per Chr- --Block-- --Seeks--
  24. # Machine        Size K/sec %CP K/sec %CP K/sec %CP K/sec %CP K/sec %CP  /sec %CP
  25. # bach            32G  2165  93 108640  10 70209  19  5469  97 285324  31 488.6  23
  26. # Latency             14746us     646ms    1855ms   16424us     165ms   90728us
  27. # Version  1.96       ------Sequential Create------ --------Random Create--------
  28. # myhost             -Create-- --Read--- -Delete-- -Create-- --Read--- -Delete--
  29. #               files  /sec %CP  /sec %CP  /sec %CP  /sec %CP  /sec %CP  /sec %CP
  30. #                  16   323   2 +++++ +++   318   2   353   2 +++++ +++   246   1
  31. # Latency               226ms     246us     164ms     105ms      61us     325ms
  32. # # 1.96,1.96,myhost,1,1285582173,32G,,2165,93,108640,10,70209,19,5469,97,285324,31,488.6,23,16,,,,,323,2,+++++,+++,318,2,353,2,+++++,+++,246,1,14746us,646ms,1855ms,16424us,165ms,90728us,226ms,246us,164ms,105ms,61us,325ms
  33.  
  34.  
  35. error()
  36. {
  37.    echo "**Error: $1"
  38.    exit
  39. }
  40.  
  41. # user must enter a filename of saved bonnie output for graphing
  42. test -z "$1" && error "need some bonnie output to graph"
  43. InFile="$1"
  44.  
  45. # read last line of bonnie output which is all we want to parse anyway
  46. data=`cat "$InFile" | grep -v ^$ | tail -1`
  47. test -z "$data" && error "Unable to find data line in bonnie output."
  48.  
  49. # some info about bonnie version
  50. ver=`echo "$data" | cut -d',' -f1`
  51. echo "created with bonnie version: $ver"
  52.  
  53. # hostname of box bonnie was run on
  54. host=`echo "$data" | cut -d',' -f3`
  55. echo "host:$host"
  56.  
  57. # seq block out  k/sec
  58. blockout=`echo "$data" | cut -d',' -f10`
  59.  
  60. # seq. rewrite output
  61. blockrew=`echo "$data" | cut -d',' -f12`
  62.  
  63. # seq. block input
  64. blockin=`echo "$data" | cut -d',' -f16`
  65.  
  66. # seeks are pos 18
  67. seeks=`echo "$data" | cut -d',' -f18`
  68.  
  69. # seq create is 25
  70. create=`echo "$data" | cut -d',' -f25`
  71.  
  72. # seq delete is 29
  73. delete=`echo "$data" | cut -d',' -f29`
  74.  
  75. # seq input create is 31
  76. randcreate=`echo "$data" | cut -d',' -f31`
  77.  
  78. # random create delete is 35
  79. randdelete=`echo "$data" | cut -d',' -f35`
  80.  
  81.  
  82. # if you don't have mktemp (solaris) just set a value for TMPFILE
  83. TMPFILE=`mktemp`
  84. echo "0 $blockout" > $TMPFILE
  85. echo "1 $blockrew" >> $TMPFILE
  86. echo "2 $blockin" >> $TMPFILE
  87. echo "3 $seeks" >> $TMPFILE
  88. echo "4 $create" >> $TMPFILE
  89. echo "5 $delete" >> $TMPFILE
  90. echo "6 $randcreate" >> $TMPFILE
  91. echo "7 $randdelete" >> $TMPFILE
  92.  
  93. # putting all the data on one line causes all the data to plot at one interval
  94. echo "0 $blockout 0.0 0.0 0.0 0.0 0.0 0.0 0.0" > $TMPFILE
  95. echo "1 0.0 $blockrew 0.0 0.0 0.0 0.0 0.0 0.0" >> $TMPFILE
  96. echo "2 0.0 0.0 $blockin 0.0 0.0 0.0 0.0 0.0" >> $TMPFILE
  97. echo "3 0.0 0.0 0.0 $seeks 0.0 0.0 0.0 0.0" >> $TMPFILE
  98. echo "4 0.0 0.0 0.0 0.0 $create 0.0 0.0 0.0" >> $TMPFILE
  99. echo "5 0.0 0.0 0.0 0.0 0.0 $delete 0.0 0.0" >> $TMPFILE
  100. echo "6 0.0 0.0 0.0 0.0 0.0 0.0 $randcreate 0.0" >> $TMPFILE
  101. echo "7 0.0 0.0 0.0 0.0 0.0 0.0 0.0 $randdelete" >> $TMPFILE
  102.  
  103. # name of png output graph - use data and num secs since 1970 for filename
  104. png="`echo $1 | cut -d'.' -f1`-`date '+%Y-%m-%d.%s'`"".png"
  105.  
  106.  
  107. # write tempfile, call gnuplot
  108. gnuplot << EOF
  109. set title "$host graph - bonnie v$ver"
  110. set terminal png truecolor size 800 crop font '/usr/share/fonts/truetype/freefont/FreeMono.ttf, 8'
  111. set output "$png"
  112. set xrange ['-1':'9']
  113. set yrange [0:500000]
  114. set grid
  115. set xlabel 'operations'
  116. set ylabel 'KB/sec'
  117. set xtics ("blk Out" 0, "blk rew" 1, "blk in" 2, "seeks" 3, "create" 4, "delete" 5, "rnd crt" 6, "rnd del" 7);
  118. set boxwidth .3
  119. plot \
  120. "$TMPFILE" using :1 title "blk out  :$blockout" with boxes, \
  121. "$TMPFILE" using :2 title "blk rew  :$blockrew" with boxes, \
  122. "$TMPFILE" using :3 title "blk in   :$blockin" with boxes, \
  123. "$TMPFILE" using :4 title "seeks    :$seeks" with boxes, \
  124. "$TMPFILE" using :5 title "create   :$create" with boxes, \
  125. "$TMPFILE" using :6 title "delete   :$delete" with boxes, \
  126. "$TMPFILE" using :7 title "rannd crt:$randcreate" with boxes, \
  127. "$TMPFILE" using :8 title "rand del :$randdelete" with boxes
  128. EOF
  129.  
  130. echo "output saved to $png"
  131.  
  132. # clean up
  133. rm -f $TMPFILE
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement