Merge branch 'fgp_fixes' of https://github.com/sitsofe/fio
[fio.git] / tools / fio_generate_plots
index f65a326c87f52e6647a90988ade23ea092850da0..8872206e5b5b87d4e5b4b062669da54a21f94aee 100755 (executable)
@@ -7,7 +7,7 @@
 #
 # The script uses the files generated by FIO to create nice graphs in the
 # SVG format. This output format is supported by most modern browsers and
-# allows resolution independant graphs to be generated.
+# allows resolution independent graphs to be generated.
 #
 # This script supports GNUPLOT 4.4 and higher.
 # 
@@ -22,7 +22,7 @@ if [ -z "$1" ]; then
 fi
 
 GNUPLOT=$(which gnuplot)
-if [ ! -x $GNUPLOT ]
+if [ ! -x "$GNUPLOT" ]
 then
        echo You need gnuplot installed to generate graphs
        exit 1
@@ -93,20 +93,26 @@ plot () {
 
     i=0
     
-    for x in *_"$FILETYPE".log
+    for x in *_"$FILETYPE".log *_"$FILETYPE".*.log
     do
-        i=$((i+1))
-        PT=$(echo $x | sed s/_"$FILETYPE".log//g)
-        if [ ! -z "$PLOT_LINE" ]
-        then
-            PLOT_LINE=$PLOT_LINE", "
+        if [ -e "$x" ]; then
+            i=$((i+1))
+            PT=$(echo $x | sed 's/\(.*\)_'$FILETYPE'\(.*\).log$/\1\2/')
+            if [ ! -z "$PLOT_LINE" ]
+            then
+                PLOT_LINE=$PLOT_LINE", "
+            fi
+
+            DEPTH=$(echo $PT | cut -d "-" -f 4)
+            PLOT_LINE=$PLOT_LINE"'$x' using (\$1/1000):(\$2/$SCALE) title \"Queue depth $DEPTH\" with lines ls $i" 
         fi
-
-        DEPTH=$(echo $PT | cut -d "-" -f 4)
-           PLOT_LINE=$PLOT_LINE"'$x' using (\$1/1000):(\$2/$SCALE) title \"Queue depth $DEPTH\" with lines ls $i" 
-        
     done
 
+    if [ $i -eq 0 ]; then
+       echo "No log files found"
+       exit 1
+    fi
+
     OUTPUT="set output \"$TITLE-$FILETYPE.svg\" "
 
     echo " $PLOT_TITLE ; $YAXIS ; $DEFAULT_OPTS ; show style lines ; $OUTPUT ; plot "  $PLOT_LINE  | $GNUPLOT -