Changeset 29437
- Timestamp:
- Oct 15, 2010, 12:34:37 PM (16 years ago)
- Location:
- trunk/tools
- Files:
-
- 3 edited
-
czarplot.pl (modified) (6 diffs)
-
czartool/CzarDb.pm (modified) (31 diffs)
-
czartool/Plotter.pm (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/czarplot.pl
r29375 r29437 23 23 my $timeSeries = undef; 24 24 my $rate = undef; 25 my $deriv = undef; 25 26 my $showCleanup = undef; 26 27 my $nebulous = undef; … … 29 30 30 31 GetOptions ( 31 "dbname |d=s" => \$czarDbName,32 "dbname=s" => \$czarDbName, 32 33 "label|l=s" => \$label, 33 34 "stage|s=s" => \$stage, … … 41 42 "cleanup|c" => \$showCleanup, 42 43 "rate|r" => \$rate, 44 "deriv|d" => \$deriv, 43 45 "timeseries|t" => \$timeSeries, 44 46 "verbose|v" => \$verbose, … … 59 61 if (!$rate) { 60 62 print "* OPTIONAL: plot timeseries of rate -r (default=off)\n";} 63 if (!$deriv) { 64 $deriv = 0; 65 print "* OPTIONAL: plot first derivative -d (default=$deriv)\n";} 61 66 if (!$showCleanup) { 62 67 $showCleanup = 0; … … 97 102 $czarDb->setDateFormat("%Y%m%d-%H%i%s"); 98 103 104 99 105 my $plotter = new czartool::Plotter( 100 106 $czarDb, … … 128 134 exit; 129 135 } 130 if (!$nebulous && $timeSeries) {$plotter->createTimeSeries($label, $stage, $begin, $end, $log, $showCleanup );}136 if (!$nebulous && $timeSeries) {$plotter->createTimeSeries($label, $stage, $begin, $end, $log, $showCleanup, $deriv);} 131 137 if ($histogram) {$plotter->createHistogram($label, $begin, $end);} 132 138 if ($nebulous && $timeSeries) {$plotter->plotStorageTimeSeries($begin, $end);} -
trunk/tools/czartool/CzarDb.pm
r29377 r29437 271 271 ########################################################################### 272 272 sub createTimeSeriesData { 273 my ($self, $label, $stage, $fromTime, $toTime, $minX, $maxX, $timeDiff, $dataFile, $isLog, $showCleanup ) = @_;273 my ($self, $label, $stage, $fromTime, $toTime, $minX, $maxX, $timeDiff, $dataFile, $isLog, $showCleanup, $firstDeriv) = @_; 274 274 275 275 my $query = $self->{_db}->prepare(<<SQL); … … 289 289 $query = $self->{_db}->prepare(<<SQL); 290 290 SELECT 291 DATE_FORMAT(timestamp, '$self->{_dateFormat}'), pending, faults, processed291 timestamp, pending, faults, processed 292 292 FROM $stage 293 293 WHERE label LIKE '$label' … … 302 302 303 303 my $lastProcessed = -1; 304 my $lastPending = -1; 305 my $lastFaults = -1; 306 my $lastTimestamp = undef; 304 307 my $processed = 0; 308 my $runningProcessed = 0; 309 my $pending = 0; 310 my $faults = 0; 311 my $timestamp = undef; 305 312 while (my @row = $query->fetchrow_array()) { 306 my ($t imestamp, $pending, $faults, $thisProcessed) = @row;307 308 if ($showCleanup ) {313 my ($thisTimestamp, $thisPending, $thisFaults, $thisProcessed) = @row; 314 315 if ($showCleanup ) { 309 316 310 $processed = $thisProcessed - $minProcessed;317 $runningProcessed = $thisProcessed - $minProcessed; 311 318 } 312 319 elsif($lastProcessed != -1 && $thisProcessed > $lastProcessed) { 313 320 314 $processed = $processed + ($thisProcessed - $lastProcessed); 315 } 316 317 if ($isLog) { 318 319 if ($processed < 0) {$processed = 0;} 320 if ($pending < 0) {$pending = 0;} 321 if ($faults < 0) {$faults = 0;} 322 323 $processed = log($processed + 1)/log(10); 324 $pending = log($pending + 1)/log(10); 321 $runningProcessed = $runningProcessed + ($thisProcessed - $lastProcessed); 322 } 323 324 325 if ($firstDeriv) { 326 327 if (defined $lastTimestamp) { 328 329 my $timeDiff = $self->diffTimesInSecs($thisTimestamp, $lastTimestamp); 330 331 if ($thisProcessed > $lastProcessed){ 332 $processed = abs($thisProcessed - $lastProcessed)/$timeDiff; 333 #print "$processed = ($thisProcessed - $lastProcessed)/$timeDiff\n"; 334 } 335 else {$processed = 0;} 336 #$pending = abs($thisPending - $lastPending)/$timeDiff; 337 #$faults = abs($thisFaults - $lastFaults)/$timeDiff; 338 } 339 else { 340 $processed = 0; 341 $pending = 0; 342 $faults = 0; 343 } 344 } 345 elsif ($isLog) { 346 347 $processed = ($runningProcessed < 0) ? 0 : $runningProcessed; 348 $pending = ($thisPending < 0) ? 0 : $thisPending; 349 $faults = ($thisFaults < 0) ? 0 : $thisFaults; 350 351 $processed = log($runningProcessed + 1)/log(10); 352 $pending = log($thisPending + 1)/log(10); 325 353 $faults = log($faults + 1)/log(10); 326 354 } 355 else { 356 357 $processed = $runningProcessed; 358 $pending = $thisPending; 359 $faults = $thisFaults; 360 } 361 362 $timestamp = $self->getFormattedDate($thisTimestamp); 327 363 328 364 print GNUDAT "$timestamp $pending $faults $processed\n"; 365 329 366 $lastProcessed = $thisProcessed; 367 $lastPending = $thisPending; 368 $lastFaults = $thisFaults; 369 $lastTimestamp = $thisTimestamp; 330 370 } 331 371 … … 568 608 ########################################################################### 569 609 # 610 # When did this stage finish? 611 # 612 ########################################################################### 613 sub getFinishTime { 614 my ($self, $label, $stage, $begin, $end) = @_; 615 616 my $query = $self->{_db}->prepare(<<SQL); 617 SELECT 618 timestamp, pending, faults 619 FROM $stage 620 WHERE label LIKE '$label' 621 AND timestamp >= '$begin' 622 AND timestamp <= '$end' 623 SQL 624 $query->execute; 625 626 my $array = $query->fetchall_arrayref(); 627 628 my $row; 629 my $thisPending = -1; 630 my $lastPending = -1; 631 my $thisFaults = -1; 632 my $lastFaults = -1; 633 my $timestamp; 634 my $started = undef; 635 my $finished = undef; 636 my $thisLeft = 0; 637 my $lastLeft = 0; 638 my $finishTimeout = "01:00:00"; 639 my $numRows = @{$array}; 640 print "$numRows rows\n"; 641 my $n = 0; 642 foreach $row ( @{$array} ){ 643 644 ($timestamp, $thisPending, $thisFaults) = @{$row}; 645 646 # print "$timestamp, $thisPending, $thisFaults\n"; 647 648 $thisLeft = $thisPending - $thisFaults; 649 $lastLeft = $lastPending - $lastFaults; 650 651 652 if ($n == 0 && $thisLeft > 0) { 653 654 print "Starting this time period with stuff pending ($thisLeft)\n"; 655 $started = $timestamp; 656 } 657 658 if (!defined $started && $lastLeft == 0 && $thisLeft > 0) { 659 660 $started = $timestamp; 661 print "STARTED at $started\n"; 662 } 663 664 if ($started && !defined $finished && $thisLeft == 0) { 665 666 $finished = $timestamp; 667 print "setting FINISHED to $finished\n"; 668 } 669 670 if (defined $finished) { 671 672 if ($thisLeft != 0) { 673 674 $finished = undef; 675 676 print "NEW pending at $timestamp\n"; 677 678 } 679 elsif ($thisLeft == 0) { 680 681 my $howLongFinished = $self->diffTimes($timestamp, $finished); 682 683 print "$howLongFinished = $timestamp, $finished\n"; 684 685 if ($self->isIntervalGreaterThan($howLongFinished, $finishTimeout)) { 686 687 print "0 pending for $howLongFinished. We're done \n"; 688 last; 689 } 690 691 } 692 693 } 694 695 696 $lastPending = $thisPending; 697 $lastFaults = $thisFaults; 698 $n++; 699 if ($n == $numRows) { 700 701 if ($thisLeft == 0) { 702 703 print "exceeded interval before reaching finished timeout\n"; 704 } 705 else { 706 print "Reached end of interval and not finished yet. $thisLeft left\n"; 707 } 708 } 709 } 710 711 if ($finished) { 712 713 my $timeTaken = $self->diffTimes($finished, $started); 714 print "FINISHED at $finished with $thisFaults remaining faults, time taken = $timeTaken\n"; 715 } 716 717 } 718 719 ########################################################################### 720 # 721 # Figures out if a stage has plateaued 722 # 723 ########################################################################### 724 sub hasPlateaued { 725 my ($self, $label, $stage, $end, $interval) = @_; 726 727 my $query = $self->{_db}->prepare(<<SQL); 728 SELECT 729 timestamp, pending, faults 730 FROM $stage 731 WHERE label LIKE '$label' 732 AND timestamp >= '$end - INTERVAL $interval' 733 AND timestamp <= '$end' 734 ORDER BY timestamp DESC; 735 SQL 736 $query->execute; 737 738 my $array = $query->fetchall_arrayref(); 739 740 my $thisPending = -1; 741 my $lastPending = -1; 742 my $thisFaults = -1; 743 my $lastFaults = -1; 744 my $timestamp; 745 my $thisLeft = 0; 746 my $lastLeft = 0; 747 my $row; 748 my $numRows = @{$array}; 749 my $n = 0; 750 foreach $row ( @{$array} ){ 751 752 ($timestamp, $thisPending, $thisFaults) = @{$row}; 753 754 $thisLeft = $thisPending - $thisFaults; 755 $lastLeft = $lastPending - $lastFaults; 756 757 print "$timestamp $thisPending\n"; 758 759 if ($n>0) { 760 761 #if () {} 762 763 } 764 765 $lastPending = $thisPending; 766 $lastFaults = $thisFaults; 767 $n++; 768 } 769 } 770 771 ########################################################################### 772 # 570 773 # Gets count of processed stuff in a given time period 571 774 # … … 582 785 AND timestamp < '$end' 583 786 SQL 584 $query->execute;787 $query->execute; 585 788 586 789 my $processedArray = $query->fetchall_arrayref(); … … 614 817 615 818 if (!$self->isBefore($thisDay, $endDay)) { 616 819 617 820 $quit = 1; 618 821 } … … 645 848 $toTime = $self->addInterval($fromTime, $interval); 646 849 if (!$self->isBefore($toTime, $endDay)) { 647 850 648 851 $toTime = $endDay; 649 852 $quit = 1; 650 853 } 651 854 652 855 my $stage = undef; 653 856 $totalDeleted = 0; … … 703 906 AND server = '$server' 704 907 SQL 705 $query->execute;908 $query->execute; 706 909 707 910 my $toDelete = scalar $query->fetchrow_array() - 1; … … 714 917 AND server = '$server' ORDER BY timestamp DESC LIMIT $toDelete 715 918 SQL 716 $query->execute;919 $query->execute; 717 920 718 921 $totalDeleted += $toDelete; … … 728 931 AND timestamp <= '$toTime' 729 932 SQL 730 $query->execute;933 $query->execute; 731 934 732 935 my $toDelete = scalar $query->fetchrow_array() - 1; … … 739 942 ORDER BY timestamp DESC LIMIT $toDelete 740 943 SQL 741 $query->execute;944 $query->execute; 742 945 743 946 $totalDeleted += $toDelete; … … 755 958 ########################################################################### 756 959 sub optimize { 757 my ($self) = @_;960 my ($self) = @_; 758 961 759 962 my $stage = undef; … … 782 985 SQL 783 986 784 $query->execute;987 $query->execute; 785 988 my $numOfReadings = scalar $query->fetchrow_array(); 786 989 … … 795 998 SQL 796 999 797 $query->execute;1000 $query->execute; 798 1001 my $numNotRunning = scalar $query->fetchrow_array(); 799 1002 … … 893 1096 INSERT INTO revision (revision) VALUES ($revision); 894 1097 SQL 895 $query->execute;1098 $query->execute; 896 1099 } 897 1100 … … 912 1115 SQL 913 1116 914 $query->execute;1117 $query->execute; 915 1118 my @row = $query->fetchrow_array(); 916 1119 … … 940 1143 foreach $stage (@stages) { 941 1144 942 my $query = $self->{_db}->prepare(<<SQL);1145 my $query = $self->{_db}->prepare(<<SQL); 943 1146 CREATE TABLE $stage ( 944 1147 timestamp TIMESTAMP DEFAULT NOW(), … … 969 1172 foreach $stage (@stages) { 970 1173 971 my $query = $self->{_db}->prepare(<<SQL);1174 my $query = $self->{_db}->prepare(<<SQL); 972 1175 ALTER TABLE $stage 973 1176 ADD COLUMN reverting TINYINT NOT NULL DEFAULT 0; … … 994 1197 foreach $stage (@stages) { 995 1198 996 my $query = $self->{_db}->prepare(<<SQL);1199 my $query = $self->{_db}->prepare(<<SQL); 997 1200 ALTER TABLE $stage 998 1201 ADD COLUMN processed BIGINT NOT NULL DEFAULT 0; 999 1202 SQL 1000 1203 1001 $query->execute;1204 $query->execute; 1002 1205 } 1003 1206 … … 1019 1222 SQL 1020 1223 1021 $query->execute;1224 $query->execute; 1022 1225 1023 1226 $self->setRevision(4); … … 1041 1244 SQL 1042 1245 1043 $query->execute;1246 $query->execute; 1044 1247 1045 1248 $self->setRevision(5); … … 1065 1268 SQL 1066 1269 1067 $query->execute;1068 } 1069 1070 my $query = $self->{_db}->prepare(<<SQL);1071 CREATE INDEX serverIndex ON servers (timestamp, server);1072 SQL 1073 1074 $query->execute;1270 $query->execute; 1271 } 1272 1273 my $query = $self->{_db}->prepare(<<SQL); 1274 CREATE INDEX serverIndex ON servers (timestamp, server); 1275 SQL 1276 1277 $query->execute; 1075 1278 1076 1279 … … 1093 1296 SQL 1094 1297 1095 $query->execute;1298 $query->execute; 1096 1299 1097 1300 $self->setRevision(7); … … 1117 1320 SQL 1118 1321 1119 $query->execute;1322 $query->execute; 1120 1323 } 1121 1324 … … 1127 1330 SQL 1128 1331 1129 $query->execute;1332 $query->execute; 1130 1333 1131 1334 # insert stages into revert table … … 1137 1340 ('$stage', 0); 1138 1341 SQL 1139 $query->execute;1342 $query->execute; 1140 1343 } 1141 1344 … … 1162 1365 SQL 1163 1366 1164 $query->execute;1367 $query->execute; 1165 1368 $query = $self->{_db}->prepare(<<SQL); 1166 1369 CREATE TABLE hosts ( … … 1171 1374 SQL 1172 1375 1173 $query->execute;1174 1175 $query = $self->{_db}->prepare(<<SQL);1176 CREATE INDEX clusterSpaceIndex ON cluster_space (timestamp);1177 SQL 1178 1179 $query->execute;1376 $query->execute; 1377 1378 $query = $self->{_db}->prepare(<<SQL); 1379 CREATE INDEX clusterSpaceIndex ON cluster_space (timestamp); 1380 SQL 1381 1382 $query->execute; 1180 1383 1181 1384 $self->setRevision(9); … … 1195 1398 ALTER TABLE hosts 1196 1399 ADD COLUMN writable TINYINT NOT NULL DEFAULT 0, 1197 ADD COLUMN readable TINYINT NOT NULL DEFAULT 0;1198 SQL 1199 1200 $query->execute;1400 ADD COLUMN readable TINYINT NOT NULL DEFAULT 0; 1401 SQL 1402 1403 $query->execute; 1201 1404 1202 1405 $self->setRevision(10); … … 1223 1426 SQL 1224 1427 1225 $query->execute;1226 $query = $self->{_db}->prepare(<<SQL);1227 CREATE INDEX burntoolIndex ON burntool (timestamp, label);1228 SQL 1229 1230 $query->execute;1428 $query->execute; 1429 $query = $self->{_db}->prepare(<<SQL); 1430 CREATE INDEX burntoolIndex ON burntool (timestamp, label); 1431 SQL 1432 1433 $query->execute; 1231 1434 1232 1435 $self->setRevision(11); … … 1250 1453 SQL 1251 1454 1252 $query->execute;1455 $query->execute; 1253 1456 1254 1457 $self->setRevision(12); -
trunk/tools/czartool/Plotter.pm
r29377 r29437 130 130 ########################################################################### 131 131 sub createTimeSeries { 132 my ($self, $label, $selectedStage, $beginTime, $endTime, $isLog, $showCleanup ) = @_;132 my ($self, $label, $selectedStage, $beginTime, $endTime, $isLog, $showCleanup, $deriv) = @_; 133 133 134 134 my $minX = 999999999; … … 156 156 \$gnuplotFile, 157 157 $isLog, 158 $showCleanup)) { 158 $showCleanup, 159 $deriv)) { 159 160 160 161 $gnuplotFiles{$stage} = $gnuplotFile; … … 186 187 $minX, 187 188 $timeDiff, 188 $isLog); 189 $isLog, 190 $deriv); 189 191 } 190 192 … … 325 327 ########################################################################### 326 328 sub plotTimeSeries { 327 my ($self, $gnuplotFiles, $outputFile, $label, $fromTime, $toTime, $maxX, $minX, $timeDiff, $isLog ) = @_;329 my ($self, $gnuplotFiles, $outputFile, $label, $fromTime, $toTime, $maxX, $minX, $timeDiff, $isLog, $isDeriv) = @_; 328 330 329 331 my $timeFormat = undef; 330 332 my $divX = undef; 331 333 my $yTitle = undef; 332 if ($isLog) {$yTitle = "Log( numExposures )";} 333 else {$yTitle = "numExposures";} 334 if ($isLog) {$yTitle = "Log( Exposures )";} 335 elsif ($isDeriv) {$yTitle = "dExposures/dTime";} 336 else {$yTitle = "Exposures";} 334 337 335 338 $self->getTimeSpacing($timeDiff, \$divX, \$timeFormat); 336 339 337 340 my $numOfPlots = keys %$gnuplotFiles; 338 my $title = undef;339 341 340 342 # sort out plot title 341 if ($numOfPlots == 1) {foreach my $stage (keys %$gnuplotFiles) {$title = "'".$stage."'";}} 342 else {$title = "'All stages'"} 343 my $title = ""; 344 if ($isDeriv) {$title .= "First derivatives of "} 345 if ($numOfPlots == 1) {foreach my $stage (keys %$gnuplotFiles) {$title .= "'".$stage."'";}} 346 else {$title .= "'all stages'"} 343 347 344 348 $title .= " for '$label', '$fromTime' to '$toTime'"; … … 369 373 if ($numOfPlots == 1) { 370 374 375 print GP "'" . $gnuplotFiles->{$stage} . "' using 1:2 title \"Pending\" with lines lt 4 lw 2,"; 371 376 print GP "'" . $gnuplotFiles->{$stage} . "' using 1:4 title \"Processed\" with lines lt 2 lw 2,"; 372 print GP "'" . $gnuplotFiles->{$stage} . "' using 1:2 title \"Pending\" with lines lt 4 lw 2,";373 377 print GP "'" . $gnuplotFiles->{$stage} . "' using 1:3 title \"Faults\" with lines lt 7 lw 2"; 374 378 }
Note:
See TracChangeset
for help on using the changeset viewer.
