Changeset 28845 for trunk/tools/czartool/Czarplot.pm
- Timestamp:
- Aug 5, 2010, 9:10:53 AM (16 years ago)
- File:
-
- 1 edited
-
trunk/tools/czartool/Czarplot.pm (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/czartool/Czarplot.pm
r28804 r28845 154 154 my ($self, $minY, $maxY) = @_; 155 155 156 ${$maxY} = ${$maxY} + (${$maxY}/10); 157 ${$minY} = ${$minY} - (${$minY}/10); 156 my $border = (${$maxY} - ${$minY})/10; 157 158 ${$maxY} += $border; 159 ${$minY} -= $border ; 158 160 if (${$maxY} == 0) {${$maxY} = 1;} 159 161 if (${$minY} == 0) {${$minY} = -1;} 160 162 } 161 163 164 165 ########################################################################### 166 # 167 # Figures out suitable spacing for time tics on time-series pliots 168 # 169 ########################################################################### 170 sub getTimeSpacing { 171 my ($self, $timeDiff, $divX, $timeFormat) = @_; 172 173 # if less than a couple of hour's data plotted, show 30 mins tics 174 if ($timeDiff < 7200) { 175 ${$timeFormat} = "%H:%M"; 176 ${$divX} = 1800; 177 } 178 # if less than half a day's data plotted, show hourly tics 179 elsif ($timeDiff < 43200) { 180 ${$timeFormat} = "%H:%M"; 181 ${$divX} = 3600; 182 } 183 # if less than one day's data plotted, show 2 hourly tics 184 elsif ($timeDiff < 86400) { 185 ${$timeFormat} = "%H:%M"; 186 ${$divX} = 7200; 187 } 188 # if less than 1 week's data is data plotted, show daily tics 189 elsif ($timeDiff < 604800) { 190 191 ${$timeFormat} = "%m/%d"; 192 ${$divX} = 86400; 193 } 194 else { 195 196 ${$timeFormat} = "%m/%d"; 197 ${$divX} = 172800; 198 } 199 } 200 162 201 ########################################################################### 163 202 # … … 171 210 172 211 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 less than 1 week's data is data plotted, show daily tics 192 elsif ($timeDiff < 604800) { 193 194 $timeFormat = "%m/%d"; 195 $divX = 86400; 196 } 197 else { 198 199 $timeFormat = "%m/%d"; 200 $divX = 172800; 201 } 202 212 my $divX = undef; 213 214 $self->getTimeSpacing($timeDiff, \$divX, \$timeFormat); 203 215 204 216 my $numOfPlots = keys %$gnuplotFiles; … … 237 249 if ($numOfPlots == 1) { 238 250 239 print GP "'" . $gnuplotFiles->{$stage} . "' using 1:4 title \" processed\" with lines lt 2,";240 print GP "'" . $gnuplotFiles->{$stage} . "' using 1:2 title \" pending\" with lines lt 3,";241 print GP "'" . $gnuplotFiles->{$stage} . "' using 1:3 title \" faults\" with lines lt 1";251 print GP "'" . $gnuplotFiles->{$stage} . "' using 1:4 title \"Processed\" with lines lt 2,"; 252 print GP "'" . $gnuplotFiles->{$stage} . "' using 1:2 title \"Pending\" with lines lt 4,"; 253 print GP "'" . $gnuplotFiles->{$stage} . "' using 1:3 title \"Faults\" with lines lt 7"; 242 254 } 243 255 # when plotting multiple stages, show only processed … … 249 261 250 262 print GP "\n"; 263 close GP; 264 } 265 266 ########################################################################### 267 # 268 # Plots a time-series of cluster storage 269 # 270 ########################################################################### 271 sub plotStorageTimeSeries { 272 my ($self, $fromTime, $toTime) = @_; 273 274 my $outputFile = "/tmp/czarplot_cluster.png"; 275 my ($minX, $maxX, $minY, $maxY, $timeDiff); 276 277 my $gnuplotFile = $self->{_czarDb}->createStorageTimeSeriesData($fromTime, $toTime, \$minX, \$maxX, \$minY, \$maxY, \$timeDiff); 278 279 $self->sortOutMaxMinY(\$minY, \$maxY); 280 281 my $timeFormat = undef; 282 my $divX = undef; 283 284 $self->getTimeSpacing($timeDiff, \$divX, \$timeFormat); 285 286 open (GP, "|/usr/bin/gnuplot -persist") or die "no gnuplot"; 287 use FileHandle; 288 GP->autoflush(1); 289 290 print GP 291 "set term $self->{_outputFormat};" . 292 "set output \"$outputFile\";" . 293 "set title \"hmjhhjhj\";" . 294 "set key left top;" . 295 "set xdata time;" . 296 "set timefmt \"$self->{_dateFormat}\";" . 297 "set xrange [\"$minX\":\"$maxX\"];" . 298 "set yrange [\"$minY\":\"$maxY\"];" . 299 "set format x \"$timeFormat\";" . 300 "set xtics \"$minX\", $divX, \"$maxX\";" . 301 "set grid xtics;" . 302 "set xlabel \"Time\";" . 303 "set ylabel \"Available (TB)\";" . 304 "plot " . 305 # "'$gnuplotFile' using 1:2 title \"Total\" with lines lt 1," . 306 "'$gnuplotFile' using 1:2 title \"Available\" with lines lt 2\n"; 307 308 print GP "\n"; 251 309 close GP; 252 310 } … … 275 333 "set bmargin 5;" . 276 334 "set ylabel \"Exposures\";" . 277 "plot '$inputFile' using 2:xtic(1) title \"Processed\" lt 2, '' using 3 title \"Pending\" lt 3, '' using 4 title \"Faults\" lt 1\n"; 335 "plot '$inputFile' using 2:xtic(1) title \"Processed\" lt 2, '' using 3 title \"Pending\" lt 4, '' using 4 title \"Faults\" lt 7;" . 336 "\n"; 278 337 279 338 close GP; 280 339 } 281 340 341 ########################################################################### 342 # 343 # Plots disk usage across cluster as a stacked histogram 344 # 345 ########################################################################### 346 sub plotDiskUsageHistogram { 347 my ($self) = @_; 348 349 my $outputFile = "/tmp/czarplot_hosts.png"; 350 351 my $inputFile = $self->{_czarDb}->createHostsData(); 352 353 open (GP, "|/usr/bin/gnuplot -persist") or die "no gnuplot"; 354 use FileHandle; 355 GP->autoflush(1); 356 357 print GP 358 "set term $self->{_outputFormat};" . 359 "set output \"$outputFile\";" . 360 "set title \"Nebulous disk use across IPP cluster\";" . 361 "set style fill solid 1.00 border -1;" . 362 "set style histogram rowstacked;" . 363 "set style data histograms;" . 364 "set ylabel \"Space (TB)\";" . 365 "set xtic rotate by -90 scale 0;" . 366 "plot '$inputFile' using 2:xtic(1) t \"Used\" , '' using 3 t \"Available\";" . 367 368 "\n"; 369 370 close GP; 371 } 282 372 1;
Note:
See TracChangeset
for help on using the changeset viewer.
