Changeset 29834
- Timestamp:
- Nov 26, 2010, 10:33:29 AM (15 years ago)
- Location:
- branches/eam_branches/ipp-20101103/tools
- Files:
-
- 8 edited
- 9 copied
-
checkfits (copied) (copied from trunk/tools/checkfits )
-
czarmetrics.pl (copied) (copied from trunk/tools/czarmetrics.pl )
-
czarplot.pl (modified) (15 diffs)
-
czarpoll.pl (modified) (7 diffs)
-
czartool/CzarDb.pm (modified) (22 diffs)
-
czartool/DayMetrics.pm (copied) (copied from trunk/tools/czartool/DayMetrics.pm )
-
czartool/Gpc1Db.pm (modified) (2 diffs)
-
czartool/Metrics.pm (copied) (copied from trunk/tools/czartool/Metrics.pm )
-
czartool/MySQLDb.pm (modified) (7 diffs)
-
czartool/OCMetrics.pm (copied) (copied from trunk/tools/czartool/OCMetrics.pm )
-
czartool/Plotter.pm (modified) (20 diffs)
-
czartool/StageMetrics.pm (copied) (copied from trunk/tools/czartool/StageMetrics.pm )
-
heather (copied) (copied from trunk/tools/heather )
-
heather/reprocess.OSS.133.pl (copied) (copied from trunk/tools/heather/reprocess.OSS.133.pl )
-
heather/reprocess.OSS.pl (copied) (copied from trunk/tools/heather/reprocess.OSS.pl )
-
roboczar.pl (modified) (3 diffs)
-
runchipimfile.pl (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20101103/tools/czarplot.pl
r29580 r29834 8 8 9 9 use czartool::CzarDb; 10 use czartool::Gpc1Db; 10 11 use czartool::Plotter; 12 use czartool::StageMetrics; 11 13 12 14 my $czarDbName = "czardb"; … … 14 16 my $stage = undef; 15 17 my $save_temps = undef; 16 my $ interval= undef;18 my $timeinpast = undef; 17 19 my $begin = undef; 18 20 my $end = undef; … … 23 25 my $timeSeries = undef; 24 26 my $rate = undef; 27 my $magicMask = undef; 28 my $rateInterval = undef; 25 29 my $deriv = undef; 26 30 my $showCleanup = undef; … … 28 32 my $savingToFile = undef; 29 33 my $analysis = undef; 34 my $exposureId = undef; 30 35 my $log = undef; 31 36 … … 34 39 "label|l=s" => \$label, 35 40 "stage|s=s" => \$stage, 36 "interval|i=s" => \$interval, 41 "timeinpast|p=s" => \$timeinpast, 42 "rateinterval|i=s" => \$rateInterval, 43 "exposureid|x=s" => \$exposureId, 44 "mask|m" => \$magicMask, 37 45 "begin|b=s" => \$begin, 38 46 "end|e=s" => \$end, … … 57 65 print "* UNKNKOWN: option @ARGV\n"; 58 66 } 67 if ($analysis && !$stage) { 68 $quit = 1; 69 print "* REQUIRED: choose a stage for analsis -s <chip|cam|warp|etc> (default=none)\n";} 59 70 if (!$histogram) { 60 71 print "* OPTIONAL: plot histogram -h (default=off)\n";} 61 72 if (!$timeSeries) { 62 73 print "* OPTIONAL: plot timeseries -t (default=on)\n";} 74 if (!$magicMask) { 75 print "* OPTIONAL: plot magic mask for these times -m (default=off)\n";} 76 if (!$exposureId) { 77 print "* OPTIONAL: set exposure ID for magic mask -x (default=none)\n";} 63 78 if (!$rate) { 64 print "* OPTIONAL: plot timeseries of rate-r (default=off)\n";}79 print "* OPTIONAL: plot histogram of rate -r (default=off)\n";} 65 80 if (!$deriv) { 66 81 $deriv = 0; … … 74 89 if (!$log) { 75 90 $log = 0; 76 print "* OPTIONAL: use log plots -g (default=$log \n";}91 print "* OPTIONAL: use log plots -g (default=$log)\n";} 77 92 if (!$nebulous) { 78 93 print "* OPTIONAL: plot nebulous disk space -n (default=off)\n";} … … 82 97 if (!$stage) { 83 98 print "* OPTIONAL: choose a stage -s <chip|cam|warp|etc> (default=none)\n";} 84 if (!$interval) { 85 print "* OPTIONAL: choose time interval in past -i <'1 hour'|'1 day'|etc> (default=none\n";} 99 if (!$timeinpast) { 100 print "* OPTIONAL: choose time interval in past -p <'1 hour'|'1 day'|etc> (default=none\n";} 101 if (!$rateInterval) { 102 print "* OPTIONAL: time interval for rate plot -i <'1 hour'|'1 day'|etc> (default=depends on time frame)\n";} 86 103 if (!$begin) { 87 104 print "* OPTIONAL: choose a begin time -b <datetime> (default=6:35am this morning)\n";} … … 98 115 99 116 # default values 100 if (!$ nebulous && !$histogram && !$timeSeries) {$timeSeries = 1; $histogram = 0;}117 if (!$rate && !$magicMask && !$nebulous && !$histogram && !$analysis && !$timeSeries) {$timeSeries = 1;} 101 118 if (!$verbose) {$verbose = 0;} 102 119 if (!$save_temps) {$save_temps = 0;} … … 104 121 else {$savingToFile = 1;} 105 122 123 my $gpc1Db = new czartool::Gpc1Db("gpc1", "ippdb01", "ippuser", "ippuser"); 106 124 my $czarDb = new czartool::CzarDb($czarDbName, "ippdb01", "ipp", "ipp", $verbose, $save_temps); 107 125 $czarDb->setDateFormat("%Y%m%d-%H%i%s"); … … 109 127 110 128 my $plotter = new czartool::Plotter( 129 $gpc1Db, 111 130 $czarDb, 112 131 "%Y%m%d-%H%M%S", … … 121 140 $begin = "$day 06:35"; 122 141 $end = "$day 23:59"; 142 print "JKJKJK '$begin' '$end' \n"; 143 123 144 } 124 145 else { … … 127 148 if (!$begin) { 128 149 129 if ($ interval) {$begin = $czarDb->subtractInterval($end, $interval);}150 if ($timeinpast) {$begin = $czarDb->subtractInterval($end, $timeinpast);} 130 151 else {$begin = strftime('%Y-%m-%d 06:35',localtime);} 131 152 } … … 134 155 135 156 if ($rate) { 136 137 if (!$interval) {$interval = "1 HOUR";} 138 $plotter->createRateTimeSeries($label, $stage, $begin, $end, $interval, $log); 157 $plotter->createRateTimeSeries($label, $stage, $begin, $end, $rateInterval, $log); 139 158 exit; 140 159 } … … 143 162 if ($nebulous && $timeSeries) {$plotter->plotStorageTimeSeries($begin, $end);} 144 163 elsif ($nebulous) {$plotter->plotDiskUsageHistogram();} 164 if ($magicMask) { 165 166 if ($exposureId) {$plotter->plotMagicMaskFractionForThisExposure($exposureId);} 167 else {$plotter->plotMagicMaskFractionHistogram($begin, $end);} 145 168 169 } 146 170 147 171 if($analysis) { 148 172 149 my ($started, $finished, $stuck, $processed, $pending, $faults, $totalTime); 150 $czarDb->runAnalysis($label, $stage, $begin, $end, \$started, \$finished, \$stuck, \$processed, \$pending, \$faults, \$totalTime); 151 152 if (defined $started) {print "* Processing started at $started\n";} 153 if (defined $finished) {print "* Processing finished at $finished and took $totalTime\n";} 154 else {print "* Processing has not finished\n";} 155 if (defined $stuck) {print "* Processing has been stuck since $stuck\n";} 156 print "* $processed exposures have been processed, with $pending pending and $faults faults\n"; 157 158 print "*******************************************************************************\n"; 173 my $stageMetrics = new czartool::StageMetrics($stage, $label, $begin, $end); 174 if ($czarDb->runAnalysis($stageMetrics)) {$stageMetrics->printMe();} 159 175 } -
branches/eam_branches/ipp-20101103/tools/czarpoll.pl
r29583 r29834 13 13 use czartool::Plotter; 14 14 use czartool::Burntool; 15 use czartool::DayMetrics; 16 15 17 16 18 my $period = 60; … … 27 29 my $nebulous = new czartool::Nebulous($czarDb); 28 30 my $pantasks = new czartool::Pantasks(); 29 my $plotter = new czartool::Plotter($ czarDb, "%Y%m%d-%H%M%S", "png font \"/usr/share/fonts/corefonts/arial.ttf\" 8", "/tmp", $save_temps); # TODO hardcoded font path31 my $plotter = new czartool::Plotter($gpc1Db, $czarDb, "%Y%m%d-%H%M%S", "png font \"/usr/share/fonts/corefonts/arial.ttf\" 8", "/tmp", $save_temps); # TODO hardcoded font path 30 32 my $burntool = new czartool::Burntool(); 33 31 34 32 35 $czarDb->setDateFormat("%Y%m%d-%H%i%s"); … … 107 110 my $lastDay = strftime('%Y-%m-%d', localtime); 108 111 my $today = undef; 112 my $doneMetricsToday = 1; 109 113 110 114 while (1) { … … 118 122 $czarDb->optimize(); 119 123 $lastDay = $today; 124 $doneMetricsToday = 0; 120 125 } 121 126 … … 124 129 $end = $czarDb->getNowTimestamp(); 125 130 131 # if time now is after 06:35am, then create metrics for past 24 hours 132 if (!$doneMetricsToday && $czarDb->isBefore($begin, $end)) { 133 134 print "* Creating metrics for last 24 hours\n"; 135 # TODO hardcopded path needs to be in config 136 my $dayMetrics = new czartool::DayMetrics($gpc1Db, $czarDb, "/data/ipp004.0/ipp/ippMetrics/", 1, 0, $today); 137 $dayMetrics->writeHTML(); 138 139 $doneMetricsToday = 1; 140 } 141 142 # if time now is before 06:35am, include data from previous day 126 143 if ($czarDb->isBefore($end, $begin)) { 127 144 … … 197 214 chomp($label); 198 215 $plotter->createLogAndLinearTimeSeries($label, $stage, $begin, $end); 199 } 200 } 216 $plotter->createRateTimeSeries($label, $stage, $begin, $end, undef, 0); 217 } 218 } 219 220 my $allServerLabels = undef; 201 221 202 222 # create plots for each label for all stages … … 205 225 206 226 $plotter->createLogAndLinearTimeSeries($label, undef, $begin, $end); 227 $plotter->createRateTimeSeries($label, undef, $begin, $end, undef, 0); 207 228 $plotter->createHistogram($label, $begin, $end); 208 209 #routineChecks($label, "1 HOUR"); 210 } 211 $plotter->createLogAndLinearTimeSeries("all_".$server."_labels", undef, $begin, $end); 212 $plotter->createHistogram("all_".$server."_labels", $begin, $end); 229 } 230 231 $allServerLabels = "all_".$server."_labels"; 232 233 $plotter->createLogAndLinearTimeSeries($allServerLabels, undef, $begin, $end); 234 $plotter->createRateTimeSeries($allServerLabels, undef, $begin, $end, undef, 0); 235 $plotter->createHistogram($allServerLabels, $begin, $end); 213 236 foreach $stage (@stages) { 214 237 215 $plotter->createLogAndLinearTimeSeries("all_".$server."_labels", $stage, $begin, $end); # TODO must be a neater way... 238 $plotter->createLogAndLinearTimeSeries($allServerLabels, $stage, $begin, $end); # TODO must be a neater way... 239 $plotter->createRateTimeSeries($allServerLabels, $stage, $begin, $end, undef, 0); 216 240 } 217 241 } -
branches/eam_branches/ipp-20101103/tools/czartool/CzarDb.pm
r29582 r29834 6 6 use strict; 7 7 8 use File::Temp; 9 8 10 my @stages = ("burntool", "chip", "cam", "fake", "warp", "stack", "diff", "magic", "magicDS", "dist"); # TODO put elsewhere 9 11 10 12 use base 'czartool::MySQLDb'; 11 13 our @ISA = qw(czartool::MySQLDb); # inherits from MySQLDb 14 15 use czartool::StageMetrics; 12 16 13 17 ########################################################################### … … 49 53 return 1; 50 54 } 55 56 ########################################################################### 57 # 58 # Gets stdscience lables active in the provided time period 59 # TODO ugly hack to avoind getting update labels 60 # 61 ########################################################################### 62 sub getStdscienceLabelsInTimePeriod { 63 my ($self, $begin, $end, $labels) = @_; 64 65 my $query = $self->{_db}->prepare(<<SQL); 66 67 SELECT DISTINCT label 68 FROM chip 69 WHERE timestamp >= '$begin' 70 AND timestamp <= '$end' 71 AND label NOT LIKE '%_ud%' 72 AND label NOT LIKE 'update%' 73 AND label NOT LIKE 'all_%_labels' 74 SQL 75 76 if (!$query->execute) {return 0;} 77 78 ${$labels} = $query->fetchall_arrayref(); 79 80 return 1; 81 } 82 83 51 84 52 85 ########################################################################### … … 264 297 } 265 298 299 ########################################################################### 300 # 301 # Returns the start and end times during one day for the provided label and start/end stages 302 # 303 ########################################################################### 304 sub getDayTimings { 305 my ($self, $label, $startStage, $endStage, $begin, $started, $finished, $timeTaken) = @_; 306 307 my $end = $self->addInterval($begin, "1 DAY"); 308 309 my $startStageMetrics = new czartool::StageMetrics($startStage, $label, $begin, $end); 310 my $endStageMetrics = new czartool::StageMetrics($endStage, $label, $begin, $end); 311 312 if (!$self->runAnalysis($startStageMetrics)) {return 0;} 313 if (!$self->runAnalysis($endStageMetrics)) {return 0;} 314 315 ${$started} = $startStageMetrics->getStarted(); 316 ${$finished} = $endStageMetrics->getFinished100(); 317 318 if (!${$started} || !${$finished}) {${$timeTaken} = undef;} 319 else {${$timeTaken} = $self->diffTimes(${$finished}, ${$started});} 320 321 return 1; 322 } 266 323 267 324 ########################################################################### … … 271 328 ########################################################################### 272 329 sub runAnalysis { 273 my ($self, 274 $label, 275 $stage, 276 $fromTime, 277 $toTime, 278 $_started, 279 $_finished, 280 $_stuck, 281 $_processed, 282 $_pending, 283 $_faults, 284 $_totalTime) = @_; 330 my ($self, $stageMetrics) = @_; 331 332 if (!$stageMetrics) {return 0;} 333 334 my $stage = $stageMetrics->getStage(); 335 my $label = $stageMetrics->getLabel(); 336 my $fromTime = $stageMetrics->getStartTime(); 337 my $toTime = $stageMetrics->getEndTime(); 338 339 $toTime = $self->addInterval($toTime, "20 MINUTE"); # TODO dodgy 285 340 286 341 my $query = $self->{_db}->prepare(<<SQL); … … 293 348 SQL 294 349 295 $query->execute;296 297 350 my $lastProcessed = -1; 298 351 my $lastPending = -1; … … 300 353 my $lastTimestamp = undef; 301 354 my ($linearProcessed, $linearPending, $linearFaults); 355 356 # first, count toatl processed in time window so that we can find time of 50%, 75%, 90% etc 357 $query->execute; 358 my $totalProcessed = 0; 359 my $firstRow = 1; 360 while (my @row = $query->fetchrow_array()) { 361 my ($thisTimestamp, $thisPending, $thisFaults, $thisProcessed) = @row; 362 363 # get linear values 364 if($lastProcessed != -1 && $thisProcessed > $lastProcessed) { 365 366 $totalProcessed = $totalProcessed + ($thisProcessed - $lastProcessed); 367 } 368 369 $lastProcessed = $thisProcessed; 370 if ($firstRow) {$stageMetrics->setInitialPending($thisPending); $firstRow = 0;} 371 } 372 373 # nothing to do here 374 if (!$totalProcessed) {return 1;} 375 376 my $percent25 = $totalProcessed * 0.25; 377 my $percent50 = $totalProcessed * 0.5; 378 my $percent75 = $totalProcessed * 0.75; 379 my $percent90 = $totalProcessed * 0.9; 380 my $percent95 = $totalProcessed * 0.95; 381 302 382 my ($derivProcessed, $derivPending, $derivFaults); 303 my $started = undef;304 my $finished = undef;305 306 383 my $notProcessing = undef; 307 384 my $howLongNotProcessing = undef; 308 385 my $notProcessingLongerThanInterval = 0; 309 310 386 my $stuck = undef; 311 387 my $howLongStuck = undef; 312 388 my $stuckLongerThanInterval = 0; 313 314 389 my $stuffToDo = undef; 315 my $interval = "00:20:00"; 316 390 my $interval = "00:20:00"; # TODO dodgy - see above 391 my $started = undef; 392 my $finished = undef; 393 394 my ($have25, $have50, $have75, $have90, $have95, $have100) = 0; 395 396 # now, loop again, this time recording more data 397 $query->execute; 317 398 $linearProcessed = 0; 399 $lastProcessed = -1; 318 400 while (my @row = $query->fetchrow_array()) { 319 401 my ($thisTimestamp, $thisPending, $thisFaults, $thisProcessed) = @row; … … 326 408 $linearPending = $thisPending; 327 409 $linearFaults = $thisFaults; 410 411 if (!$have25 && $linearProcessed >= $percent25) {$stageMetrics->setFinished25($thisTimestamp); $have25 = 1;} 412 if (!$have50 && $linearProcessed >= $percent50) {$stageMetrics->setFinished50($thisTimestamp); $have50 = 1;} 413 if (!$have75 && $linearProcessed >= $percent75) {$stageMetrics->setFinished75($thisTimestamp); $have75 = 1;} 414 if (!$have90 && $linearProcessed >= $percent90) {$stageMetrics->setFinished90($thisTimestamp); $have90 = 1;} 415 if (!$have95 && $linearProcessed >= $percent95) {$stageMetrics->setFinished95($thisTimestamp); $have95 = 1;} 328 416 329 417 # get first derivative values … … 363 451 if (defined $notProcessing) { 364 452 365 if ($stuckLongerThanInterval) {366 367 # print "* $stage procesing was stuck for $howLongStuck, from $stuck until $lastTimestamp\n";368 }369 if ($notProcessingLongerThanInterval) {370 371 # print " * $stage not procesing for $howLongNotProcessing, from $notProcessing until $thisTimestamp\n";372 }373 453 $notProcessing = undef; 374 454 $stuck = undef; 375 455 } 376 456 if (!defined $started) { 457 377 458 $started = $lastTimestamp; 378 459 $finished = undef; 379 # print "* $stage processing started at $started\n";380 460 } 381 461 } … … 418 498 } 419 499 420 ${$_processed} = $linearProcessed; 421 ${$_pending} = $stuffToDo; 422 ${$_faults} = $lastFaults; 500 $stageMetrics->setProcessed($linearProcessed); 501 $stageMetrics->setFinalPending($stuffToDo); 502 $stageMetrics->setFaults($lastFaults); 503 504 505 if (!defined $finished) { 506 507 $stageMetrics->setFinished25(undef); 508 $stageMetrics->setFinished50(undef); 509 $stageMetrics->setFinished75(undef); 510 $stageMetrics->setFinished90(undef); 511 $stageMetrics->setFinished95(undef); 512 $stageMetrics->setFinished100(undef); 513 $stageMetrics->setTotalTime($self->diffTimes($lastTimestamp, $started)); 514 } 423 515 424 516 if (defined $finished) { 425 ${$_finished} = $finished; 426 ${$_totalTime} = $self->diffTimes($finished, $started); 427 } 428 429 elsif(defined $started) { 430 431 ${$_finished} = undef; 432 } 433 517 518 $stageMetrics->setFinished100($finished); 519 $stageMetrics->setTotalTime($self->diffTimes($finished, $started)); 520 } 521 522 434 523 if (!defined $started){ 435 524 436 $ {$_started} = undef;525 $stageMetrics->setStarted(undef); 437 526 } 438 527 else { 439 528 440 ${$_started} = $started; 529 my $rate = ($stageMetrics->getProcessed()/$self->getTimeInSecs($stageMetrics->getTotalTime) ) * 3600.0; 530 $stageMetrics->setRate($rate); 531 $stageMetrics->setStarted($started); 441 532 } 442 533 if ($stuck && $stuckLongerThanInterval && !defined $finished) { 443 534 444 $ {$_stuck} = $stuck;535 $stageMetrics->setStuck($stuck); 445 536 } 446 537 else { 447 538 448 $ {$_stuck} = undef;539 $stageMetrics->setStuck(undef); 449 540 } 450 541 … … 484 575 $query->execute; 485 576 486 ${$dataFile} = "/tmp/czarplot_gnuplot_".$label."_".$stage."_t.dat"; 577 my $tmpFile = File::Temp->new( TEMPLATE => "czarplot_gnuplot_".$label."_".$stage."_t.XXXXX", DIR => '/tmp', SUFFIX => 'dat'); 578 $tmpFile->unlink_on_destroy( 0 ); 579 ${$dataFile} = $tmpFile->filename; 487 580 open (GNUDAT, ">${$dataFile}") or print "* Problem opening gnuplot data file for plot for '$label' '$stage'\n"; 488 581 … … 497 590 498 591 $linearProcessed = 0; 592 my $someData = 0; 499 593 while (my @row = $query->fetchrow_array()) { 500 594 my ($thisTimestamp, $thisPending, $thisFaults, $thisProcessed) = @row; … … 517 611 my $timeDiff = $self->diffTimesInSecs($thisTimestamp, $lastTimestamp); 518 612 519 if ($thisProcessed >= $lastProcessed ){613 if ($thisProcessed >= $lastProcessed && $timeDiff){ 520 614 $derivProcessed = abs($thisProcessed - $lastProcessed)/$timeDiff; 521 615 } … … 547 641 else {print GNUDAT "$timestamp $linearPending $linearFaults $linearProcessed\n";} 548 642 643 if ($linearPending > 0 || $linearFaults > 0 || $linearProcessed > 0) {$someData = 1;} 644 549 645 $lastProcessed = $thisProcessed; 550 646 $lastPending = $thisPending; … … 555 651 close(GNUDAT) or print "* Problem closing gnuplot data file for plot for '$label' '$stage'\n"; 556 652 557 return 1;653 #return $someData; 558 654 } 559 655 … … 637 733 ########################################################################### 638 734 sub createHostsData { 639 my ($self, $limit) = @_; 640 641 my $dataFile = "/tmp/czarplot_hosts_space.dat"; 642 open (GNUDAT, ">$dataFile"); 735 my ($self, $limit, $tmpFile) = @_; 736 737 open (GNUDAT, ">".$tmpFile->filename); 643 738 644 739 my $query = $self->{_db}->prepare(<<SQL); … … 686 781 print GNUDAT "\n"; 687 782 } 783 688 784 close(GNUDAT); 689 690 return $dataFile;691 785 } 692 786 … … 714 808 ########################################################################### 715 809 sub createStorageTimeSeriesData { 716 my ($self, $fromTime, $toTime, $minX, $maxX, $minY, $maxY, $timeDiff) = @_; 717 718 my $dataFile = "/tmp/czarplot_gnuplot_storage_timeseries.dat"; 719 open (GNUDAT, ">$dataFile"); 810 my ($self, $tmpFile, $fromTime, $toTime, $minX, $maxX, $minY, $maxY, $timeDiff) = @_; 811 812 open (GNUDAT, ">".$tmpFile->filename); 720 813 721 814 my $query = $self->{_db}->prepare(<<SQL); … … 753 846 754 847 close(GNUDAT); 755 756 return $dataFile;757 848 } 758 849 … … 763 854 ########################################################################### 764 855 sub createProcessingRateData { 765 my ($self, $stage, $label, $ startDay, $endDay, $interval, $dataFile, $isLog) = @_;766 767 my $startTime = $ startDay;856 my ($self, $stage, $label, $begin, $end, $interval, $dataFile, $isLog) = @_; 857 858 my $startTime = $begin; 768 859 my $endTime; 769 860 my $quit = 0; … … 772 863 my $faults; 773 864 my $timestamp; 774 ${$dataFile} = "/tmp/czarplot_gnuplot_".$label."_".$stage."_r.dat"; 865 866 my $tmpFile = File::Temp->new( TEMPLATE => "czarplot_gnuplot_".$label."_".$stage."_r.XXXXX", DIR => '/tmp', SUFFIX => 'dat'); 867 $tmpFile->unlink_on_destroy( 0 ); 868 ${$dataFile} = $tmpFile->filename; 869 775 870 open (GNUDAT, ">${$dataFile}") or print "* Problem opening gnuplot data file for plot for '$label' '$stage'\n"; 776 871 my $cleanupCarry = 0; 872 my $someData = 0; 777 873 while(1) { 778 874 779 if (!$self->isBefore($startTime, $endDay)) {last;} 875 876 #print "NNN $startTime, $end\n"; 877 if (!$self->isBefore($startTime, $end)) {last;} 780 878 $endTime = $self->addInterval($startTime, $interval); 781 879 $self->countProcessedPendingAndFaults($label, $stage, $startTime, $endTime, \$processed, \$pending, \$faults); … … 783 881 print GNUDAT "$timestamp $processed 0 0\n"; 784 882 883 if ($processed > 0 ) {$someData = 1;} 884 785 885 $startTime = $endTime; 786 886 } 787 887 788 close(GNUDAT) or print "* Problem closing gnuplot data file for rate plot for '$label' '$stage'\n" 888 close(GNUDAT) or print "* Problem closing gnuplot data file for rate plot for '$label' '$stage'\n"; 889 890 #return $someData; 789 891 } 790 892 … … 1512 1614 $self->setRevision(12); 1513 1615 } 1514 1515 1616 1; 1516 1617 -
branches/eam_branches/ipp-20101103/tools/czartool/Gpc1Db.pm
r28924 r29834 60 60 ########################################################################### 61 61 # 62 # Returns the number of science exposures taken 'last night' for a given day 63 # 64 # Notes: 65 # 66 # - 03:00 HST = 17:00 last night UTC 67 # - 17:00 HST = 07:00 this morning UTC 68 # - 'OBJECT' = science exposures 69 # 70 ########################################################################### 71 sub countScienceExposuresFromLastNight { 72 my ($self, $day) = @_; 73 74 my $begin = "$day 03"; 75 my $end = "$day 17"; 76 77 my $query = $self->{_db}->prepare(<<SQL); 78 SELECT COUNT(*) 79 FROM summitExp 80 WHERE dateobs > '$begin' 81 AND dateobs < '$end' AND 82 exp_type = 'OBJECT'; 83 SQL 84 85 $query->execute; 86 return scalar $query->fetchrow_array(); 87 } 88 89 ########################################################################### 90 # 91 # Returns the number of exposures between two dates that have been registered with chip 92 # 93 # Notes: 94 # 95 # necessary to convert times as rawExp.dateobs is in UTC 96 # 97 ########################################################################### 98 sub getProcessedExposures { 99 my ($self, $beginDate, $endDate, $expIds) = @_; 100 101 $beginDate = "$beginDate 03"; 102 $endDate = "$endDate 17"; 103 104 my $query = $self->{_db}->prepare(<<SQL); 105 SELECT rawExp.exp_id 106 FROM chipRun, rawExp 107 WHERE chipRun.exp_id = rawExp.exp_id 108 AND rawExp.dateobs >= '$beginDate' 109 AND rawExp.dateobs <= '$endDate'; 110 SQL 111 112 $query->execute; 113 ${$expIds} = $query->fetchall_arrayref(); 114 115 return 1; 116 } 117 118 ########################################################################### 119 # 62 120 # Returns count of faults for this stage and label 63 121 # … … 158 216 } 159 217 160 161 218 $query->execute; 162 219 return scalar $query->fetchrow_array(); 163 220 } 221 222 ########################################################################### 223 # 224 # Returns magic mask fraction across all chips for a particular exposure 225 # 226 ########################################################################### 227 sub getMagicMaskFraction { 228 my ($self, $exp_id, $fracs) = @_; 229 230 my $query = $self->{_db}->prepare(<<SQL); 231 SELECT component, streak_frac 232 FROM magicDSFile 233 JOIN magicDSRun USING(magic_ds_id) 234 JOIN camRun USING(cam_id) 235 JOIN chipRun USING(chip_id) 236 WHERE exp_id = $exp_id 237 AND camRun.label LIKE "%nightlyscience" 238 AND component LIKE "XY%"; 239 SQL 240 $query->execute; 241 ${$fracs} = $query->fetchall_arrayref(); 242 243 return 1; 244 } 245 246 ########################################################################### 247 # 248 # Returns average magic mask fraction across all chips for a particular exposure 249 # 250 ########################################################################### 251 sub getAverageMagicMaskFraction { 252 my ($self, $exp_id) = @_; 253 254 my $query = $self->{_db}->prepare(<<SQL); 255 SELECT AVG(streak_frac) 256 FROM magicDSFile 257 JOIN magicDSRun USING(magic_ds_id) 258 JOIN camRun USING(cam_id) 259 JOIN chipRun USING(chip_id) 260 WHERE exp_id = $exp_id 261 AND camRun.label LIKE "%nightlyscience" 262 AND component LIKE "XY%"; 263 SQL 264 $query->execute; 265 return scalar $query->fetchrow_array(); 266 } 164 267 1; -
branches/eam_branches/ipp-20101103/tools/czartool/MySQLDb.pm
r29436 r29834 64 64 return $self->{_dbHost}; 65 65 } 66 ########################################################################### 67 # 68 # Adds the provided interval to the provided time 66 67 ########################################################################### 68 # 69 # Returns a date formatted wit hthe current formatting 69 70 # 70 71 ########################################################################### … … 82 83 ########################################################################### 83 84 # 85 # Returns a full MySQL formatted date 86 # 87 ########################################################################### 88 sub getFullDate { 89 my ($self, $time) = @_; 90 91 my $query = $self->{_db}->prepare(<<SQL); 92 SELECT DATE_FORMAT('$time','%Y-%m-%d %H:%i:%s'); 93 SQL 94 $query->execute; 95 96 return scalar $query->fetchrow_array(); 97 } 98 99 ########################################################################### 100 # 84 101 # Adds the provided interval to the provided time 85 102 # … … 98 115 ########################################################################### 99 116 # 117 # Subtracts the provided interval from the provided time 118 # 119 ########################################################################### 120 sub subtractInterval { 121 my ($self, $time, $interval) = @_; 122 123 my $query = $self->{_db}->prepare(<<SQL); 124 SELECT '$time' - INTERVAL $interval; 125 SQL 126 $query->execute; 127 128 return scalar $query->fetchrow_array(); 129 } 130 131 ########################################################################### 132 # 133 # Formats a date/time string in a way suitable for TIMEDIFF calls 134 # 135 ########################################################################### 136 sub formatTimeForDiff { 137 my ($self, $time) = @_; 138 139 if (${$time} =~ m/^[0-9]{4}-[0-9]{2}-[0-9]{2}.*/) {${$time} = $self->getFullDate(${$time});} 140 elsif(${$time} !~ m/^[0-9]+:[0-9]{2}:[0-9]{2}$/) {return 0;} 141 142 return 1; 143 } 144 145 ########################################################################### 146 # 100 147 # Finds the difference of two times 148 # 149 # Should be able to handle most date/time formats 101 150 # 102 151 ########################################################################### … … 104 153 my ($self, $time1, $time2) = @_; 105 154 106 my $query = $self->{_db}->prepare(<<SQL); 155 if (!$time1 || !$time2) {return 0;} 156 157 if (!$self->formatTimeForDiff(\$time1) || !$self->formatTimeForDiff(\$time2)) {return 0;} 158 159 my $query = $self->{_db}->prepare(<<SQL); 107 160 SELECT TIMEDIFF('$time1','$time2'); 161 SQL 162 163 $query->execute; 164 return scalar $query->fetchrow_array(); 165 } 166 167 ########################################################################### 168 # 169 # Returns the provided time in seconds 170 # 171 ########################################################################### 172 sub getTimeInSecs { 173 my ($self, $time) = @_; 174 175 if (!$time) {return 0;} 176 177 my $query = $self->{_db}->prepare(<<SQL); 178 SELECT TIME_TO_SEC('$time'); 108 179 SQL 109 180 … … 120 191 my ($self, $time1, $time2) = @_; 121 192 122 my $query = $self->{_db}->prepare(<<SQL); 193 if (!$time1 || !$time2) {return 0;} 194 if (!$self->formatTimeForDiff(\$time1) || !$self->formatTimeForDiff(\$time2)) {return 0;} 195 196 my $query = $self->{_db}->prepare(<<SQL); 123 197 SELECT TIME_TO_SEC(TIMEDIFF('$time1','$time2')); 124 198 SQL … … 146 220 ########################################################################### 147 221 # 148 # Subtracts the provided interval from the provided time149 #150 ###########################################################################151 sub subtractInterval {152 my ($self, $time, $interval) = @_;153 154 my $query = $self->{_db}->prepare(<<SQL);155 SELECT '$time' - INTERVAL $interval;156 SQL157 $query->execute;158 159 return scalar $query->fetchrow_array();160 }161 162 ###########################################################################163 #164 222 # Returns whether time1 is before time2 165 223 # … … 168 226 my ($self, $time1, $time2) = @_; 169 227 170 my $query = $self->{_db}->prepare(<<SQL); 171 SELECT '$time1' < '$time2'; 172 SQL 173 $query->execute; 174 175 return scalar $query->fetchrow_array(); 228 if (!$time1 || !$time2) {return 0;} 229 if (!$self->formatTimeForDiff(\$time1) || !$self->formatTimeForDiff(\$time2)) {return 0;} 230 231 my $query = $self->{_db}->prepare(<<SQL); 232 SELECT TIME_TO_SEC(TIMEDIFF('$time1', '$time2')); 233 SQL 234 $query->execute; 235 236 return (scalar $query->fetchrow_array() >= 0) ? 0 : 1; 176 237 } 177 238 -
branches/eam_branches/ipp-20101103/tools/czartool/Plotter.pm
r29618 r29834 4 4 use warnings; 5 5 use strict; 6 7 use File::Temp; 6 8 7 9 my @allStages = ("burntool", "chip", "cam", "fake", "warp", "stack", "diff", "magic", "magicDS", "dist"); … … 16 18 my $class = shift; 17 19 my $self = { 20 _gpc1Db => shift, 18 21 _czarDb => shift, 19 22 _dateFormat => shift, … … 53 56 } 54 57 58 59 ########################################################################### 60 # 61 # Figures out a suitable interval for rate plots 62 # Could use a function here, but instead we want to choose meaningful intervals 63 # 64 ########################################################################### 65 sub getSuitableInterval { 66 my ($self, $begin, $end, $interval) = @_; 67 68 my $timeDiff = $self->{_czarDb}->diffTimes($end, $begin); 69 70 71 if ($self->{_czarDb}->isBefore($timeDiff, "00:00:01")) {return 0;} 72 elsif ($self->{_czarDb}->isBefore($timeDiff, "03:00:00")) {${$interval} = "15 MINUTE";} 73 elsif ($self->{_czarDb}->isBefore($timeDiff, "10:00:00")) {${$interval} = "30 MINUTE";} 74 elsif ($self->{_czarDb}->isBefore($timeDiff, "24:00:00")) {${$interval} = "1 HOUR";} # under 1 day 75 elsif ($self->{_czarDb}->isBefore($timeDiff, "36:00:00")) {${$interval} = "2 HOUR";} # under 1.5 days 76 elsif ($self->{_czarDb}->isBefore($timeDiff, "48:00:00")) {${$interval} = "3 HOUR";} # under 2 days 77 elsif ($self->{_czarDb}->isBefore($timeDiff, "72:00:00")) {${$interval} = "4 HOUR";} # under 3 days 78 elsif ($self->{_czarDb}->isBefore($timeDiff, "96:00:00")) {${$interval} = "5 HOUR";} # under 4 days 79 elsif ($self->{_czarDb}->isBefore($timeDiff, "144:00:00")) {${$interval} = "6 HOUR";} # under 6 days 80 elsif ($self->{_czarDb}->isBefore($timeDiff, "168:00:00")) {${$interval} = "12 HOUR";} # under week 81 elsif ($self->{_czarDb}->isBefore($timeDiff, "672:00:00")) {${$interval} = "1 DAY";} # under 2 week 82 elsif ($self->{_czarDb}->isBefore($timeDiff, "2016:00:00")) {${$interval} = "1 WEEK";} # under 3 month 83 else {${$interval} = "1 MONTH";} 84 85 return 1; 86 } 87 55 88 ########################################################################### 56 89 # … … 61 94 my ($self, $label, $selectedStage, $beginTime, $endTime, $interval, $isLog) = @_; 62 95 63 my $minX = 999999999; 64 my $maxX = -9999999999; 65 my $timeDiff = -1; 66 96 # stages 67 97 my $stages = undef; 68 69 if (!$selectedStage) {$stages = \@allStages;}70 else {$stages = ["$selectedStage"]};71 72 $self->{_czarDb}->getTimeMinMaxDiff($label, $selectedStage, $beginTime, $endTime, \$minX, \$maxX, \$timeDiff);73 74 my $divX;75 my $timeFormat;76 $self->getTimeSpacing($timeDiff, \$divX, \$timeFormat); 77 98 if (!$selectedStage) { 99 $stages = \@allStages; 100 $selectedStage = 'all_stages'; 101 } 102 else {$stages = ["$selectedStage"]}; 103 104 # interval 105 if (!$interval && !$self->getSuitableInterval($beginTime, $endTime, \$interval)) {return 0;} 106 107 # set up files 78 108 my %gnuplotFiles; 79 109 my $stage = undef; … … 89 119 "set term $self->{_outputFormat};" . 90 120 "set title \"'$label', '$selectedStage' during '$beginTime' to '$endTime'\";" . 91 #"set xdata time;" .92 "set timefmt \"$self->{_dateFormat}\";" .93 "set format x \"$timeFormat\";" .94 "set xtics \"$minX\", $divX, \"$maxX\";" .95 # "set xrange [\"$minX\":\"$maxX\"];" .96 121 "set boxwidth;" . 122 "set xtic rotate by -90 scale 0;" . 97 123 "set style data histogram;" . 98 124 "set style histogram rowstacked;" . … … 124 150 print GP ";\n"; 125 151 close GP; 126 } 152 153 # now delete temp dat files 154 foreach my $stage (keys %gnuplotFiles) {unlink($gnuplotFiles{$stage});} 155 156 return 1; 157 } 158 127 159 ########################################################################### 128 160 # … … 168 200 if ($numOfPlots == 0 ) { 169 201 170 print "Warning: No plots could be generated for stage '$selectedStage' and label '$label' during time period '$beginTime', '$endTime'\n";202 # print "Warning: No plots could be generated for stage '$selectedStage' and label '$label' during time period '$beginTime', '$endTime'\n"; 171 203 return; 172 204 } … … 202 234 my $outputFile = createImageFileName($self, $label, undef, "h", 0); 203 235 204 my $ inputFile = "/tmp/czarplot_gnuplot_".$label."_h.dat"; # TODO use stage not table205 open (GNUDAT, ">$inputFile");236 my $tmpFile = File::Temp->new( TEMPLATE => "czarplot_gnuplot_".$label."_h.XXXXX", DIR => '/tmp', SUFFIX => 'dat'); 237 open (GNUDAT, ">".$tmpFile->filename); 206 238 207 239 my ($processed, $pending, $faults); 208 240 my $stage = undef; 209 241 my $pendingMinusFaults = undef; 210 my $maxY = 0;211 my $sum;212 242 foreach $stage (@allStages) { 213 243 214 $self->{_czarDb}->countProcessedPendingAndFaults(244 if (!$self->{_czarDb}->countProcessedPendingAndFaults( 215 245 $label, 216 246 $stage, … … 219 249 \$processed, 220 250 \$pending, 221 \$faults) ;251 \$faults)) {next;} 222 252 223 253 $pendingMinusFaults = $pending - $faults; 224 print GNUDAT "$stage $faults $processed, $pendingMinusFaults\n"; 225 my $sum = $faults + $processed + $pendingMinusFaults; 226 if ($sum > $maxY) {$maxY = $sum;} 254 print GNUDAT "$stage $faults $processed $pendingMinusFaults\n"; 227 255 } 228 256 … … 232 260 use FileHandle; 233 261 GP->autoflush(1); 234 235 if ($maxY == 0) {$maxY = 1;}236 else {$maxY = $maxY*1.1;}237 238 262 239 263 if ($self->{_outputFormat} ne "X11") {print GP "set output \"$outputFile\";";} … … 243 267 "set grid;" . 244 268 "set boxwidth;" . 245 "set yrange [\"0\":\"$maxY\"];" .246 269 "set style data histogram;" . 247 270 "set style histogram rowstacked;" . … … 249 272 "set ylabel \"Exposures\";" . 250 273 "set boxwidth 0.75;" . 251 "plot ' $inputFile' using 2:xtic(1) title \"Faults\" lt 1, '' using 3 title \"Processed\" lt 2, '' using 4 title \"Pending\" lt 7;" .274 "plot '".$tmpFile->filename."' using 2:xtic(1) title \"Faults\" lt 1, '' using 3 title \"Processed\" lt 2, '' using 4 title \"Pending\" lt 7;" . 252 275 "\n"; 253 276 254 277 close GP; 255 unlink($inputFile);256 278 } 257 279 … … 295 317 my ($self, $timeDiff, $divX, $timeFormat) = @_; 296 318 319 # if less than a few mins of data, show 1 minute tics 320 if ($timeDiff < 300) { 321 ${$timeFormat} = "%H:%M"; 322 ${$divX} = 60; 323 } 324 # if less than a few mins of data, show 5 minute tics 325 elsif ($timeDiff < 1800) { 326 ${$timeFormat} = "%H:%M"; 327 ${$divX} = 300; 328 } 329 # if less than an hour of data, show 15 minute tics 330 elsif ($timeDiff < 3600) { 331 ${$timeFormat} = "%H:%M"; 332 ${$divX} = 900; 333 } 297 334 # if less than a couple of hour's data plotted, show 30 mins tics 298 if ($timeDiff < 7200) {335 elsif ($timeDiff < 7200) { 299 336 ${$timeFormat} = "%H:%M"; 300 337 ${$divX} = 1800; … … 376 413 377 414 my $firstIn = 1; 378 foreach my $stage (keys %$gnuplotFiles) { 415 # loop through stages array so that they are ordered properly (not maintained in hash) 416 foreach my $stage (@allStages) { 417 418 if(!$gnuplotFiles->{$stage}) {next;} 379 419 if (!$firstIn) {print GP ",";} 380 420 … … 398 438 399 439 # now delete temp dat files 400 foreach my $stage (keys %$gnuplotFiles) { 401 402 unlink($gnuplotFiles->{$stage}); 403 } 440 foreach my $stage (keys %$gnuplotFiles) {unlink($gnuplotFiles->{$stage});} 404 441 } 405 442 … … 416 453 my ($minX, $maxX, $minY, $maxY, $timeDiff); 417 454 418 my $gnuplotFile = $self->{_czarDb}->createStorageTimeSeriesData($fromTime, $toTime, \$minX, \$maxX, \$minY, \$maxY, \$timeDiff); 455 my $tmpFile = File::Temp->new( TEMPLATE => "czarplot_gnuplot_storage_timeseries.XXXXX", DIR => '/tmp', SUFFIX => 'dat'); 456 $self->{_czarDb}->createStorageTimeSeriesData($tmpFile, $fromTime, $toTime, \$minX, \$maxX, \$minY, \$maxY, \$timeDiff); 419 457 420 458 my $timeFormat = undef; … … 440 478 "set ylabel \"Available (TB)\";" . 441 479 "plot " . 442 "' $gnuplotFile' using 1:2 title \"Available\" with lines lt 2 lw 2\n";480 "'".$tmpFile->filename."' using 1:2 title \"Available\" with lines lt 2 lw 2\n"; 443 481 444 482 print GP "\n"; 445 483 close GP; 446 unlink($gnuplotFile);447 484 } 448 485 … … 458 495 my $outputFile = "$prefix/czarplot_hosts_space.png"; 459 496 my $limit = 97.0; 460 my $inputFile = $self->{_czarDb}->createHostsData($limit); 497 my $tmpFile = File::Temp->new( TEMPLATE => "czarplot_hosts_space.XXXXX", DIR => '/tmp', SUFFIX => 'dat'); 498 $self->{_czarDb}->createHostsData($limit, $tmpFile); 461 499 462 500 my $totalUsed = $self->{_czarDb}->getTotalClusterStorageAsPercentage(); … … 477 515 "set ylabel \"Space (TB)\";" . 478 516 "set xtic rotate by -90 scale 0;" . 479 "plot ' $inputFile' " .517 "plot '".$tmpFile->filename."' " . 480 518 "using 2:xtic(1) t \"Used\" lt 7," . 481 519 "'' using 3 t \"Over $limit% used\" lt 1," . … … 489 527 close GP; 490 528 } 529 530 ########################################################################### 531 # 532 # Generates 3D plot of magic mask fraction for provided exposure ID 533 # 534 ########################################################################### 535 sub plotMagicMaskFractionForThisExposure { 536 my ($self, $exp_id) = @_; 537 538 # set up file stuff 539 my $prefix = $self->{_outputPath} ? $self->{_outputPath} : "."; # TODO should be function for this 540 my $outputFile = "$prefix/czarplot_single_exp_magic_mask_fraction.png"; 541 my $tmpFile = File::Temp->new( TEMPLATE => "czarplot_single_exp_magic_mask_fraction.XXXXX", DIR => '/tmp', SUFFIX => '.dat'); 542 543 my $fracs; 544 if (!$self->{_gpc1Db}->getMagicMaskFraction($exp_id, \$fracs)) {return 0;} 545 546 open (GNUDAT, ">".$tmpFile->filename); 547 548 print GNUDAT "0 0 0.0\n"; 549 foreach my $row ( @{$fracs} ) { 550 551 if (@{$row}[0] =~ m/XY([0-9])([0-9])/) { 552 print GNUDAT "$1 $2 @{$row}[1]\n"; 553 if($1 == 0 && $2 == 6) {print GNUDAT "0 7 0.0\n";} 554 if($1 == 6 && $2 == 7) {print GNUDAT "7 0 0.0\n";} 555 } 556 } 557 print GNUDAT "7 7 0.0\n"; 558 559 560 close(GNUDAT); 561 562 563 open (GP, "|/usr/bin/gnuplot -persist") or die "no gnuplot"; 564 use FileHandle; 565 GP->autoflush(1); 566 567 my $datFile = $tmpFile->filename; 568 569 if ($self->{_outputFormat} ne "X11") {print GP "set output \"$outputFile\";";} 570 print GP <<PLOT; 571 572 set term $self->{_outputFormat} 573 set title "Magic mask fraction for exposure $exp_id" 574 set grid 575 set size square 576 set xrange [-0.5:7.5] reverse 577 set yrange [-0.5:7.5] 578 unset key 579 set palette rgb 22,13,10 580 set ylabel "Y" 581 set xlabel "X" 582 set cbrange [0:1] 583 set datafile missing "NaN" 584 plot "$datFile" using 1:2:3 with image 585 PLOT 586 587 close GP; 588 589 return 1; 590 } 591 592 593 ########################################################################### 594 # 595 # Plots mask fraction histogram for exposures taken between these dates 596 # 597 ########################################################################### 598 sub plotMagicMaskFractionHistogram { 599 my ($self, $begin, $end) = @_; 600 601 # get exposures between these dates 602 my $exp_ids = undef; 603 if (!$self->{_gpc1Db}->getProcessedExposures($begin, $end, \$exp_ids)) {return 0;} 604 my $totalExp = @{$exp_ids}; 605 if ($totalExp < 1) {return 0;} 606 607 # set up file stuff 608 my $prefix = $self->{_outputPath} ? $self->{_outputPath} : "."; # TODO should be function for this 609 my $histoOutputFile = "$prefix/czarplot_magic_mask_fraction_h.png"; 610 my $distOutputFile = "$prefix/czarplot_magic_mask_fraction_d.png"; 611 my $tmpFile = File::Temp->new( TEMPLATE => "czarplot_magic_mask_fraction.XXXXX", DIR => '/tmp', SUFFIX => 'dat'); 612 613 # set up bins 614 my %histogram; 615 my @bins; 616 my $interval = 0.05; 617 my $min = 1.0; 618 my $max = 1.0; 619 for (my $n=0.0; $n<$max; $n += $interval){ 620 621 push(@bins, $n); 622 $histogram{$n} = 0; 623 } 624 625 # get mask for each exposure, and bin 626 my $mask = undef; 627 my $expCount = 0; 628 foreach my $row ( @{$exp_ids} ) { 629 630 $mask = $self->{_gpc1Db}->getAverageMagicMaskFraction(@{$row}[0]); 631 632 if (!$mask) {next;} 633 $expCount++; 634 635 foreach my $bin (@bins) { 636 if ($mask <= ($bin+$interval)) { 637 638 $histogram{$bin}++; 639 last; 640 } 641 } 642 } 643 644 # write data to GNUPLOT data file 645 print "* Found mask values for $expCount exposures out of $totalExp\n"; 646 open (GNUDAT, ">".$tmpFile->filename); 647 my $accum = 0; 648 my $maxBin = 0; 649 foreach my $bin (@bins) { 650 651 $accum += $histogram{$bin}; 652 if ($histogram{$bin} > $maxBin) {$maxBin = $histogram{$bin};} 653 print GNUDAT "$bin $histogram{$bin} $accum\n"; 654 } 655 close(GNUDAT); 656 657 # now plot 658 open (GP, "|/usr/bin/gnuplot -persist") or die "no gnuplot"; 659 use FileHandle; 660 GP->autoflush(1); 661 662 $maxBin = $maxBin * 1.1; 663 $accum = $accum * 1.1; 664 665 if ($self->{_outputFormat} ne "X11") {print GP "set output \"$histoOutputFile\";";} 666 print GP 667 "set term $self->{_outputFormat};" . 668 "set title \"Magic mask fraction for $expCount exposures between '$begin' and '$end'\";" . 669 "set grid;" . 670 "set boxwidth;" . 671 "set style data histogram;" . 672 "set yrange [0:$maxBin];" . 673 "set style histogram rowstacked;" . 674 "set style fill solid border -1;" . 675 "set ylabel \"Number of Exposures\";" . 676 "set xlabel \"Magic Mask Fraction\";" . 677 "set boxwidth 0.75;" . 678 "set xtic rotate by -90 scale 0;" . 679 "plot '".$tmpFile->filename."' using 2:xtic(1) notitle lt 1;" . 680 "\n"; 681 682 close GP; 683 684 685 open (GP, "|/usr/bin/gnuplot -persist") or die "no gnuplot"; 686 use FileHandle; 687 GP->autoflush(1); 688 689 if ($self->{_outputFormat} ne "X11") {print GP "set output \"$distOutputFile\";";} 690 print GP 691 "set term $self->{_outputFormat};" . 692 "set title \"Cumulative distribution of magic streaks per image between '$begin' and '$end'\";" . 693 "set yrange [0:$accum];" . 694 "set key left top;" . 695 "set grid xtics;" . 696 "set xlabel \"Magic Mask Fraction\";" . 697 "set ylabel \"Number of Exposures\";" . 698 "set xtic rotate by -90 scale 0;" . 699 "plot " . 700 "'".$tmpFile->filename."' using 1:3 notitle with lines lt 2 lw 2\n"; 701 702 print GP "\n"; 703 close GP; 704 705 return 1; 706 } 491 707 1; -
branches/eam_branches/ipp-20101103/tools/roboczar.pl
r29581 r29834 13 13 use czartool::Plotter; 14 14 use czartool::Burntool; 15 use czartool::StageMetrics; 15 16 16 17 my $czarDbName = "czardb"; # TODO variables for other Db stuff, host etc … … 56 57 57 58 sendEmail( 58 " roydhenderson\@gmail.com",59 "ps-ipp-ops\@ifa.hawaii.edu", 59 60 "Roboczar warnings", 60 61 "$message\n"); … … 89 90 my $stage; 90 91 foreach $stage (@stages) { 91 my ($started, $finished, $stuck, $processed, $pending, $faults, $totalTime);92 $czarDb->runAnalysis(93 "all_stdscience_labels",94 $stage,95 $begin,96 $end,97 \$started,98 \$finished,99 \$stuck,100 \$processed,101 \$pending,102 \$faults,103 \$totalTime);104 92 105 print "* $stage $end $begin:\n"; 106 if (defined $started) {print "* Processing started at $started\n";} 107 if (defined $finished) {print "* Processing finished at $finished and took $totalTime\n";} 108 else {print "* Processing has not finished\n";} 109 if (defined $stuck) {print "* Processing has been stuck since $stuck\n";} 110 print "* $processed exposures have been processed, with $pending pending and $faults faults\n"; 93 my $stageMetrics = new czartool::StageMetrics($stage, "all_stdscience_labels", $begin, $end); 111 94 112 print "*******************************************************************************\n";95 if ($czarDb->runAnalysis($stageMetrics)) {$stageMetrics->printMe();} 113 96 114 if ($st uck&& $stage eq "burntool" && !$worryAboutBurntool) {next;}97 if ($stageMetrics->getStuck() && $stage eq "burntool" && !$worryAboutBurntool) {next;} 115 98 116 if ($st uck) {99 if ($stageMetrics->getStuck()) { 117 100 118 ${$message} = ${$message} ."\n - '$stage' is stuck with $pending pending exposures (and $faultsfaults)";101 ${$message} = ${$message} ."\n - '$stage' is stuck with ".$stageMetrics->getFinalPending()." pending exposures (and ".$stageMetrics->getFaults()." faults)"; 119 102 $anyStuckStages = 1; 120 103 } -
branches/eam_branches/ipp-20101103/tools/runchipimfile.pl
r29586 r29834 38 38 39 39 my $query1 = "SELECT chipProcessedImfile.path_base, camera, exp_id, rawImfile.magicked AS raw_magicked, (rawImfile.user_1 is not NULL and rawImfile.user_1 > 0.5) As deburned, chip_imfile_id, chipProcessedImfile.fault, rawImfile.uri, chipRun.reduction, chipRun.state"; 40 $query1 .= " FROM chipRun join chipProcessedImfile using(chip_id ) JOIN chipImfile USING (chip_id, class_id) JOIN rawExp using(exp_id) JOIN rawImfile USING(exp_id) WHERE chip_id = $chip_id AND class_id = $class_id";40 $query1 .= " FROM chipRun join chipProcessedImfile using(chip_id,exp_id) JOIN chipImfile USING (chip_id, class_id) JOIN rawExp using(exp_id) JOIN rawImfile USING(exp_id, camera, class_id) WHERE chip_id = $chip_id AND class_id = '$class_id'"; 41 41 42 42 my $stmt1 = $dbh->prepare($query1); … … 55 55 my $exp_id = $results->{exp_id}; 56 56 57 notdone58 59 57 die "cannot update database for a chip that is not faulted\n" if $update and !$fault; 60 58 … … 69 67 $run_state = 'new'; 70 68 } elsif ($state eq 'update') { 71 $ state = 'update';69 $run_state = 'update'; 72 70 } else { 73 die "unexpected warpRun.state found: $state\n";71 die "unexpected chipRun.state found: $state\n"; 74 72 } 75 73 76 my $command = "chip_imfile.pl --exp_id $exp_id --chip_id $chip_id --c lass_id $class_id --chip_imfile_id $chip_imfile_id --uri $uri --camera $camera --run-state $run_state --deburned $deburned --outroot $path_base" ;74 my $command = "chip_imfile.pl --exp_id $exp_id --chip_id $chip_id --chip_imfile_id $chip_imfile_id --class_id $class_id --uri $uri --camera $camera --run-state $run_state --deburned $deburned --outroot $path_base" ; 77 75 78 76 $command .= " --magicked $magicked" if $magicked > 0; … … 83 81 $command .= " --verbose" unless $no_verbose; 84 82 $command .= " --dbname $dbname" if $dbname; 85 86 83 87 84 if ($update) {
Note:
See TracChangeset
for help on using the changeset viewer.
