1 #!/bin/sh 2 # 3 # This script is an almost total rewrite by Louwrentius 4 # of the original fio_generate_plots script provided as part of the FIO storage 5 # benchmark utiliy. I only retained how GNUplot is used to generate graphs, as 6 # that is something I know nothing about. 7 # 8 # The script uses the files generated by FIO to create nice graphs in the 9 # SVG format. This output format is supported by most modern browsers and 10 # allows resolution independent graphs to be generated. 11 # 12 # This script supports GNUPLOT 4.4 and higher. 13 # 14 # Version 1.0 @ 20121231 15 # 16 # 17 # 18 19 if [ -z "$1" ]; then 20 echo "Usage: fio_generate_plots subtitle [xres yres]" 21 exit 1 22 fi 23 24 GNUPLOT=$(which gnuplot) 25 if [ ! -x "$GNUPLOT" ] 26 then 27 echo You need gnuplot installed to generate graphs 28 exit 1 29 fi 30 31 TITLE="$1" 32 33 # set resolution 34 if [ ! -z "$2" ] && [ ! -z "$3" ] 35 then 36 XRES="$2" 37 YRES="$3" 38 else 39 XRES=1280 40 YRES=768 41 fi 42 43 if [ -z "$SAMPLE_DURATION" ] 44 then 45 SAMPLE_DURATION="*" 46 fi 47 48 DEFAULT_GRID_LINE_TYPE=3 49 DEFAULT_LINE_WIDTH=2 50 DEFAULT_LINE_COLORS=" 51 set object 1 rectangle from screen 0,0 to screen 1,1 fillcolor rgb\"#ffffff\" behind 52 set style line 1 lc rgb \"#E41A1C\" lw $DEFAULT_LINE_WIDTH lt 1; 53 set style line 2 lc rgb \"#377EB8\" lw $DEFAULT_LINE_WIDTH lt 1; 54 set style line 3 lc rgb \"#4DAF4A\" lw $DEFAULT_LINE_WIDTH lt 1; 55 set style line 4 lc rgb \"#984EA3\" lw $DEFAULT_LINE_WIDTH lt 1; 56 set style line 5 lc rgb \"#FF7F00\" lw $DEFAULT_LINE_WIDTH lt 1; 57 set style line 6 lc rgb \"#DADA33\" lw $DEFAULT_LINE_WIDTH lt 1; 58 set style line 7 lc rgb \"#A65628\" lw $DEFAULT_LINE_WIDTH lt 1; 59 set style line 20 lc rgb \"#000000\" lt $DEFAULT_GRID_LINE_TYPE lw $DEFAULT_LINE_WIDTH; 60 " 61 62 DEFAULT_TERMINAL="set terminal svg enhanced dashed size $XRES,$YRES dynamic" 63 DEFAULT_TITLE_FONT="\"Helvetica,28\"" 64 DEFAULT_AXIS_FONT="\"Helvetica,14\"" 65 DEFAULT_AXIS_LABEL_FONT="\"Helvetica,16\"" 66 DEFAULT_XLABEL="set xlabel \"Time (sec)\" font $DEFAULT_AXIS_LABEL_FONT" 67 DEFAULT_XTIC="set xtics font $DEFAULT_AXIS_FONT" 68 DEFAULT_YTIC="set ytics font $DEFAULT_AXIS_FONT" 69 DEFAULT_MXTIC="set mxtics 0" 70 DEFAULT_MYTIC="set mytics 2" 71 DEFAULT_XRANGE="set xrange [0:$SAMPLE_DURATION]" 72 DEFAULT_YRANGE="set yrange [0:*]" 73 DEFAULT_GRID="set grid ls 20" 74 DEFAULT_KEY="set key outside bottom center ; set key box enhanced spacing 2.0 samplen 3 horizontal width 4 height 1.2 " 75 DEFAULT_SOURCE="set label 30 \"Data source: http://example.com\" font $DEFAULT_AXIS_FONT tc rgb \"#00000f\" at screen 0.976,0.175 right" 76 DEFAULT_OPTS="$DEFAULT_LINE_COLORS ; $DEFAULT_GRID_LINE ; $DEFAULT_GRID ; $DEFAULT_GRID_MINOR ; $DEFAULT_XLABEL ; $DEFAULT_XRANGE ; $DEFAULT_YRANGE ; $DEFAULT_XTIC ; $DEFAULT_YTIC ; $DEFAULT_MXTIC ; $DEFAULT_MYTIC ; $DEFAULT_KEY ; $DEFAULT_TERMINAL ; $DEFAULT_SOURCE" 77 78 plot () { 79 80 if [ -z "$TITLE" ] 81 then 82 PLOT_TITLE=" set title \"$1\" font $DEFAULT_TITLE_FONT" 83 else 84 PLOT_TITLE=" set title \"$TITLE\\\n\\\n{/*0.6 "$1"}\" font $DEFAULT_TITLE_FONT" 85 fi 86 FILETYPE="$2" 87 YAXIS="set ylabel \"$3\" font $DEFAULT_AXIS_LABEL_FONT" 88 SCALE=$4 89 90 echo "Title: $PLOT_TITLE" 91 echo "File type: $FILETYPE" 92 echo "yaxis: $YAXIS" 93 94 i=0 95 96 for x in *_"$FILETYPE".log 97 do 98 i=$((i+1)) 99 PT=$(echo $x | sed s/_"$FILETYPE".log//g) 100 if [ ! -z "$PLOT_LINE" ] 101 then 102 PLOT_LINE=$PLOT_LINE", " 103 fi 104 105 DEPTH=$(echo $PT | cut -d "-" -f 4) 106 PLOT_LINE=$PLOT_LINE"'$x' using (\$1/1000):(\$2/$SCALE) title \"Queue depth $DEPTH\" with lines ls $i" 107 108 done 109 110 OUTPUT="set output \"$TITLE-$FILETYPE.svg\" " 111 112 echo " $PLOT_TITLE ; $YAXIS ; $DEFAULT_OPTS ; show style lines ; $OUTPUT ; plot " $PLOT_LINE | $GNUPLOT - 113 unset PLOT_LINE 114 } 115 116 # 117 # plot <sub title> <file name tag> <y axis label> <y axis scale> 118 # 119 120 plot "I/O Latency" lat "Time (msec)" 1000 121 plot "I/O Operations Per Second" iops "IOPS" 1 122 plot "I/O Submission Latency" slat "Time (sec)" 1 123 plot "I/O Completion Latency" clat "Time (msec)" 1000 124 plot "I/O Bandwidth" bw "Throughput (KB/s)" 1 125 126 127