Whamcloud - gitweb
LU-17744 ldiskfs: mballoc stats fixes
[fs/lustre-release.git] / lustre-iokit / ior-survey / iokit-parse-ior
1 #!/usr/bin/perl -w
2 # SPDX-License-Identifier: GPL-2.0
3
4 #
5 # This file is part of Lustre, http://www.lustre.org/
6 #
7
8 sub usages_msg(){
9         print "Usage: $0 <results_filename>\n"
10         print "  parses and plots IOR results using gnuplot, and generates a .dat file for\n"
11         print "  simple graphing in spreadhseets\n"
12         print "e.g.> perl iokit-parse-ior ior-log\n"
13         exit 1;
14 }
15
16 if ( !$ARGV[0] ) {
17         usages_msg()
18 }
19 $file = $ARGV[0];
20
21 # Open log file for reading
22 open ( PFILE, "$file") or die "Can't open results log file";
23 # Open .csv file for writting required columns from log file.
24 open ( DATAFILE, "> $file.dat" ) or die "Can't open csv file for writting";
25 $count = 0;
26 while ( <PFILE> ) {
27         chomp;
28         @line = split( /\s+/ ); # splits line into tokens
29         if ( $line[0] ) {
30                 # This comparison will be changed if there will be changes log file.
31                 if ( $line[0] eq "access" && $line[1] eq "bw(MiB/s)" ) {
32                         print DATAFILE "$count $line[1] $line[4] $line[5] $line[6] br(MiB/s) ropen(s) rd(s) rclose(s)\n";
33                         $count = $count + 1;
34                 }
35                 # Two columns from output file are skiped since
36                 # they are constant and may not be so useful while graphing results.
37                 if ( $line[0] eq "write" ) {
38                         print DATAFILE "$count $line[1] $line[4] $line[5] $line[6] ";
39                 }
40                 if ( $line[0] eq "read" ) {
41                         print DATAFILE "$line[1] $line[4] $line[5] $line[6]\n";
42                         $count = $count + 1;
43                 }
44         }
45 }
46 close PFILE;
47 close DATAFILE;
48
49 # Open .scr file for writting instructions for gnuplot.
50 open ( SCRFILE, "> $file.scr" ) or die "Can't open scr file for writting";
51 # Only two columns bw(MiB/s) and br(MiB/s) are considered for graphing results.
52 print SCRFILE "plot \"$file.dat\" using 1:2 axes x1y1 title \"bw(MiB/s)\" with line\n";
53 print SCRFILE "replot \"$file.dat\" using 1:6 axes x1y1 title \"br(MiB/s)\" with line\n";
54 print SCRFILE "pause -1\n";
55 close SCRFILE;
56 # check whether gnuplot exists?
57 system ("which gnuplot > /dev/null") == 0 or die "gnuplot does not exists, Please install it and try again.\n";
58 # invoke gnuplot to display graph.
59 system ("gnuplot $file.scr");