Changeset 28719
- Timestamp:
- Jul 27, 2010, 2:42:17 PM (16 years ago)
- Location:
- trunk/tools
- Files:
-
- 1 added
- 1 deleted
- 4 edited
-
czarplot.pl (modified) (6 diffs)
-
czartool/CzarDb.pm (modified) (6 diffs)
-
czartool/Czarplot.pm (added)
-
czartool/Gnuplot.pm (deleted)
-
czartool/Gpc1Db.pm (modified) (1 diff)
-
roboczar.pl (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/czarplot.pl
r28714 r28719 5 5 6 6 use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt ); 7 use File::Temp qw(tempfile);8 7 use POSIX qw/strftime/; 9 8 10 9 use czartool::CzarDb; 11 use czartool::Gnuplot; 12 10 use czartool::Czarplot; 13 11 14 12 my $czarDbName = "czardb"; … … 19 17 my $begin = undef; 20 18 my $end = undef; 19 my $path = undef; 21 20 my $verbose = undef; 22 21 my $histogram = undef; 23 22 my $timeSeries = undef; 23 my $savingToFile = undef; 24 24 25 25 GetOptions ( … … 30 30 "begin|b=s" => \$begin, 31 31 "end|e=s" => \$end, 32 "output|o=s" => \$path, 32 33 "histogram|h" => \$histogram, 33 34 "timeseries|t" => \$timeSeries, … … 37 38 print "\n"; 38 39 if (!$histogram) { 39 print "* OPTIONAL: plot histogram -h (default=on)\n"; 40 } 40 print "* OPTIONAL: plot histogram -h (default=off)\n";} 41 41 if (!$timeSeries) { 42 print "* OPTIONAL: plot timeseries -t (default=on)\n"; 43 } 42 print "* OPTIONAL: plot timeseries -t (default=on)\n";} 44 43 if (!$label) { 45 print "* OPTIONAL: choose a label -l <labellName> (default='all_labels')\n"; 46 } 44 print "* OPTIONAL: choose a label -l <labellName> (default='all_labels')\n";} 47 45 if (!$stage) { 48 print "* OPTIONAL: choose a stage -s <chip|cam|warp|etc> (default=none)\n"; 49 } 46 print "* OPTIONAL: choose a stage -s <chip|cam|warp|etc> (default=none)\n";} 50 47 if (!$interval) { 51 print "* OPTIONAL: choose time interval in past -i <'1 hour'|'1 day'|etc> (default=interval since 7am this morning)\n"; 52 } 48 print "* OPTIONAL: choose time interval in past -i <'1 hour'|'1 day'|etc> (default=interval since 7am this morning)\n";} 53 49 if (!$begin) { 54 print "* OPTIONAL: choose a begin time -d <datetime> (default=7am this morning)\n"; 55 } 50 print "* OPTIONAL: choose a begin time -d <datetime> (default=7am this morning)\n";} 56 51 if (!$end) { 57 print "* OPTIONAL: choose an end time -e <datetime> (default=now)\n"; 58 } 52 print "* OPTIONAL: choose an end time -e <datetime> (default=now)\n";} 53 if (!$path) { 54 print "* OPTIONAL: choose an output location -o <path> (default=none)\n";} 59 55 60 56 print "\n"; … … 62 58 # default values 63 59 if (!$label) {$label = "all_labels";} 64 if (!$histogram && !$timeSeries) {$timeSeries = 1; }60 if (!$histogram && !$timeSeries) {$timeSeries = 1; $histogram = 1;} 65 61 if (!$verbose) {$verbose = 0;} 66 62 if (!$save_temps) {$save_temps = 0;} 63 if (!$path) {$savingToFile = 0; $path = ".";} 64 else {$savingToFile = 1;} 67 65 68 66 my $czarDb = new czartool::CzarDb($czarDbName, "ippdb01", "ipp", "ipp", $verbose); 69 my $gnuplot = new czartool::Gnuplot("%Y%m%d-%H%M%S", "X11", "histo.pbm");70 67 $czarDb->setDateFormat("%Y%m%d-%H%i%s"); 68 69 my $czarplot = new czartool::Czarplot($czarDb, "%Y%m%d-%H%M%S", $savingToFile ? "png" : "X11", $path, $save_temps); 71 70 72 71 my @allStages = ("chip", "cam", "fake", "warp", "stack", "diff", "magic", "magicDS", "dist"); … … 79 78 } 80 79 81 if ($ histogram) {plotHistogram($label, $begin, $end);}82 if ($ timeSeries) {plotTimeSeries($label, $stage, $begin, $end);}80 if ($timeSeries) {$czarplot->createTimeSeries($label, $stage, $begin, $end);} 81 if ($histogram) {$czarplot->createHistogram($label, $begin, $end);} 83 82 84 ###########################################################################85 #86 # Plots a time series for all stages for this label87 #88 ###########################################################################89 sub plotTimeSeries {90 my ($label, $selectedStage, $beginTime, $endTime) = @_;91 92 my ($minX, $maxX, $minY, $maxY, $timeDiff);93 $minX = 999999999;94 $maxX = -9999999999;95 $minY = 999999999;96 $maxY = -99999999;97 98 my $stages = undef;99 100 if (!$selectedStage) {$stages = \@allStages;}101 else {$stages = ["$selectedStage"]};102 103 my %gnuplotFiles;104 foreach $stage (@{$stages}) {105 $gnuplotFiles{$stage} = $czarDb->createTimeSeriesData($save_temps, $label, $stage, $beginTime, $endTime, \$minX, \$maxX, \$minY, \$maxY, \$timeDiff);106 }107 108 if (!$selectedStage) {$gnuplot->plotAllStagesTimeSeries($label, $beginTime, $endTime, $maxX, $minX, $maxY, $minY, $timeDiff, \%gnuplotFiles);}109 else {$gnuplot->plotSingleTimeSeries($gnuplotFiles{$selectedStage}, $selectedStage, $label, $beginTime, $endTime, $maxX, $minX, $maxY, $minY, $timeDiff);}110 111 }112 113 ###########################################################################114 #115 # Plots a histogram of stuff processed in provided interval and label for all stages116 #117 ###########################################################################118 sub plotHistogram {119 my ($label, $beginTime, $endTime) = @_;120 121 my ($tempFile, $filePath) = tempfile( "/tmp/czartool_gnuplot_histogram.XXXX", UNLINK => !$save_temps);122 my ($processed, $pending, $faults);123 124 foreach $stage (@allStages) {125 126 $czarDb->countProcessedPendingAndFaults($label, $stage, $beginTime, $endTime, \$processed, \$pending, \$faults);127 print $tempFile "$stage $processed, $pending, $faults\n";128 }129 130 close($tempFile);131 132 $gnuplot->plotHistogram($filePath, $label, $beginTime, $endTime);133 }134 135 136 -
trunk/tools/czartool/CzarDb.pm
r28715 r28719 72 72 $query->execute; 73 73 } 74 75 ########################################################################### 76 # 77 # Sets priority for this label 78 # 79 ########################################################################### 80 sub setLabelPriority { 81 my ($self, $label, $priority) = @_; 82 83 my $query = $self->{_db}->prepare(<<SQL); 84 UPDATE current_labels 85 SET priority = $priority 86 WHERE label LIKE '$label' 87 AND server LIKE 'stdscience'; 88 SQL 89 90 $query->execute; 91 } 92 74 93 ########################################################################### 75 94 # … … 79 98 sub updateCurrentLabels { 80 99 my ($self, $server, $labels) = @_; 100 101 my $size = scalar @{$labels}; 102 if ($size < 1) {return;} 81 103 82 104 my $query = $self->{_db}->prepare(<<SQL); … … 181 203 182 204 my ($timestamp, $pending, $faults, $processed) = @row; 205 # print "'$timestamp' '$pending' '$faults' '$processed'\n"; 183 206 print $tempFile "$timestamp $pending $faults $processed\n"; 184 207 } … … 298 321 299 322 my $currentRevision = -1; 300 my $latestRevision = 6;323 my $latestRevision = 7; 301 324 302 325 while ($currentRevision != $latestRevision) { … … 311 334 elsif ($currentRevision == 4) {$self->createRevision_5();} 312 335 elsif ($currentRevision == 5) {$self->createRevision_6();} 336 elsif ($currentRevision == 6) {$self->createRevision_7();} 313 337 } 314 338 } … … 476 500 ####################################################################################### 477 501 # 502 # Create revision 7 of the database 503 # 504 ####################################################################################### 505 sub createRevision_7 { 506 my ($self) = @_; 507 508 print "* Creating revision 7 of '$self->{_dbName}'\n"; 509 510 my $query = $self->{_db}->prepare(<<SQL); 511 ALTER TABLE current_labels 512 ADD COLUMN priority INT NOT NULL DEFAULT 0; 513 SQL 514 515 $query->execute; 516 517 $self->setRevision(7); 518 } 519 520 ####################################################################################### 521 # 478 522 # Sets current revision of ippToPsps database 479 523 # -
trunk/tools/czartool/Gpc1Db.pm
r28704 r28719 73 73 ########################################################################### 74 74 # 75 # Returns priority for this label 76 # 77 ########################################################################### 78 sub getPriority { 79 my ($self, $label) = @_; 80 81 my $query = $self->{_db}->prepare(<<SQL); 82 SELECT priority 83 FROM Label 84 WHERE label LIKE '$label' 85 SQL 86 87 $query->execute; 88 my $priority = scalar $query->fetchrow_array(); 89 if (!$priority) {return 50000;} # assume labels not given priority in gpc1 Db have highest priority 90 return $priority; 91 } 92 93 ########################################################################### 94 # 75 95 # Returns count of exposures with this state for this label 76 96 # -
trunk/tools/roboczar.pl
r28715 r28719 4 4 use strict; 5 5 use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt ); 6 use POSIX qw/strftime/; 6 7 7 8 # local classes … … 9 10 use czartool::Gpc1Db; 10 11 use czartool::Pantasks; 12 use czartool::Czarplot; 11 13 12 14 13 15 my $period = 60; 14 16 my $czarDbName = "czardb"; # TODO variables for other Db stuff, host etc 15 my $save_temps = 1;17 my $save_temps = 0; 16 18 17 19 my $czarDb = new czartool::CzarDb($czarDbName, "ippdb01", "ipp", "ipp"); 18 20 my $gpc1Db = new czartool::Gpc1Db("gpc1", "ippdb01", "ippuser", "ippuser"); 19 21 my $pantasks = new czartool::Pantasks(); 22 my $czarplot = new czartool::Czarplot($czarDb, "%Y%m%d-%H%M%S", "png", "~/", $save_temps); 23 $czarDb->setDateFormat("%Y%m%d-%H%i%s"); 24 20 25 my @stages = ("chip", "cam", "fake", "warp", "stack", "diff", "magic", "magicDS", "dist"); 21 26 … … 79 84 my $full; 80 85 my $faults; 81 my $currentTime;82 86 my $stage; 83 87 my ($totalNew,$totalFull,$totalFaults); … … 88 92 my $rows = undef; 89 93 my $row = undef; 94 my $begin = undef; 95 my $end = undef; 96 my $priority = undef; 90 97 91 98 while (1) { … … 94 101 updateLabels(); 95 102 if (!$czarDb->getCurrentLabels("stdscience", \$rows)) {next;} 103 104 my $size = @{$rows}; 105 if($size < 1) { 106 107 print "* WARNING: no stdscience labels found in Db\n"; 108 next; 109 } 110 111 # get priority 112 foreach $row ( @{$rows} ) { 113 my ($label) = @{$row}; 114 $priority = $gpc1Db->getPriority($label); 115 $czarDb->setLabelPriority($label, $priority); 116 } 117 118 # sort out times 119 $begin = strftime('%Y-%m-%d 07:00',localtime); 120 $end = $czarDb->getNowTimestamp(); 96 121 97 122 foreach $stage (@stages) { … … 112 137 $full = $gpc1Db->countExposures($label, $stage, "full"); 113 138 $faults = $gpc1Db->countFaults($label, $stage); 114 $currentTime = time();115 139 116 140 #printf("%ld, %s, %s, %d, %d\n", $currentTime, $label, $stage, $new, $faults); … … 125 149 } 126 150 151 print "* Generating plots\n"; 127 152 foreach $row ( @{$rows} ) { 128 153 my ($label) = @{$row}; 154 155 $czarplot->createTimeSeries($label, undef, $begin, $end); 156 $czarplot->createHistogram($label, $begin, $end); 157 129 158 #routineChecks($label, "1 HOUR"); 130 159 } 160 $czarplot->createTimeSeries("all_labels", undef, $begin, $end); 161 $czarplot->createHistogram("all_labels", $begin, $end); 131 162 print "--------------------------------------------------------------------------\n"; 132 163 print "* Going to sleep\n";
Note:
See TracChangeset
for help on using the changeset viewer.
