- Timestamp:
- Aug 19, 2010, 6:50:13 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20100621/tools/czartool/Czarplot.pm
r28794 r28980 154 154 my ($self, $minY, $maxY) = @_; 155 155 156 ${$maxY} = ${$maxY} + (${$maxY}/10); 157 ${$minY} = ${$minY} - (${$minY}/10); 156 my $tmp; 157 if (${$maxY} < ${$minY}) { 158 159 $tmp = ${$maxY}; 160 ${$maxY} = ${$minY}; 161 ${$minY} = $tmp; 162 } 163 164 my $border = (${$maxY} - ${$minY})/10; 165 166 ${$maxY} += $border; 167 ${$minY} -= $border ; 158 168 if (${$maxY} == 0) {${$maxY} = 1;} 159 169 if (${$minY} == 0) {${$minY} = -1;} 160 170 } 161 171 172 173 ########################################################################### 174 # 175 # Figures out suitable spacing for time tics on time-series pliots 176 # 177 ########################################################################### 178 sub getTimeSpacing { 179 my ($self, $timeDiff, $divX, $timeFormat) = @_; 180 181 # if less than a couple of hour's data plotted, show 30 mins tics 182 if ($timeDiff < 7200) { 183 ${$timeFormat} = "%H:%M"; 184 ${$divX} = 1800; 185 } 186 # if less than half a day's data plotted, show hourly tics 187 elsif ($timeDiff < 43200) { 188 ${$timeFormat} = "%H:%M"; 189 ${$divX} = 3600; 190 } 191 # if less than one day's data plotted, show 2 hourly tics 192 elsif ($timeDiff < 86400) { 193 ${$timeFormat} = "%H:%M"; 194 ${$divX} = 7200; 195 } 196 # if less than 1 week's data is data plotted, show daily tics 197 elsif ($timeDiff < 604800) { 198 199 ${$timeFormat} = "%m/%d"; 200 ${$divX} = 86400; 201 } 202 else { 203 204 ${$timeFormat} = "%m/%d"; 205 ${$divX} = 172800; 206 } 207 } 208 162 209 ########################################################################### 163 210 # … … 171 218 172 219 my $timeFormat = undef; 173 174 my $divX = $timeDiff/4; 175 176 # if less than a couple of hour's data plotted, show 30 mins tics 177 if ($timeDiff < 7200) { 178 $timeFormat = "%H:%M"; 179 $divX = 1800; 180 } 181 # if less than half a day's data plotted, show hourly tics 182 elsif ($timeDiff < 43200) { 183 $timeFormat = "%H:%M"; 184 $divX = 3600; 185 } 186 # if less than one day's data plotted, show 2 hourly tics 187 elsif ($timeDiff < 86400) { 188 $timeFormat = "%H:%M"; 189 $divX = 7200; 190 } 191 # if more than one day's data plotted, show daily tics 192 else { 193 194 $timeFormat = "%m/%d %H:%M"; 195 $divX = 86400; 196 } 220 my $divX = undef; 221 222 $self->getTimeSpacing($timeDiff, \$divX, \$timeFormat); 197 223 198 224 my $numOfPlots = keys %$gnuplotFiles; 225 my $title = undef; 226 227 # sort out plot title 228 if ($numOfPlots == 1) {foreach my $stage (keys %$gnuplotFiles) {$title = "'".$stage."'";}} 229 else {$title = "'All stages'"} 230 231 $title .= " for '$label', '$fromTime' to '$toTime'"; 199 232 200 233 open (GP, "|/usr/bin/gnuplot -persist") or die "no gnuplot"; … … 205 238 "set term $self->{_outputFormat};" . 206 239 "set output \"$outputFile\";" . 207 "set title \" All stages for '$label' since $fromTime\";" .240 "set title \"$title\";" . 208 241 "set key left top;" . 209 242 "set xdata time;" . 210 243 "set timefmt \"$self->{_dateFormat}\";" . 244 # "set yrange [\"$minY\":\"$maxY\"];" . 211 245 "set xrange [\"$minX\":\"$maxX\"];" . 212 246 "set format x \"$timeFormat\";" . … … 224 258 if ($numOfPlots == 1) { 225 259 226 print GP "'" . $gnuplotFiles->{$stage} . "' using 1:4 title \" processed\" with lines lt 2,";227 print GP "'" . $gnuplotFiles->{$stage} . "' using 1:2 title \" pending\" with lines lt 3,";228 print GP "'" . $gnuplotFiles->{$stage} . "' using 1:3 title \" faults\" with lines lt 1";260 print GP "'" . $gnuplotFiles->{$stage} . "' using 1:4 title \"Processed\" with lines lt 2,"; 261 print GP "'" . $gnuplotFiles->{$stage} . "' using 1:2 title \"Pending\" with lines lt 4,"; 262 print GP "'" . $gnuplotFiles->{$stage} . "' using 1:3 title \"Faults\" with lines lt 7"; 229 263 } 230 264 # when plotting multiple stages, show only processed … … 241 275 ########################################################################### 242 276 # 243 # Plots a histogram of processed stuff 244 # 245 ########################################################################### 246 sub plotHistogram { 247 my ($self, $inputFile, $outputFile, $label, $fromTime, $toTime) = @_; 277 # Plots a time-series of cluster storage 278 # 279 ########################################################################### 280 sub plotStorageTimeSeries { 281 my ($self, $fromTime, $toTime) = @_; 282 283 my $prefix = $self->{_outputPath} ? $self->{_outputPath} : "."; 284 my $outputFile = "$prefix/czarplot_cluster.png"; 285 my ($minX, $maxX, $minY, $maxY, $timeDiff); 286 287 my $gnuplotFile = $self->{_czarDb}->createStorageTimeSeriesData($fromTime, $toTime, \$minX, \$maxX, \$minY, \$maxY, \$timeDiff); 288 289 $self->sortOutMaxMinY(\$minY, \$maxY); 290 291 my $timeFormat = undef; 292 my $divX = undef; 293 294 $self->getTimeSpacing($timeDiff, \$divX, \$timeFormat); 248 295 249 296 open (GP, "|/usr/bin/gnuplot -persist") or die "no gnuplot"; … … 254 301 "set term $self->{_outputFormat};" . 255 302 "set output \"$outputFile\";" . 256 "set title \"Processing status for '$label' since $fromTime\";" . 303 "set title \"Total available cluster space over time\";" . 304 "set key left top;" . 305 "set xdata time;" . 306 "set timefmt \"$self->{_dateFormat}\";" . 307 "set xrange [\"$minX\":\"$maxX\"];" . 308 "set yrange [\"$minY\":\"$maxY\"];" . 309 "set format x \"$timeFormat\";" . 310 "set xtics \"$minX\", $divX, \"$maxX\";" . 311 "set grid xtics;" . 312 "set xlabel \"Time\";" . 313 "set ylabel \"Available (TB)\";" . 314 "plot " . 315 # "'$gnuplotFile' using 1:2 title \"Total\" with lines lt 1," . 316 "'$gnuplotFile' using 1:2 title \"Available\" with lines lt 2\n"; 317 318 print GP "\n"; 319 close GP; 320 } 321 322 ########################################################################### 323 # 324 # Plots a histogram of processed stuff 325 # 326 ########################################################################### 327 sub plotHistogram { 328 my ($self, $inputFile, $outputFile, $label, $fromTime, $toTime) = @_; 329 330 open (GP, "|/usr/bin/gnuplot -persist") or die "no gnuplot"; 331 use FileHandle; 332 GP->autoflush(1); 333 334 print GP 335 "set term $self->{_outputFormat};" . 336 "set output \"$outputFile\";" . 337 "set title \"'$label', '$fromTime' to '$toTime'\";" . 257 338 "set grid;" . 258 339 "set boxwidth;" . … … 262 343 "set bmargin 5;" . 263 344 "set ylabel \"Exposures\";" . 264 "plot '$inputFile' using 2:xtic(1) title \"Processed\" lt 2, '' using 3 title \"Pending\" lt 3, '' using 4 title \"Faults\" lt 1\n"; 345 "plot '$inputFile' using 2:xtic(1) title \"Processed\" lt 2, '' using 3 title \"Pending\" lt 4, '' using 4 title \"Faults\" lt 7;" . 346 "\n"; 265 347 266 348 close GP; 267 349 } 268 350 351 ########################################################################### 352 # 353 # Plots disk usage across cluster as a stacked histogram 354 # 355 ########################################################################### 356 sub plotDiskUsageHistogram { 357 my ($self) = @_; 358 359 my $prefix = $self->{_outputPath} ? $self->{_outputPath} : "."; # TODO should be function for this 360 my $outputFile = "$prefix/czarplot_hosts_space.png"; 361 my $limit = 97.0; 362 my $inputFile = $self->{_czarDb}->createHostsData($limit); 363 364 my $totalUsed = $self->{_czarDb}->getTotalClusterStorageAsPercentage(); 365 366 my $totalPercent = sprintf("%.1f%%", $totalUsed); 367 368 open (GP, "|/usr/bin/gnuplot -persist") or die "no gnuplot"; 369 use FileHandle; 370 GP->autoflush(1); 371 372 print GP 373 "set term $self->{_outputFormat};" . 374 "set output \"$outputFile\";" . 375 "set title \"Nebulous disk use across IPP cluster ($totalPercent of total allocated)\";" . 376 "set style fill solid 1.00 border -1;" . 377 "set style histogram rowstacked;" . 378 "set style data histograms;" . 379 "set ylabel \"Space (TB)\";" . 380 "set xtic rotate by -90 scale 0;" . 381 "plot '$inputFile' " . 382 "using 2:xtic(1) t \"Used\" lt 7," . 383 "'' using 3 t \"Over $limit% used\" lt 1," . 384 "'' using 4 t \"Unavailable\" fs solid 0.50 lt -1 ," . 385 "'' using 5 t \"Free\" lt 2," . 386 "'' using 6 notitle fs solid 0.50 lt -1" . 387 ";" . 388 389 "\n"; 390 391 close GP; 392 } 269 393 1;
Note:
See TracChangeset
for help on using the changeset viewer.
