Changeset 28926 for trunk/tools/roboczar.pl
- Timestamp:
- Aug 16, 2010, 2:08:26 PM (16 years ago)
- File:
-
- 1 edited
-
trunk/tools/roboczar.pl (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/roboczar.pl
r28870 r28926 42 42 43 43 print "* Updating labels\n"; 44 my @servers = ("stdscience", "distribution", "publishing" );44 my @servers = ("stdscience", "distribution", "publishing", "update"); 45 45 46 46 my $server = undef; … … 92 92 my $faults; 93 93 my $stage; 94 my ($totalNew,$totalFull,$totalFaults);95 94 my $query = undef; 96 95 my $str = undef; 97 my $reverting = 0; 98 my $server = undef; 99 my $rows = undef; 96 my $labels = undef; 97 my $updateLabels = undef; 100 98 my $row = undef; 101 99 my $begin = undef; 102 100 my $end = undef; 103 101 my $priority = undef; 102 my $newState = undef; 103 104 104 while (1) { 105 105 106 # sort out times 107 $begin = strftime('%Y-%m-%d 07:00',localtime); 108 $end = $czarDb->getNowTimestamp(); 109 110 if ($czarDb->isBefore($end, $begin)) { 111 112 $begin = $czarDb->subtractInterval($begin, "1 DAY"); 113 } 114 115 # check nebulous 106 116 print "* Checking Nebulous\n"; 107 117 $nebulous->updateClusterSpaceInfo(); 108 118 $czarplot->plotDiskUsageHistogram(); 109 119 updateServerStatus(); 120 121 # check labels 110 122 updateLabels(); 111 if (!$czarDb->getCurrentLabels("stdscience", \$rows)) {next;} 112 113 my $size = @{$rows}; 114 if($size < 1) { 115 116 print "* WARNING: no stdscience labels found in Db\n"; 117 next; 118 } 119 120 # get priority 121 foreach $row ( @{$rows} ) { 122 my ($label) = @{$row}; 123 $priority = $gpc1Db->getPriority($label); 124 $czarDb->setLabelPriority($label, $priority); 125 } 126 127 # sort out times 128 $begin = strftime('%Y-%m-%d 07:00',localtime); 129 $end = $czarDb->getNowTimestamp(); 130 131 if ($czarDb->isBefore($end, $begin)) { 132 133 $begin = $czarDb->subtractInterval($begin, "1 DAY"); 134 } 135 136 foreach $stage (@stages) { 137 138 $server = $pantasks->getServerForThisStage($stage); 139 $pantasks->getRevertStatus($stage, \$reverting); 140 $czarDb->updateRevertStatus($stage, $reverting); 141 142 print "* Checking labels for $stage stage\n"; 143 144 $totalNew=$totalFaults=$totalFull=0; 145 foreach $row ( @{$rows} ) { 146 my ($label) = @{$row}; 147 148 chomp($label); 149 150 $new = $gpc1Db->countExposures($label, $stage, "new"); 151 $full = $gpc1Db->countExposures($label, $stage, "full"); 152 $faults = $gpc1Db->countFaults($label, $stage); 153 154 #printf("%ld, %s, %s, %d, %d\n", $currentTime, $label, $stage, $new, $faults); 155 $totalNew += $new; 156 $totalFull += $full; 157 $totalFaults += $faults; 158 159 $czarDb->insertNewTimeData($stage, $label, $new, $full, $faults); 160 $czarplot->createTimeSeries($label, $stage, $begin, $end); 123 124 # servers to check 125 my @serversToCheck = ("stdscience", "update"); 126 127 my $thisServer = undef; 128 foreach $thisServer (@serversToCheck) { 129 130 if ($thisServer eq "update") {$newState = "update";} 131 else {$newState = "new";} 132 133 # deal with stdscience labels 134 if (!$czarDb->getCurrentLabels($thisServer, \$labels)) {next;} 135 my $size = @{$labels}; 136 if($size > 0) { 137 138 # get priority 139 foreach $row ( @{$labels} ) { 140 my ($label) = @{$row}; 141 $priority = $gpc1Db->getPriority($label); 142 $czarDb->setLabelPriority($label, $priority); 143 } 144 145 updateAllStages($thisServer, $newState, $labels, $begin, $end); 146 createPlots($thisServer, $labels, $begin, $end); 161 147 } 162 163 $czarDb->insertNewTimeData($stage, "all_labels", $totalNew, $totalFull, $totalFaults); 164 } 165 166 print "* Generating plots\n"; 167 foreach $row ( @{$rows} ) { 168 my ($label) = @{$row}; 169 170 $czarplot->createTimeSeries($label, undef, $begin, $end); 171 $czarplot->createHistogram($label, $begin, $end); 172 173 #routineChecks($label, "1 HOUR"); 174 } 175 $czarplot->createTimeSeries("all_labels", undef, $begin, $end); 176 $czarplot->createHistogram("all_labels", $begin, $end); 177 foreach $stage (@stages) { 178 179 $czarplot->createTimeSeries("all_labels", $stage, $begin, $end); # TODO must be a neater way... 180 } 148 else { print "* WARNING: no $thisServer labels found in Db\n";} 149 } 150 181 151 print "--------------------------------------------------------------------------\n"; 182 152 print "* Going to sleep\n"; … … 186 156 #sendEmail("roydhenderson\@gmail.com", "roboczar\@ipp.com", "Roboczar update", "Some content"); 187 157 }; 158 } 159 160 ########################################################################### 161 # 162 # Loops through labels and creates time series and histogram plots 163 # 164 ########################################################################### 165 sub createPlots { 166 my ($server, $rows, $begin, $end) = @_; 167 168 my $stage = undef; 169 my $row = undef; 170 171 print "* Generating plots\n"; 172 173 # create plots for each label for each stage 174 foreach $stage (@stages) { 175 foreach $row ( @{$rows} ) { 176 my ($label) = @{$row}; 177 178 chomp($label); 179 $czarplot->createTimeSeries($label, $stage, $begin, $end); 180 } 181 } 182 183 # create plots for each label for all stages 184 foreach $row ( @{$rows} ) { 185 my ($label) = @{$row}; 186 187 $czarplot->createTimeSeries($label, undef, $begin, $end); 188 $czarplot->createHistogram($label, $begin, $end); 189 190 #routineChecks($label, "1 HOUR"); 191 } 192 $czarplot->createTimeSeries("all_".$server."_labels", undef, $begin, $end); 193 $czarplot->createHistogram("all_".$server."_labels", $begin, $end); 194 foreach $stage (@stages) { 195 196 $czarplot->createTimeSeries("all_".$server."_labels", $stage, $begin, $end); # TODO must be a neater way... 197 } 198 } 199 200 ########################################################################### 201 # 202 # Loops through some labels and updates processed/pending/faults in the Db 203 # 204 ########################################################################### 205 sub updateAllStages { 206 my ($labelServer, $newState, $rows, $begin, $end) = @_; 207 208 print "* Updating stage data\n"; 209 my $totalNew = undef; 210 my $totalFaults = undef; 211 my $totalFull = undef; 212 my $stage = undef; 213 my $reverting = 0; 214 my $row = undef; 215 my $new = undef; 216 my $full = undef; 217 my $faults = undef; 218 my $server = undef; 219 my $state = undef; 220 221 foreach $stage (@stages) { 222 223 $server = $pantasks->getServerForThisStage($stage); 224 $pantasks->getRevertStatus($stage, \$reverting); 225 $czarDb->updateRevertStatus($stage, $reverting); 226 227 print "* Checking labels for $stage stage\n"; 228 229 $totalNew=$totalFaults=$totalFull=0; 230 foreach $row ( @{$rows} ) { 231 my ($label) = @{$row}; 232 233 chomp($label); 234 235 $new = $gpc1Db->countExposures($label, $stage, $newState); 236 $full = $gpc1Db->countExposures($label, $stage, "full"); 237 $faults = $gpc1Db->countFaults($label, $stage, $newState); 238 239 #printf("%s %s, %s, %d, %d\n", $labelServer, $label, $stage, $new, $faults); 240 $totalNew += $new; 241 $totalFull += $full; 242 $totalFaults += $faults; 243 244 $czarDb->insertNewTimeData($stage, $label, $new, $full, $faults); 245 } 246 247 $czarDb->insertNewTimeData($stage, "all_".$labelServer."_labels", $totalNew, $totalFull, $totalFaults); 248 } 188 249 } 189 250
Note:
See TracChangeset
for help on using the changeset viewer.
