fio_generate_plots: cope with per_job_logs filenames
authorSitsofe Wheeler <sitsofe@yahoo.com>
Sun, 1 Oct 2017 08:07:15 +0000 (09:07 +0100)
committerSitsofe Wheeler <sitsofe@yahoo.com>
Sat, 7 Oct 2017 07:58:45 +0000 (08:58 +0100)
- Teach fio_generate_plots how to find log files that are generated when
  per_job_logs=1 (which has been the fio default for a while).
- Make fio_generate_plots spit out an error message when no log files
  are found.

Fixes: https://github.com/axboe/fio/issues/43
Fixes: https://github.com/axboe/fio/issues/323

Signed-off-by: Sitsofe Wheeler <sitsofe@yahoo.com>
tools/fio_generate_plots

index a47bfa5c3250147bffdde277dca2bbbaf473a61d..8872206e5b5b87d4e5b4b062669da54a21f94aee 100755 (executable)
@@ -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 -