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