From 4eba91b533d9c2389d3690ed5696f221e12b5d15 Mon Sep 17 00:00:00 2001 From: Nick Dokos Date: Tue, 24 Nov 2015 14:56:38 -0500 Subject: [PATCH] Ignore extra disk-stats array if present. Some versions of fio produce an extra disk-stats array. This change makes the postprocess script ignore the extra array if present. --- .../bench-scripts/postprocess/fio-postprocess | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/agent/bench-scripts/postprocess/fio-postprocess b/agent/bench-scripts/postprocess/fio-postprocess index f0a31590d3..d0acd1268b 100755 --- a/agent/bench-scripts/postprocess/fio-postprocess +++ b/agent/bench-scripts/postprocess/fio-postprocess @@ -9,22 +9,23 @@ my $tool_group = $ARGV[2]; my $js_str; open( JS, "<$dir/fio-result.txt" ) or die "Can't open $dir/fio-result.txt: $!"; -# skip past the non json stuff +# there may be more than one json array, and we want only the last one while ( ) { + # skip past the non json stuff if ( /{/ ) { - last; + $js_str = "{\n"; + while ( ) { + $js_str = $js_str . $_; + if ( /^}/ ) { + last; + } + } } } -if ( eof JS ) { - print "Could not read rest of json data\n"; - exit 1; -} else { - # read the rest of the file in to one string - local $/=undef; - binmode JS; - $js_str = ; - $js_str = "{\n" . $js_str; +if ( ! defined $js_str ) { + print "Could not find any json data, exiting\n"; + exit 1 } # convert [json] string in to big hash