2 # Report generation for ost-survey.pl
3 # ===================================
4 # The plot-ost.pl script is used to generate csv file and
5 # instructions files for gnuplot from the output of ost-survey.pl script.
7 # The plot-ost.pl also creates .scr file that contains instructions
8 # for gnuplot to plot the graph. After generating .dat and .scr files this
9 # script invokes gnuplot to display graph.
12 # $ plot-ost.pl <log_filename>
13 # Note: 1. This script may need modifications whenever there will be
14 # modifications in output format of ost-survey.pl script.
15 # 2. Gnuplot version 4.0 or above is required.
19 print "Usage: $0 <log_filename> \n";
20 print " $0 produces graphs from the output of ost-survey.pl\n";
21 print " using gnuplot.\n";
22 print "e.g.# perl ost-survey /mnt/lustre > ost-log; perl $0 ost-log\n";
26 my $count = 0; # count for number of rows in csv(.dat) file.
27 my @line; # To store recently read line from log file
35 # Open log file for reading
36 open ( PFILE, "$file") or die "Can't open results log file";
37 # Open .csv file for writting required columns from log file.
38 open ( DATAFILE, "> $file.dat" ) or die "Can't open csv file for writting";
39 LABLE:while ( <PFILE> ) {
41 @line = split( /\s+/ ); # splits line into tokens
42 # This comparison may be changed if there will be changes log file.
43 if ( $line[0] eq "Ost#" ) {
44 print DATAFILE "$line[0] $line[1] $line[2]\n";
46 <PFILE>; # skip the "---------" line from result file.
49 if ($line[2] eq "OST" && $line[3] eq "speed") {
51 @GraphTitle = split( /:/ );
55 print "Invalid logfile format\n";
60 @line = split( /\s+/ ); # splits line into tokens
61 if ( $line[1] ne "Inactive" ) {
62 print DATAFILE "$count $line[1] $line[2]\n";
68 # Open .scr file for writting instructions for gnuplot.
69 open ( SCRFILE, "> $file.scr" ) or die "Can't open scr file for writting";
70 # generate instructions for gnuplot. decide axes depends on ranges in @columnvalues
71 print SCRFILE "set title \"$GraphTitle[1]\"\n";
72 print SCRFILE "set xlabel \"OST index\"\n";
73 print SCRFILE "set ylabel \"MB/s\"\n";
74 print SCRFILE "set boxwidth 0.2\n";
75 print SCRFILE "plot \"$file.dat\" using 1:2 axes x1y1 title \"Read(MB/s)\" with boxes fs solid 0.7\n";
76 print SCRFILE "replot \"$file.dat\" using (\$1 + 0.2):3 axes x1y1 title \"Write(MB/s)\" with boxes fs solid 0.7\n";
77 print SCRFILE "pause -1\n";
79 # invoke gnuplot to display graph.
80 system ("gnuplot $file.scr") == 0 or die "ERROR: while ploting graph.\nMake sure that gnuplot is working properly";