X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=blobdiff_plain;f=lustre-iokit%2Fsgpdd-survey%2Fplot-sgpdd;h=542b1da38fcf2e006e7d549a22fafc6e401729b7;hp=274ab31a9a4b376f1b6164682eb3af431815f174;hb=9053b73b74f9994df320100fdc637bf6fda13e23;hpb=883187fe4288076fbe1a4e634fb69f1476554719 diff --git a/lustre-iokit/sgpdd-survey/plot-sgpdd b/lustre-iokit/sgpdd-survey/plot-sgpdd index 274ab31..542b1da 100755 --- a/lustre-iokit/sgpdd-survey/plot-sgpdd +++ b/lustre-iokit/sgpdd-survey/plot-sgpdd @@ -1,62 +1,217 @@ #!/usr/bin/perl -w -# Report generation for plot-sgpdd.pl -# =================================== -# The plot-sgpdd.pl script is used to generate csv file and +# Report generation for plot-sgpdd +# ================================ +# The plot-sgpdd script is used to generate csv file and # instructions files for gnuplot from the output of sgpdd-survey.pl script. # -# The plot-sgpdd.pl also creates .scr file that contains instructions +# The plot-sgpdd also creates .scr file that contains instructions # for gnuplot to plot the graph. After generating .dat and .scr files this # script invokes gnuplot to display graph. # # Syntax: -# $ plot-sgpdd.pl +# $ sgpdd-survey > log_filename +# $ plot-sgpdd # [Note: 1. This script may need modifications whenever there will be # modifications in output format of sgpdd-survey.pl script. # 2. Gnuplot version 4.0 or above is required.] -# arg 0 is filename -sub usages_msg() { - print "Usage: $0 \n"; +my @GraphTitle; +sub usage() { + print "Usage: $0 [--rt=] [--wt=]\n"; print " The $0 parses and plots graph for output of sgpdd-survey.pl using gnuplot,\n"; - print " it generates .dat and .scr files for results graphing\n"; - print "e.g.> perl $0 sgpdd-log \n"; + print " it generates -.dat and --.scr files\n"; + print " those will be used for graphing the results\n"; + print "e.g. # perl $0 sgpdd-log \"8 devices, chunk = 256\"\n"; + print " # gnuplot -.scr\n"; exit 1; } -my @GraphTitle; +# check whether gnuplot exists? +system ("which gnuplot > /dev/null") == 0 or die "gnuplot does not exist, please install it and try again.\n"; + +#Subroutine to write .scr file that further used by gnuplot to plot the graph. +sub write_scr_file() { + my $op = $_[0]; + print "generating plot $file-$rsz-$op.png\n"; + open ( SCRFILE, "> $file-$rsz-$op.scr" ) or die "Can't open scr file for writing"; + if ($op eq "rd") { + $rwlabel = "Read"; + } + if ($op eq "wr") { + $rwlabel = "Write"; + } + + if ($opt_rdtitle || $opt_wrtitle) { + if ($op eq "rd") { + print SCRFILE "set title \"@GraphTitle\\n$rwlabel, Rsize = $rsz, $opt_rdtitle\"\n"; + } + if ($op eq "wr") { + print SCRFILE "set title \"@GraphTitle\\n$rwlabel, Rsize = $rsz, $opt_wrtitle\"\n"; + } + } else { + print SCRFILE "set title \"@GraphTitle\\n$rwlabel, Rsize = $rsz\"\n"; + } + print SCRFILE "set xlabel \"Threads\"\n"; + print SCRFILE "set ylabel \"Speeds(MB/s)\"\n"; + print SCRFILE "set logscale x\n"; + my $plot = "plot"; + $i = 2; + $xrange = 1; + # generate instructions for gnuplot, with adjusting X-axes ranges + for ($j = 1; $j <= $thread ; $j = $j + $j) { + if ($j > 15 ) { + $xrange = 2; + } + if ($op eq "wr") { + printf SCRFILE "$plot \"$file-$rsz-$op.dat\" using 1:$i axes x%dy1 title \"write$j\" with line\n", $xrange; + } + if ($op eq "rd") { + printf SCRFILE "$plot \"$file-$rsz-$op.dat\" using 1:$i axes x%dy1 title \"read$j\" with line\n", $xrange; + } + $i++; + $plot = "replot"; + } + print SCRFILE "set terminal png transparent\n"; + print SCRFILE "set output \"$file-$rsz-$op.png\"\n"; + print SCRFILE "replot\n"; + close SCRFILE; + # invoke gnuplot to display graph. + system ("gnuplot $file-$rsz-$op.scr") == 0 or die "ERROR: while ploting graph"; + system ("rm $file-$rsz-$op.scr"); +} + +#Subroutine to write .dat file that further used by gnuplot to plot the graph. +sub write_dat_file() { + my $op = $_[0]; + print "writing data $file-$rsz-$op.dat\n"; + # Open .csv/.dat file for writing required columns from log file. + open ( DATAFILE, "> $file-$rsz-$op.dat" ) or die "Can't open csv file for writing"; + printf DATAFILE "%-6s", "0"; + for ($j = 1; $j <= $thread ; $j = $j + $j) { + printf DATAFILE "%-8s", "$op$j"; + } + for ( $i = 1; $i <= $region; $i = $i + $i ) { + printf DATAFILE "\n%-6s", $i; + for ($j = 1; $j <= $thread ; $j = $j + $j) { + if (($op eq "rd" && $rdwr) || ($op eq "wr" && $wrrd) || ($readop) || ($writeop)) { + if ( $out{$i}{$j} ) { + printf DATAFILE "%-8s", $out{$i}{$j}; + } else { + printf DATAFILE "%-8s", "-"; + } + } else { + if (($j <= 1 && $out{$i}{$j - 1})) { + printf DATAFILE "%-8s", $out{$i}{$j - 1}; + }elsif ($out{$i}{$j + 1} && $j > 1) { + printf DATAFILE "%-8s", $out{$i}{$j + 1}; + } else { + printf DATAFILE "%-8s", "-"; + } + } + } + } + close DATAFILE; +} if ( !$ARGV[0] ) { - usages_msg(); + usage(); } $file = $ARGV[0]; $region = 0; $thread = 0; $count = 0; +$wrrd = 0; +$rdwr = 0; +$writeop = 0; +$readop = 0; +$rsz = 0; +$opt_rdtitle = ""; +$opt_wrtitle = ""; +# Command line parameter parsing +use Getopt::Long; +GetOptions ('help' => \$opt_help, 'rt=s' => \$opt_rdtitle, 'wt=s' => \$opt_wrtitle) or usage(); +if ($opt_help) { + usage(); +} open ( PFILE, "$file") or die "Can't open results"; LABEL: while ( ) { chomp; @line = split( /\s+/ ); + if ($line[27]) { + print "invalid file format\n"; + exit 1; + } if ($count == 0) { @GraphTitle = @line; $count++; next LABEL; } - $rindex = 18; - if ($line[9]) { - if ($line[10] eq "failed") { - $rindex = 12; - } else { - $out{$line[7]}{$line[5]} = $line[9]; - } + if ($line[8]) { + if ($line[8] eq "ENOMEM") { + next LABEL; + } + } + if (!$rsz && $line[3]) { + $rsz = $line[3]; + } + if ($rsz != $line[3]) { + if($readop) { + &write_dat_file("rd"); + &write_scr_file("rd"); + } + if($writeop) { + &write_dat_file("wr"); + &write_scr_file("wr"); + } + if ($wrrd || $rdwr) { + &write_dat_file("rd"); + &write_scr_file("rd"); + &write_dat_file("wr"); + &write_scr_file("wr"); + } + $rsz = $line[3]; + $region = 0; + $thread = 0; } #print "rg$line[5] th$line[7] w$line[9] r$line[$rindex]\n"; - if ($line[$rindex]) { - if (!($line[$rindex+1] eq "failed")) { - if ($line[5] <= 1 ) { - $out{$line[7]}{$line[5] - 1} = $line[$rindex]; + $rindex = 18; + if ($line[18]) { + if ($line[10] eq "failed") { + $rindex = 12; + } + if ($line[8] eq "write" && $line[17] eq "read") { + $wrrd = 1; + } + if ($line[8] eq "read" && $line[17] eq "write") { + $rdwr = 1; + } + } else { + if ($line[8] eq "write" && $line[9]) { + $writeop = 1; + } + if ($line[8] eq "read" && $line[9]) { + $readop = 1; + } + + } + if ($wrrd || $rdwr) { + $out{$line[7]}{$line[5]} = $line[9]; + if ($line[$rindex+1]) { + if (!($line[$rindex+1] eq "failed")) { + goto LABEL2; + } } else { - $out{$line[7]}{$line[5] + 1} = $line[$rindex]; +LABEL2: if ($line[5] <= 1 ) { + $out{$line[7]}{$line[5] - 1} = $line[$rindex]; + } else { + $out{$line[7]}{$line[5] + 1} = $line[$rindex]; + } } - } + } + if ($writeop) { + $out{$line[7]}{$line[5]} = $line[9]; + } + if ($readop) { + $out{$line[7]}{$line[5]} = $line[9]; } if ( $region < $line[7] ) { $region = $line[7]; @@ -67,50 +222,21 @@ LABEL: while ( ) { $count++; } close PFILE; - -print "@GraphTitle\n"; -# Open .csv file for writting required columns from log file. -open ( DATAFILE, "> $file.dat" ) or die "Can't open csv file for writting"; -printf DATAFILE "%-6s", "0"; -for ($j = 1; $j <= $thread ; $j = $j + $j) { - printf DATAFILE "%-8s%-8s", "wr$j", "rd$j"; -} -for ( $i = 1; $i <= $region; $i = $i + $i ) { - printf DATAFILE "\n%-6s", $i; - for ($j = 1; $j <= $thread ; $j = $j + $j) { - if ( $out{$i}{$j} ) { - printf DATAFILE "%-8s", $out{$i}{$j}; - } else { - printf DATAFILE "%-8s", "-"; - } - if ( $j <= 1 && $out{$i}{$j - 1}) { - printf DATAFILE "%-8s", $out{$i}{$j - 1}; - } elsif ($out{$i}{$j + 1}) { - printf DATAFILE "%-8s", $out{$i}{$j + 1}; - } else { - printf DATAFILE "%-8s", "-"; - } +if ($count > 1 && $rsz) { + if($readop) { + &write_dat_file("rd"); + &write_scr_file("rd"); } + if($writeop) { + &write_dat_file("wr"); + &write_scr_file("wr"); + } + if ($wrrd || $rdwr) { + &write_dat_file("rd"); + &write_scr_file("rd"); + &write_dat_file("wr"); + &write_scr_file("wr"); + } +} else { + print "Invalid log file format\n"; } -close DATAFILE; -open ( SCRFILE, "> $file.scr" ) or die "Can't open scr file for writting"; -print SCRFILE "set title \"@GraphTitle\"\n"; -print SCRFILE "set xlabel \"Threads\"\n"; -print SCRFILE "set ylabel \"Speeds(MB/s)\"\n"; -my $plot = "plot"; -$i = 2; -$xrange = 1; -# generate instructions for gnuplot, with adjusting X-axes ranges -for ($j = 1; $j <= $thread ; $j = $j + $j) { - if ($j > 15 ) { - $xrange = 2; - } - printf SCRFILE "$plot \"$file.dat\" using 1:$i axes x%dy1 title \"write$j\" with line\n", $xrange; - $plot = "replot"; - $i++; - printf SCRFILE "$plot \"$file.dat\" using 1:$i axes x%dy1 title \"read$j\" with line\n", $xrange; - $i++; -} -print SCRFILE "pause -1\n"; -close SCRFILE; -system ("gnuplot $file.scr") == 0 or die "ERROR: while ploting graph.\nMake sure that gnuplot is working properly";