This file is indexed.

/usr/bin/plot-sgpdd is in lustre-utils 1.8.5+dfsg-3ubuntu1.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
#!/usr/bin/perl -w
# 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 script.
#
#        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:
# $ sgpdd-survey > log_filename
# $ plot-sgpdd <log_filename>
# [Note: 1. This script may need modifications whenever there will be
#           modifications in output format of sgpdd-survey script.
#        2. Gnuplot version 4.0 or above is required.]

sub usage() 
{
	print STDERR "Usage: $0 [options] <log_filename>\n";
	print STDERR "  $0 parses and plots graphs from the output of sgpdd-survey\n";
	print STDERR "  It generates text data files (.dat) and graphs (.png) using gnuplot.\n";
	print STDERR "options:\n";
	print STDERR "	--rt: Subtitle for read graphs\n";
	print STDERR "	--wt: Subtitle for write graphs\n";
	print STDERR "	--y: Y-axis scale\n";
	print STDERR "e.g. # $0 --rt=\"no prefetch\" --wt=\"WB disabled\" --y=500 sgpdd.summary\n";
	exit 1;
}

# check whether gnuplot exists?
system ("which gnuplot > /dev/null") == 0 or die "gnuplot does not exist, please install it and try again.\n";

# check whether gnuplot supports png
$pngsupport = "ldd `which gnuplot` | grep -q libpng";
system ("$pngsupport") == 0 or die "gnuplot installed does not support png.
	Please install gnuplot to support png and try again.\n"; 

my @GraphTitle;

#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 KBytes, $opt_rdtitle\"\n";
		}
		if ($op eq "wr") {
			print SCRFILE "set title \"@GraphTitle\\n$rwlabel, Rsize = $rsz KBytes, $opt_wrtitle\"\n";
		}
	} else {
		print SCRFILE "set title \"@GraphTitle\\n$rwlabel, Rsize = $rsz KBytes\"\n";
	}
	print SCRFILE "set xlabel \"Threads\"\n";
	print SCRFILE "set ylabel \"Speeds(MB/s)\"\n";
	print SCRFILE "set logscale x\n";
	print SCRFILE "set grid\n";
        print SCRFILE "set terminal png\n";
        print SCRFILE "set output \"/dev/null\"\n";
	if ($opt_y != 0) {
		print SCRFILE "set yrange [ 0:$opt_y ]\n";
	} else {
		print SCRFILE "set yrange [ 0: ]\n";
	}

	my $plot = "plot";
	$i = 2;
	my @numrgs = split " ", $regions;
	$xrange = 1;
	# generate instructions for gnuplot, with adjusting X-axes ranges
	
	foreach my $j (sort numerically split " ", $threads) {
		if ($op eq "wr") {
			$using = ( $i < $#numrgs ) ? $i : $#numrgs;
			printf SCRFILE "$plot \"$file-$rsz-$op.dat\" using 1:$using axes x%dy1 title \"write-obj$j\" with line\n", $xrange;
		}
		if ($op eq "rd") {
			$using = ( $i < $#numrgs ) ? $i : $#numrgs;
			printf SCRFILE "$plot \"$file-$rsz-$op.dat\" using 1:$using axes x%dy1 title \"read-obj$j\" with line\n", $xrange;
		}
		$i++;
		$plot = "replot";
	}
	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");
}

sub check_data_file () {
        my $file=shift;
        my @values;
        my @tmp;

        open ( FILE, "< $file" ) or die "Can't open $file for reading";
        while ( <FILE> ) {
                @tmp = split;
                push @values, [ @tmp ];
        }
        close FILE;

        for ( $j = 0; $j <= $#tmp; $j++) {
                my $sum=0;
                for ($i = 2; $i <= $#values ; $i ++) {
                        $values [$i][$j] =~ "-" or $sum = $sum + $values [$i][$j];
                }
                die "File: $file : $j column contains no data.\n" unless $sum != 0;
        }
}

sub numerically { $a <=> $b; }

#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.
	my $datafile = "$file-$rsz-$op.dat";
	open ( DATAFILE, "> $datafile" ) or die "Can't open csv $datafile for writing";
	printf DATAFILE "%-6s", "0";
	
	foreach my $j (sort numerically split " ", $regions) {
		printf DATAFILE "%-8s", "$op$j";
	}

	# threads, line [7], strings
	foreach my $i (sort numerically split " ", $threads) {
	        printf DATAFILE "\n%-6s", $i;

		# regions, line [5], column
		foreach my $j (sort numerically split " ", $regions) {
			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;
	&check_data_file ( $datafile );		
}

if ( !$ARGV[0] ) {
	usage();
}
$regions = "";
$threads = "";
$count = 0;
$wrrd = 0;
$rdwr = 0;
$writeop = 0;
$readop = 0;
$rsz = 0;
$opt_rdtitle = "";
$opt_wrtitle = "";
$opt_y = 0;
# Command line parameter parsing
use Getopt::Long;
GetOptions ('help' => \$opt_help, 'rt=s' => \$opt_rdtitle, 'wt=s' => \$opt_wrtitle, 'y=i' => \$opt_y) or usage(); 
if ($opt_help) {
	usage();
}
$file = $ARGV[0];

open ( PFILE, "$file") or die "Can't open $file";
LABEL: while ( <PFILE> ) {
	chomp;
	@line = split( /\s+/ );
	if ($line[27] && $count != 0) {
		print "invalid file format\n";
		exit 1;	
	} 
	if ($count == 0) {
		@GraphTitle = @line;
		$count++;
		next LABEL;
	}
	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];		
		$regions = "";
		$threads = "";
	}
	#print "rg$line[5] th$line[7] w$line[9] r$line[$rindex]\n";
	$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 {
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];
	}
	$regions .= " $line[5]" unless $regions =~ $line[5];
	$threads .= " $line[7]" unless $threads =~ $line[7];
	$count++;
}
close PFILE;
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";
}