Changeset 28705 for trunk/ippMonitor/raw/czartool_labels.php
- Timestamp:
- Jul 23, 2010, 2:55:23 PM (16 years ago)
- File:
-
- 1 edited
-
trunk/ippMonitor/raw/czartool_labels.php (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippMonitor/raw/czartool_labels.php
r28625 r28705 3 3 include 'site.php'; 4 4 5 $ID = checkID ();5 $ID = checkID(); 6 6 7 7 // require an explicit project 8 8 if (! $ID['proj']) { projectform ($ID); } 9 9 10 $db = dbconnect($ID['proj']); 10 //$db = dbconnect($ID['proj']); 11 $czardb = dbconnect("czardb"); // HACK to connect to czarDb 12 $gpc1db = dbconnect($ID['proj']); 13 11 14 $PATH = getenv("PATH"); 12 15 putenv("PATH=$BINDIR:$PATH"); … … 17 20 18 21 if ($ID['menu']) {$myMenu = $ID['menu'];} 19 else {$myMenu = "ipp. czartool.dat";}22 else {$myMenu = "ipp.imfiles.dat";} 20 23 21 24 menu($myMenu, 'Czartool', 'ipp.css', $ID['link'], $ID['proj']); … … 35 38 36 39 if ($revertStage != "" && $revertMode != "" && $revertServer != "" ) 37 exec("czartool_revert.pl -s $revertServer -t $revertStage -o $revertMode", $revertOnOff, $status);40 exec("czartool_revert.pl -s $revertServer -t $revertStage -o $revertMode", $revertOnOff, $status); 38 41 39 42 $debug = 0; 40 43 41 exec("czartool_getLabels.pl -s stdscience", $stdsLabels, $status); 42 exec("czartool_getLabels.pl -s distribution", $distLabels, $status); 44 $stdsLabels = getLabels($czardb, "stdscience"); 45 $distLabels = getLabels($czardb, "distribution"); 46 $pubLabels = getLabels($czardb, "publishing"); 43 47 44 48 if ($debug) { … … 50 54 51 55 $states=array("full","new","drop","wait"); 52 $stages=array("chip","camera","fake","warp","stack","diff","magic","destreak","dist"); 56 $stages=array("chip","cam","fake","warp","stack","diff","magic","magicDS","dist"); 57 $servers=array( 58 "addstar", 59 "cleanup", 60 "detrend", 61 "distribution", 62 "pstamp", 63 "update", 64 "publishing", 65 "registration", 66 "replication", 67 "stdscience", 68 "summitcopy"); 53 69 54 70 // set up the form … … 59 75 echo "<input type=\"hidden\" name=\"menu\" value=\"$menu\">\n"; 60 76 echo "</form>\n"; 61 $stateChosen = 0; 62 foreach ($states as &$state) { 63 64 if ($userSelection == $state) { 65 showAllLabels($pass, $proj, $db, $stdsLabels, $distLabels, $stages, $states, $state); 66 $stateChosen=1; 67 break; 68 } 69 } 70 71 if (!$stateChosen) showOneLabel($pass, $proj, $db, $userSelection, $stages, $states); 77 $lastUpdateTime = getLastUpdateTime($czardb); 78 echo "<p align=\"center\"> Current status of pantasks servers and stdscience labels (any faults are shown in parentheses)<br>"; 79 echo "NOTE: This data is good as of: $lastUpdateTime </p>"; 80 81 createLabelsTable($pass, $proj, $czardb, $stdsLabels, $distLabels, $pubLabels, $stages, $states, "new"); 82 83 echo "<table>\n"; 84 echo "<tr>\n"; 85 echo "<td style=\"width: 50%;\">\n"; 86 87 $today = date("Y-m-d"); // 03.10.01 88 showSummitData($gpc1db, $today); 89 90 echo "</td>\n"; 91 echo "<td> \n"; 92 93 createServersTable($pass, $proj,$czardb, $servers); 94 95 echo "</td?\n"; 96 echo "</tr>\n"; 97 echo "</table>\n"; 72 98 73 99 menu_end(); … … 76 102 ########################################################################### 77 103 # 78 # Checks one label and prints results in a table 79 # 80 ########################################################################### 81 function showOneLabel($pass, $proj, $db, $label, $stages, $states) { 82 83 echo "<p> Current status for label '$label' (any faults are shown in parentheses) </p>"; 104 # Checks summitExp table agains rawExp table 105 # 106 ########################################################################### 107 function showSummitData($gpc1db, $date) { 108 109 echo "<p> Status of summit data since $date:</p>"; 110 111 112 $sql = "SELECT DISTINCT exp_type FROM summitExp WHERE dateobs > '$date'"; 113 114 $qry = $gpc1db->query($sql); 115 if (dberror($qry)) { 116 echo "<b>error reading newExp table</b><br>\n"; 117 echo "<br><small><b> table query : $sql </b></small><br>\n"; 118 menu_end(); 119 } 120 121 // set up the table 122 echo "<table class=list>\n"; 123 echo "<tr><td></td>\n"; 124 write_header_cell ("list", "Exposure type"); 125 write_header_cell ("list", "At summit"); 126 write_header_cell ("list", "Registered at MHPCC"); 127 128 $msg = "No science images taken since $date"; 129 130 // list the results 131 while ($qry->fetchInto($expType)) { 132 133 $sql = "SELECT COUNT(*) FROM summitExp WHERE dateobs > '$date' AND exp_type = '$expType[0]'"; 134 $qry2 = $gpc1db->query($sql); 135 $qry2->fetchInto($summit); 136 $sql = "SELECT COUNT(*) FROM summitExp JOIN rawExp ON summitExp.exp_name = rawExp.exp_name WHERE summitExp.dateobs > '$date' AND summitExp.exp_type = '$expType[0]'"; 137 $qry2 = $gpc1db->query($sql); 138 $qry2->fetchInto($mhpcc); 139 140 $class = "list"; 141 echo "<tr><td></td>\n"; 142 143 if ($expType[0] == "OBJECT") { 144 if ($summit[0] == $mhpcc[0]) $msg = "All science exposures taken since $date have been registered at MHPCC"; 145 else $msg = "Warning: Not all science exposures taken since $date have been registered at MHPCC"; 146 } 147 148 write_table_cell ($class, '%s', "", $expType[0]); 149 write_table_cell ($class, '%d', "", $summit[0]); 150 write_table_cell ($class, '%d', $link, $mhpcc[0]); 151 echo "</tr>\n"; 152 } 153 154 echo "</table>\n"; 155 156 echo "<p> $msg </p>"; 157 158 } 159 160 ########################################################################### 161 # 162 # Gets labels for this server 163 # 164 ########################################################################### 165 function getLabels($db, $server) { 166 167 $sql = "SELECT label FROM current_labels WHERE server LIKE '$server'"; 168 if ($debug) {echo "$sql<br>";} 169 170 $qry = $db->query($sql); 171 if (dberror($qry)) {echo "<b>error with $sql </b><br>\n";} 172 while ($qry->fetchInto($row)) { 173 174 $labels[] = $row[0]; 175 } 176 177 return $labels; 178 } 179 180 ########################################################################### 181 # 182 # Creates table for all labels showing all stages for given 'state' 183 # 184 ########################################################################### 185 function createLabelsTable($pass, $proj, $db, $stdsLabels, $distLabels, $pubLabels, $stages, $states, $selectedState) { 186 187 // set up table columns 188 $class = "list"; 189 echo "<table class=$class >\n"; 190 echo "<tr><td></td>\n"; 191 192 write_header_cell($class, ""); 193 write_header_cell($class, ""); 194 write_header_cell($class, "Reverts:"); 195 foreach ($stages as &$stage) { 196 197 $revertOnOff=array(); 198 if ($stage == "destreak" or $stage == "dist") $server = "distribution"; 199 else $server = "stdscience"; 200 $reverting = getRevertStatus($db, $stage); 201 $link = "czartool_labels.php?pass=" . $pass . "&proj=" . $proj . "&server=" . $server . "&stage=" . $stage . "&revert="; 202 if(!$reverting) {$label = "Start";$link = $link . "on";} 203 if($reverting) {$label = "Stop";$link = $link . "off";} 204 unset($reverting); 205 write_table_cell($class, '%s', $link, $label); 206 } 207 208 echo "</tr>\n"; 209 echo "<tr><td></td>\n"; 210 write_header_cell($class, "label"); 211 write_header_cell($class, "distributing?"); 212 write_header_cell($class, "publishing?"); 213 foreach ($stages as &$stage) write_header_cell($class, $stage); 214 215 echo "</tr>\n"; 216 echo "<tr><td></td>\n"; 217 218 // write rows 219 foreach ($stdsLabels as &$stdsLabel) { 220 221 $distributing = false; 222 $publishing = false; 223 foreach ($distLabels as &$distLabel) { 224 225 if ($stdsLabel == $distLabel) { $distributing = true; break;} 226 } 227 foreach ($pubLabels as &$pubLabel) { 228 229 if ($stdsLabel == $pubLabel) { $publishing = true; break;} 230 } 231 232 // create link to label summary page for each label 233 //$link = "czartool_labels.php?pass=" . $pass . "&proj=" . $proj . "&selection=" . $stdsLabel; 234 $link = ""; 235 $defaultlink = "czartool_labels.php?pass=" . $pass . "&proj=" . $proj; 236 237 echo "<tr><td></td>\n"; 238 write_table_cell($class, '%s', $link, $stdsLabel); 239 write_table_cell($class, '%s', "", $distributing ? "yes" : "NO"); 240 write_table_cell($class, '%s', "", $publishing ? "yes" : "NO"); 241 242 $str = ""; 243 $anyFaults = false; 244 245 $link = "chipProcessedImfile_failure.php?pass=" . $pass . "&proj=" . $proj . "&chipRun.label=" . $stdsLabel . "&chipRun.state=new"; 246 getStateAndFaults($db, $stdsLabel, $selectedState, "chip", $str, $anyFaults); 247 write_table_cell($class, '%s', $anyFaults ? $link : "", $str); 248 249 $link = "camProcessedExp_failure.php?pass=" . $pass . "&proj=" . $proj . "&camRun.label=" . $stdsLabel . "&camRun.state=new"; 250 getStateAndFaults($db, $stdsLabel, $selectedState, "cam", $str, $anyFaults); 251 write_table_cell($class, '%s', $anyFaults ? $link : "", $str); 252 253 $link = $defaultlink; 254 getStateAndFaults($db, $stdsLabel, $selectedState, "fake", $str, $anyFaults); 255 write_table_cell($class, '%s', $anyFaults ? $link : "", $str); 256 257 $link = "warpFailedSkyfiles.php?pass=" . $pass . "&proj=" . $proj . "&warpRun.label=" . $stdsLabel . "&warpRun.state=new"; 258 getStateAndFaults($db, $stdsLabel, $selectedState, "warp", $str, $anyFaults); 259 write_table_cell($class, '%s', $anyFaults ? $link : "", $str); 260 261 $link = "stackFailedSkyfile.php?pass=" . $pass . "&proj=" . $proj . "&stackRun.label=" . $stdsLabel . "&stackRun.state=new"; 262 getStateAndFaults($db, $stdsLabel, $selectedState, "stack", $str, $anyFaults); 263 write_table_cell($class, '%s', $anyFaults ? $link : "", $str); 264 265 $link = "diffFailedSkyfile.php?pass=" . $pass . "&proj=" . $proj . "&diffRun.label=" . $stdsLabel . "&diffRun.state=new"; 266 getStateAndFaults($db, $stdsLabel, $selectedState, "diff", $str, $anyFaults); 267 write_table_cell($class, '%s', $anyFaults ? $link : "", $str); 268 269 $link = $defaultlink; 270 getStateAndFaults($db, $stdsLabel, $selectedState, "magic", $str, $anyFaults); 271 write_table_cell($class, '%s', $anyFaults ? $link : "", $str); 272 273 $link = $defaultlink; 274 getStateAndFaults($db, $stdsLabel, $selectedState, "magicDS", $str, $anyFaults); 275 write_table_cell($class, '%s', $anyFaults ? $link : "", $str); 276 277 $link = $defaultlink; 278 getStateAndFaults($db, $stdsLabel, $selectedState, "dist", $str, $anyFaults); 279 write_table_cell($class, '%s', $anyFaults ? $link : "", $str); 280 281 echo "</tr>\n"; 282 } 283 284 echo "</tr>\n"; 285 echo "</table>\n"; 286 287 echo "<p> - Click on a fault to find logfile<br>"; 288 echo "- Click on column header to turn reverts on or off </p>"; 289 } 290 291 ########################################################################### 292 # 293 # Returns whether this stage is reverting or not 294 # 295 ########################################################################### 296 function getRevertStatus($db, $stage) { 297 298 $anyFaults = false; 299 $sql = "SELECT reverting FROM $stage ORDER BY timestamp DESC LIMIT 1"; 300 if ($debug) {echo "$sql<br>";} 301 302 $qry = $db->query($sql); 303 if (dberror($qry)) {echo "<b>error with $sql </b><br>\n";} 304 $qry->fetchInto($row); 305 306 return $row[0]; 307 } 308 309 ########################################################################### 310 # 311 # Returns state and fault-count (if new) as a string 312 # 313 ########################################################################### 314 function getStateAndFaults($db, $label, $state, $stage, &$str, &$anyFaults) { 315 316 $anyFaults = false; 317 $sql = "SELECT pending, faults FROM $stage WHERE label LIKE '$label' ORDER BY timestamp DESC LIMIT 1"; 318 if ($debug) {echo "$sql<br>";} 319 320 $qry = $db->query($sql); 321 if (dberror($qry)) {echo "<b>error with $sql </b><br>\n";} 322 $qry->fetchInto($row); 323 324 $pending = $row[0]; 325 $faults = $row[1]; 326 327 $str = "$pending"; 328 329 if ($state == "new") { 330 331 if ($faults > 0) { 332 333 $str = $str."(".$faults.")"; 334 $anyFaults = true; 335 } 336 } 337 } 338 339 ########################################################################### 340 # 341 # Checks the status of all the pantasks servers 342 # 343 ########################################################################### 344 function createServersTable($pass, $proj, $db, $servers) { 84 345 85 346 // set up table columns … … 87 348 echo "<table class=$class>\n"; 88 349 echo "<tr><td></td>\n"; 89 write_header_cell($class, "state"); 90 foreach ($stages as &$stage) {write_header_cell($class, $stage);} 350 write_header_cell($class, "Server"); 351 write_header_cell($class, "Alive?"); 352 write_header_cell($class, "Scheduler running?"); 91 353 echo "</tr>\n"; 92 354 93 // write rows 94 foreach ($states as &$state) { 95 96 $link = "czartool_labels.php?pass=" . $pass . "&proj=" . $proj . "&selection=" . $state; 97 $defaultlink = "czartool_labels.php?pass=" . $pass . "&proj=" . $proj; 355 foreach ($servers as &$server) { 356 357 //$link = "czartool_servers.php?pass=" . $pass . "&proj=" . $proj . "&server=" . $server; 358 $link = ""; 359 360 getServerStatus($db, $server, $alive, $running); 98 361 99 362 echo "<tr><td></td>\n"; 100 write_table_cell($class, '%s', $link, $state); 101 102 $str = ""; 103 $anyFaults = false; 104 $link = "chipProcessedImfile_failure.php?pass=" . $pass . "&proj=" . $proj . "&chipRun.label=" . $label . "&chipRun.state=new"; 105 getStateAndFaults($db, $label,"chipRun", $state, "chip", $str, $anyFaults); 106 write_table_cell($class, '%s', $anyFaults ? $link : "", $str); 107 108 $link = "camProcessedExp_failure.php?pass=" . $pass . "&proj=" . $proj . "&camRun.label=" . $label . "&camRun.state=new"; 109 getStateAndFaults($db, $label,"camRun", $state, "cam", $str, $anyFaults); 110 write_table_cell($class, '%s', $anyFaults ? $link : "", $str); 111 112 $link = $defaultlink; 113 getStateAndFaults($db, $label,"fakeRun", $state, "fake", $str, $anyFaults); 114 write_table_cell($class, '%s', $anyFaults ? $link : "", $str); 115 116 $link = "warpFailedSkyfiles.php?pass=" . $pass . "&proj=" . $proj . "&warpRun.label=" . $label . "&warpRun.state=new"; 117 getStateAndFaults($db, $label,"warpRun", $state, "warp", $str, $anyFaults); 118 write_table_cell($class, '%s', $anyFaults ? $link : "", $str); 119 120 $link = "stackFailedSkyfile.php?pass=" . $pass . "&proj=" . $proj . "&stackRun.label=" . $label . "&stackRun.state=new"; 121 getStateAndFaults($db, $label,"stackRun", $state, "stack", $str, $anyFaults); 122 write_table_cell($class, '%s', $anyFaults ? $link : "", $str); 123 124 $link = "diffFailedSkyfile.php?pass=" . $pass . "&proj=" . $proj . "&diffRun.label=" . $label . "&diffRun.state=new"; 125 getStateAndFaults($db, $label,"diffRun", $state, "diff", $str, $anyFaults); 126 write_table_cell($class, '%s', $anyFaults ? $link : "", $str); 127 128 $link = $defaultlink; 129 getStateAndFaults($db, $label,"magicRun", $state, "magic", $str, $anyFaults); 130 write_table_cell($class, '%s', $anyFaults ? $link : "", $str); 131 132 $link = $defaultlink; 133 getStateAndFaults($db, $label,"magicDSRun", $state, "magicDS", $str, $anyFaults); 134 write_table_cell($class, '%s', $anyFaults ? $link : "", $str); 135 136 $link = $defaultlink; 137 getStateAndFaults($db, $label,"distRun", $state, "dist", $str, $anyFaults); 138 write_table_cell($class, '%s', $anyFaults ? $link : "", $str); 139 363 write_table_cell($class, '%s', $link, $server); 364 write_table_cell($class, '%s', "", $alive ? "yes" : "NO"); 365 write_table_cell($class, '%s', "", $running ? "yes" : "NO"); 140 366 echo "</tr>\n"; 141 367 } 142 368 143 369 echo "</table>\n"; 144 145 echo "<p> - Click on a state to see all labels for that state <br>";146 echo "- Click on a fault to find logfile </p>";147 }148 149 ###########################################################################150 #151 # Creates table for all labels showing all stages for given 'state'152 #153 ###########################################################################154 function showAllLabels($pass, $proj, $db, $stdsLabels, $distLabels, $stages, $states, $selectedState) {155 156 echo "<p> Current stdscience labels for '$selectedState' (any faults are shown in parentheses)</p>";157 158 // set up table columns159 $class = "list";160 echo "<table class=$class >\n";161 echo "<tr><td></td>\n";162 163 write_header_cell($class, "");164 write_header_cell($class, "");165 foreach ($stages as &$stage) {166 167 $revertOnOff=array();168 if ($stage == "destreak" or $stage == "dist") $server = "distribution";169 else $server = "stdscience";170 exec("czartool_revert.pl -s $server -t $stage", $revertOnOff, $status);171 $link = "czartool_labels.php?pass=" . $pass . "&proj=" . $proj . "&server=" . $server . "&stage=" . $stage . "&revert=";172 if($revertOnOff[0] == "off") {$label = "Start reverts";$link = $link . "on";}173 if($revertOnOff[0] == "on") {$label = "Stop reverts";$link = $link . "off";}174 unset($revertOnOff);175 write_table_cell($class, '%s', $link, $label);176 }177 178 echo "</tr>\n";179 echo "<tr><td></td>\n";180 write_header_cell($class, "label");181 write_header_cell($class, "distributing?");182 foreach ($stages as &$stage) write_header_cell($class, $stage);183 184 echo "</tr>\n";185 echo "<tr><td></td>\n";186 187 // write rows188 foreach ($stdsLabels as &$stdsLabel) {189 190 $distributing = false;191 foreach ($distLabels as &$distLabel) {192 193 if ($stdsLabel == $distLabel) { $distributing = true; break;}194 }195 196 // create link to label summary page for each label197 $link = "czartool_labels.php?pass=" . $pass . "&proj=" . $proj . "&selection=" . $stdsLabel;198 $defaultlink = "czartool_labels.php?pass=" . $pass . "&proj=" . $proj;199 200 echo "<tr><td></td>\n";201 write_table_cell($class, '%s', $link, $stdsLabel);202 write_table_cell($class, '%s', "", $distributing ? "yes" : "NO");203 204 $str = "";205 $anyFaults = false;206 207 $link = "chipProcessedImfile_failure.php?pass=" . $pass . "&proj=" . $proj . "&chipRun.label=" . $stdsLabel . "&chipRun.state=new";208 getStateAndFaults($db, $stdsLabel,"chipRun", $selectedState, "chip", $str, $anyFaults);209 write_table_cell($class, '%s', $anyFaults ? $link : "", $str);210 211 $link = "camProcessedExp_failure.php?pass=" . $pass . "&proj=" . $proj . "&camRun.label=" . $stdsLabel . "&camRun.state=new";212 getStateAndFaults($db, $stdsLabel,"camRun", $selectedState, "cam", $str, $anyFaults);213 write_table_cell($class, '%s', $anyFaults ? $link : "", $str);214 215 $link = $defaultlink;216 getStateAndFaults($db, $stdsLabel,"fakeRun", $selectedState, "fake", $str, $anyFaults);217 write_table_cell($class, '%s', $anyFaults ? $link : "", $str);218 219 $link = "warpFailedSkyfiles.php?pass=" . $pass . "&proj=" . $proj . "&warpRun.label=" . $stdsLabel . "&warpRun.state=new";220 getStateAndFaults($db, $stdsLabel,"warpRun", $selectedState, "warp", $str, $anyFaults);221 write_table_cell($class, '%s', $anyFaults ? $link : "", $str);222 223 $link = "stackFailedSkyfile.php?pass=" . $pass . "&proj=" . $proj . "&stackRun.label=" . $stdsLabel . "&stackRun.state=new";224 getStateAndFaults($db, $stdsLabel,"stackRun", $selectedState, "stack", $str, $anyFaults);225 write_table_cell($class, '%s', $anyFaults ? $link : "", $str);226 227 $link = "diffFailedSkyfile.php?pass=" . $pass . "&proj=" . $proj . "&diffRun.label=" . $stdsLabel . "&diffRun.state=new";228 getStateAndFaults($db, $stdsLabel,"diffRun", $selectedState, "diff", $str, $anyFaults);229 write_table_cell($class, '%s', $anyFaults ? $link : "", $str);230 231 $link = $defaultlink;232 getStateAndFaults($db, $stdsLabel,"magicRun", $selectedState, "magic", $str, $anyFaults);233 write_table_cell($class, '%s', $anyFaults ? $link : "", $str);234 235 $link = $defaultlink;236 getStateAndFaults($db, $stdsLabel,"magicDSRun", $selectedState, "magicDS", $str, $anyFaults);237 write_table_cell($class, '%s', $anyFaults ? $link : "", $str);238 239 $link = $defaultlink;240 getStateAndFaults($db, $stdsLabel,"distRun", $selectedState, "dist", $str, $anyFaults);241 write_table_cell($class, '%s', $anyFaults ? $link : "", $str);242 243 echo "</tr>\n";244 }245 246 echo "</tr>\n";247 echo "</table>\n";248 249 echo "<p> - Click on a label to see all states for that label (full, new, drop etc)<br>";250 echo "- Click on a fault to find logfile<br>";251 echo "- Click on column header to turn reverts on or off </p>";252 370 } 253 371 … … 257 375 # 258 376 ########################################################################### 259 function getStateAndFaults($db, $label, $table, $state, $stage, &$str, &$anyFaults) { 260 261 $anyFaults = false; 262 263 $str = checkLabel($db, $label, $table, $state, $stage); 264 265 if ($state == "new") { 266 267 $faults = countFaults($db, $label,$table,$stage); 268 269 if ($faults > 0) { 270 271 $str = $str."(".$faults.")"; 272 $anyFaults = true; 273 } 274 } 275 } 276 277 ########################################################################### 278 # 279 # Returns count of exposures with this state for this label 280 # 281 ########################################################################### 282 function checkLabel($db, $label, $table, $state, $stage) { 283 284 $sql = "SELECT COUNT(state) FROM $table WHERE label LIKE '$label' AND state = '$state'"; 285 if ($debug) {echo "$sql<br>";} 377 function getServerStatus($db, $server, &$alive, &$running) { 378 379 $sql = "SELECT alive, running FROM servers WHERE server LIKE '$server' ORDER BY timestamp DESC LIMIT 1"; 380 if($debug){echo "$sql<br>";} 286 381 287 382 $qry = $db->query($sql); 288 383 if (dberror($qry)) {echo "<b>error with $sql </b><br>\n";} 289 if (!$qry->fetchInto($row)) {echo "<b>error with $sql </b><br>\n";} 290 return $row[0]; 291 } 292 293 ########################################################################### 294 # 295 # Returns count of faults for this stage and label 296 # 297 ########################################################################### 298 function countFaults($db, $label, $table, $stage) { 299 300 $joinTable = 0; 301 $id = $stage."_id"; 302 303 if ($stage == "chip") {$joinTable="chipProcessedImfile";} 304 elseif ($stage == "cam") {$joinTable="camProcessedExp";} 305 elseif ($stage == "fake") {$joinTable="fakeProcessedImfile";} 306 elseif ($stage == "warp") {$joinTable="warpSkyfile";} 307 elseif ($stage == "stack") {$joinTable="stackSumSkyfile";} 308 elseif ($stage == "diff") {$joinTable="diffSkyfile";} 309 elseif ($stage == "magic") {$joinTable="magicNodeResult";} 310 elseif ($stage == "magicDS") {$id = "magic_ds_id"; $joinTable="magicDSFile";} 311 elseif ($stage == "dist") {$joinTable="distComponent";} 312 else {return -1;} 313 314 $faultCol = $joinTable.".fault"; 315 316 $sql = "SELECT COUNT(DISTINCT $id) FROM $table JOIN $joinTable USING ($id) WHERE label LIKE '$label' AND $faultCol != 0 AND $table.state = 'new'"; 384 $qry->fetchInto($row); 385 386 $alive = $row[0]; 387 $running = $row[1]; 388 } 389 390 ########################################################################### 391 # 392 # Returns time of last czarDb update 393 # 394 ########################################################################### 395 function getLastUpdateTime($db) { 396 397 $anyFaults = false; 398 $sql = "SELECT timestamp FROM chip ORDER BY timestamp DESC LIMIT 1"; 317 399 if ($debug) {echo "$sql<br>";} 318 400 319 401 $qry = $db->query($sql); 320 402 if (dberror($qry)) {echo "<b>error with $sql </b><br>\n";} 321 if (!$qry->fetchInto($row)) {echo "<b>error with $sql </b><br>\n";} 403 $qry->fetchInto($row); 404 322 405 return $row[0]; 323 406 } 407 408 409 324 410 ?> 325 411
Note:
See TracChangeset
for help on using the changeset viewer.
