- Timestamp:
- Jul 30, 2010, 9:31:50 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20100621/ippMonitor/raw/czartool_labels.php
r28167 r28794 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 14 $PATH = getenv("PATH"); 15 putenv("PATH=$BINDIR:$PATH"); 16 17 $LD_LIBRARY_PATH = getenv("LD_LIBRARY_PATH"); 18 putenv("LD_LIBRARY_PATH=$LIBDIR:$LD_LIBRARY_PATH"); 19 11 20 12 21 if ($ID['menu']) {$myMenu = $ID['menu'];} 13 else {$myMenu = "ipp. czartool.dat";}22 else {$myMenu = "ipp.imfiles.dat";} 14 23 15 24 menu($myMenu, 'Czartool', 'ipp.css', $ID['link'], $ID['proj']); … … 19 28 $menu = $ID['menu']; 20 29 21 $userSelection = $_GET[selection]; 22 23 if ($userSelection == "") {$userSelection = $_POST['state'];} 24 if ($userSelection == "") {$userSelection = "new";} 25 30 $selectedStage = $_GET[stage]; 31 $selectedLabel = $_GET[label]; 32 $selectedServer = $_GET[server]; 33 $selectedRevertServer = $_GET[revertserver]; 34 $selectedRevertStage = $_GET[revertstage]; 35 $selectedRevertMode = $_GET[revertmode]; 36 37 if ($selectedLabel == "") $selectedLabel = "all_labels"; 38 if ($selectedStage == "") $selectedStage = "all_stages"; 39 40 // deal with reverts: turn on or off if requested and pass current revert state for this stage onto labels table later 41 $currentRevertMode; 42 if ($selectedRevertStage != "" && $selectedRevertMode != "" && $selectedRevertServer != "" ) { 43 44 exec("czartool_revert.pl -s $selectedRevertServer -t $selectedRevertStage -o $selectedRevertMode", $response, $status); 45 if ($response[0] == "off") $currentRevertMode = 0; 46 else if ($response[0] == "on") $currentRevertMode = 1; 47 } 26 48 $debug = 0; 27 49 28 $PATH = getenv("PATH"); 29 putenv("PATH=$BINDIR:$PATH"); 30 31 $LD_LIBRARY_PATH = getenv("LD_LIBRARY_PATH"); 32 putenv("LD_LIBRARY_PATH=$LIBDIR:$LD_LIBRARY_PATH"); 33 34 exec("czartool_getLabels.pl -s stdscience", $stdsLabels, $status); 35 exec("czartool_getLabels.pl -s distribution", $distLabels, $status); 50 $stdsLabels = getLabels($czardb, "stdscience"); 51 $distLabels = getLabels($czardb, "distribution"); 52 $pubLabels = getLabels($czardb, "publishing"); 36 53 37 54 if ($debug) { … … 43 60 44 61 $states=array("full","new","drop","wait"); 45 $stages=array("chip","cam","fake","warp","stack","diff","magic","destreak","dist"); 62 $stages=array("chip","cam","fake","warp","stack","diff","magic","magicDS","dist"); 63 $servers=array( 64 "addstar", 65 "cleanup", 66 "detrend", 67 "distribution", 68 "pstamp", 69 "update", 70 "publishing", 71 "registration", 72 "replication", 73 "stdscience", 74 "summitcopy"); 46 75 47 76 // set up the form … … 52 81 echo "<input type=\"hidden\" name=\"menu\" value=\"$menu\">\n"; 53 82 echo "</form>\n"; 54 $stateChosen = 0; 55 foreach ($states as &$state) { 56 57 if ($userSelection == $state) { 58 showAllLabels($pass, $proj, $db, $stdsLabels, $distLabels, $stages, $states, $state); 59 $stateChosen=1; 60 break; 61 } 62 } 63 64 if (!$stateChosen) showOneLabel($pass, $proj, $db, $userSelection, $stages, $states); 83 $lastUpdateTime = getLastUpdateTime($czardb); 84 echo "<p align=\"center\"> Current status of IPP (any faults are shown in parentheses). NOTE: This data is good as of: $lastUpdateTime </p>"; 85 86 echo "<table>\n"; 87 echo "<tr>\n"; 88 89 echo "<td> \n"; 90 echo "<img src=\"czartool_getplot.php?type=t&label=$selectedLabel&stage=$selectedStage\"><br>\n"; 91 echo "</td>\n"; 92 93 echo "<td> \n"; 94 createLabelsTable($pass, $proj, $czardb, $stdsLabels, $distLabels, $pubLabels, $stages, $states, "new", $selectedLabel, $selectedStage, $selectedRevertStage, $currentRevertMode); 95 echo "</td>\n"; 96 97 echo "</tr>\n"; 98 echo "<tr>\n"; 99 100 echo "<table>\n"; 101 echo "<tr valign=top>\n"; 102 echo "<td> \n"; 103 echo "<img src=\"czartool_getplot.php?type=h&label=$selectedLabel&stage=$selectedStage\"><br>\n"; 104 echo "</td>\n"; 105 echo "<td> \n"; 106 createServersTable($pass, $proj,$czardb, $servers, $selectedLabel, $selectedStage); 107 echo "</td>\n"; 108 109 echo "<td> \n"; 110 $today = date("Y-m-d"); // 03.10.01 111 showSummitData($gpc1db, $today); 112 echo "</td>\n"; 113 echo "</tr>\n"; 114 echo "</table>\n"; 115 if ($selectedServer) showServerStatus($selectedServer); 116 117 echo "</tr>\n"; 118 echo "</table>\n"; 119 65 120 66 121 menu_end(); … … 69 124 ########################################################################### 70 125 # 71 # Checks one label and prints results in a table 72 # 73 ########################################################################### 74 function showOneLabel($pass, $proj, $db, $label, $stages, $states) { 75 76 echo "<p> Current status for label '$label' (any faults are shown in parentheses) </p>"; 126 # Checks summitExp table agains rawExp table 127 # 128 ########################################################################### 129 function showSummitData($gpc1db, $date) { 130 131 $sql = "SELECT DISTINCT exp_type FROM summitExp WHERE dateobs > '$date'"; 132 133 $qry = $gpc1db->query($sql); 134 if (dberror($qry)) { 135 echo "<b>error reading newExp table</b><br>\n"; 136 echo "<br><small><b> table query : $sql </b></small><br>\n"; 137 menu_end(); 138 } 139 140 // set up the table 141 echo "<table class=list>\n"; 142 echo "<tr><td></td>\n"; 143 write_header_cell ("list", "Exposure type"); 144 write_header_cell ("list", "At summit"); 145 write_header_cell ("list", "Registered at MHPCC"); 146 147 $msg = "No science images taken since $date"; 148 149 // list the results 150 while ($qry->fetchInto($expType)) { 151 152 $sql = "SELECT COUNT(*) FROM summitExp WHERE dateobs > '$date' AND exp_type = '$expType[0]'"; 153 $qry2 = $gpc1db->query($sql); 154 $qry2->fetchInto($summit); 155 $sql = "SELECT COUNT(*) FROM summitExp JOIN rawExp ON summitExp.exp_name = rawExp.exp_name WHERE summitExp.dateobs > '$date' AND summitExp.exp_type = '$expType[0]'"; 156 $qry2 = $gpc1db->query($sql); 157 $qry2->fetchInto($mhpcc); 158 159 $class = "list"; 160 echo "<tr><td></td>\n"; 161 162 if ($expType[0] == "OBJECT") { 163 if ($summit[0] == $mhpcc[0]) $msg = "All science exposures taken since $date<br>have been registered at MHPCC"; 164 else $msg = "Warning: Not all science exposures taken since $date<br>have been registered at MHPCC"; 165 } 166 167 write_table_cell ($class, '%s', "", $expType[0]); 168 write_table_cell ($class, '%d', "", $summit[0]); 169 write_table_cell ($class, '%d', $link, $mhpcc[0]); 170 echo "</tr>\n"; 171 } 172 173 echo "</table>\n"; 174 175 echo "<p> $msg </p>"; 176 177 } 178 179 ########################################################################### 180 # 181 # Gets labels for this server 182 # 183 ########################################################################### 184 function getLabels($db, $server) { 185 186 # order by descending priority as set in gpc1 database 187 $sql = "SELECT label FROM current_labels WHERE server LIKE '$server' ORDER BY priority DESC"; 188 if ($debug) {echo "$sql<br>";} 189 190 $qry = $db->query($sql); 191 if (dberror($qry)) {echo "<b>error with $sql </b><br>\n";} 192 while ($qry->fetchInto($row)) { 193 194 $labels[] = $row[0]; 195 } 196 197 return $labels; 198 } 199 200 ########################################################################### 201 # 202 # Creates table for all labels showing all stages for given 'state' 203 # 204 ########################################################################### 205 function createLabelsTable($pass, $proj, $db, $stdsLabels, $distLabels, $pubLabels, $stages, $states, $selectedState, $selectedLabel, $selectedStage, $selectedRevertStage, $currentRevertMode) { 206 207 // set up table columns 208 $class = "list"; 209 echo "<table class=$class >\n"; 210 echo "<tr><td></td>\n"; 211 212 write_header_cell($class, ""); 213 write_header_cell($class, ""); 214 write_header_cell($class, "Reverts:"); 215 foreach ($stages as &$stage) { 216 217 $revertOnOff=array(); 218 if ($stage == "destreak" or $stage == "dist") $server = "distribution"; 219 else $server = "stdscience"; 220 if ($stage == $selectedRevertStage) $reverting = $currentRevertMode; 221 else $reverting = getRevertStatus($db, $stage); 222 $link = "czartool_labels.php?pass=" . $pass . "&proj=" . $proj . "&revertserver=" . $server . "&revertstage=" . $stage . "&revertmode="; 223 if(!$reverting) {$label = "Start";$link = $link . "on";} 224 if($reverting) {$label = "Stop";$link = $link . "off";} 225 unset($reverting); 226 write_table_cell($class, '%s', $link, $label); 227 } 228 write_header_cell($class, ""); 229 230 echo "</tr>\n"; 231 echo "<tr><td></td>\n"; 232 write_header_cell($class, "Label (in order of priority)"); 233 write_header_cell($class, "Distributing?"); 234 write_header_cell($class, "Publishing?"); 235 foreach ($stages as &$stage) { 236 237 if ($stage == $selectedStage) $link = ""; 238 else $link = "czartool_labels.php?pass=" . $pass . "&proj=" . $proj . "&label=" . $selectedLabel . "&stage=" . $stage; 239 write_table_cell($class, '%s', $link, $stage); 240 } 241 242 if ($selectedStage=="all_stages") $link = ""; 243 else $link = "czartool_labels.php?pass=" . $pass . "&proj=" . $proj . "&label=" . $selectedLabel . "&stage=all_stages"; 244 write_table_cell($class, '%s', $link, "All stages"); 245 246 echo "</tr>\n"; 247 echo "<tr><td></td>\n"; 248 249 $defaultlink = "czartool_labels.php?pass=" . $pass . "&proj=" . $proj; 250 251 // write rows 252 foreach ($stdsLabels as &$stdsLabel) { 253 254 $distributing = false; 255 $publishing = false; 256 foreach ($distLabels as &$distLabel) { 257 258 if ($stdsLabel == $distLabel) { $distributing = true; break;} 259 } 260 foreach ($pubLabels as &$pubLabel) { 261 262 if ($stdsLabel == $pubLabel) { $publishing = true; break;} 263 } 264 265 // create link to label summary page for each label 266 if ($stdsLabel == $selectedLabel) $link = ""; 267 else $link = "czartool_labels.php?pass=" . $pass . "&proj=" . $proj . "&label=" . $stdsLabel . "&stage=" . $selectedStage; 268 269 echo "<tr><td></td>\n"; 270 write_table_cell($class, '%s', $link, $stdsLabel); 271 write_table_cell($class, '%s', "", $distributing ? "yes" : "NO"); 272 write_table_cell($class, '%s', "", $publishing ? "yes" : "NO"); 273 274 $str = ""; 275 $anyFaults = false; 276 277 $link = "chipProcessedImfile_failure.php?pass=" . $pass . "&proj=" . $proj . "&chipRun.label=" . $stdsLabel . "&chipRun.state=new"; 278 getStateAndFaults($db, $stdsLabel, $selectedState, "chip", $str, $anyFaults); 279 write_table_cell($class, '%s', $anyFaults ? $link : "", $str); 280 281 $link = "camProcessedExp_failure.php?pass=" . $pass . "&proj=" . $proj . "&camRun.label=" . $stdsLabel . "&camRun.state=new"; 282 getStateAndFaults($db, $stdsLabel, $selectedState, "cam", $str, $anyFaults); 283 write_table_cell($class, '%s', $anyFaults ? $link : "", $str); 284 285 $link = $defaultlink; 286 getStateAndFaults($db, $stdsLabel, $selectedState, "fake", $str, $anyFaults); 287 write_table_cell($class, '%s', $anyFaults ? $link : "", $str); 288 289 $link = "warpFailedSkyfiles.php?pass=" . $pass . "&proj=" . $proj . "&warpRun.label=" . $stdsLabel . "&warpRun.state=new"; 290 getStateAndFaults($db, $stdsLabel, $selectedState, "warp", $str, $anyFaults); 291 write_table_cell($class, '%s', $anyFaults ? $link : "", $str); 292 293 $link = "stackFailedSkyfile.php?pass=" . $pass . "&proj=" . $proj . "&stackRun.label=" . $stdsLabel . "&stackRun.state=new"; 294 getStateAndFaults($db, $stdsLabel, $selectedState, "stack", $str, $anyFaults); 295 write_table_cell($class, '%s', $anyFaults ? $link : "", $str); 296 297 $link = "diffFailedSkyfile.php?pass=" . $pass . "&proj=" . $proj . "&diffRun.label=" . $stdsLabel . "&diffRun.state=new"; 298 getStateAndFaults($db, $stdsLabel, $selectedState, "diff", $str, $anyFaults); 299 write_table_cell($class, '%s', $anyFaults ? $link : "", $str); 300 301 $link = $defaultlink; 302 getStateAndFaults($db, $stdsLabel, $selectedState, "magic", $str, $anyFaults); 303 write_table_cell($class, '%s', $anyFaults ? $link : "", $str); 304 305 $link = $defaultlink; 306 getStateAndFaults($db, $stdsLabel, $selectedState, "magicDS", $str, $anyFaults); 307 write_table_cell($class, '%s', $anyFaults ? $link : "", $str); 308 309 $link = $defaultlink; 310 getStateAndFaults($db, $stdsLabel, $selectedState, "dist", $str, $anyFaults); 311 write_table_cell($class, '%s', $anyFaults ? $link : "", $str); 312 313 echo "</tr>\n"; 314 } 315 316 if ($selectedLabel == "all_labels") $link = ""; 317 else $link = "czartool_labels.php?pass=" . $pass . "&proj=" . $proj . "&label=all_labels&stage=".$selectedStage; 318 319 echo "<tr><td></td>\n"; 320 write_table_cell($class, '%s', $link, "All labels:"); 321 write_table_cell($class, '%s', "", "-"); 322 write_table_cell($class, '%s', "", "-"); 323 324 $str = ""; 325 $anyFaults = false; 326 327 $link = "chipProcessedImfile_failure.php?pass=" . $pass . "&proj=" . $proj . "&chipRun.state=new"; 328 getStateAndFaults($db, "all_labels", $selectedState, "chip", $str, $anyFaults); 329 write_table_cell($class, '%s', $anyFaults ? $link : "", $str); 330 331 $link = "camProcessedExp_failure.php?pass=" . $pass . "&proj=" . $proj . "&camRun.state=new"; 332 getStateAndFaults($db, "all_labels", $selectedState, "cam", $str, $anyFaults); 333 write_table_cell($class, '%s', $anyFaults ? $link : "", $str); 334 335 $link = $defaultlink; 336 getStateAndFaults($db, "all_labels", $selectedState, "fake", $str, $anyFaults); 337 write_table_cell($class, '%s', $anyFaults ? $link : "", $str); 338 339 $link = "warpFailedSkyfiles.php?pass=" . $pass . "&proj=" . $proj . "&warpRun.state=new"; 340 getStateAndFaults($db, "all_labels", $selectedState, "warp", $str, $anyFaults); 341 write_table_cell($class, '%s', $anyFaults ? $link : "", $str); 342 343 $link = "stackFailedSkyfile.php?pass=" . $pass . "&proj=" . $proj . "&stackRun.state=new"; 344 getStateAndFaults($db, "all_labels", $selectedState, "stack", $str, $anyFaults); 345 write_table_cell($class, '%s', $anyFaults ? $link : "", $str); 346 347 $link = "diffFailedSkyfile.php?pass=" . $pass . "&proj=" . $proj . "&diffRun.state=new"; 348 getStateAndFaults($db, "all_labels", $selectedState, "diff", $str, $anyFaults); 349 write_table_cell($class, '%s', $anyFaults ? $link : "", $str); 350 351 $link = $defaultlink; 352 getStateAndFaults($db, "all_labels", $selectedState, "magic", $str, $anyFaults); 353 write_table_cell($class, '%s', $anyFaults ? $link : "", $str); 354 355 $link = $defaultlink; 356 getStateAndFaults($db, "all_labels", $selectedState, "magicDS", $str, $anyFaults); 357 write_table_cell($class, '%s', $anyFaults ? $link : "", $str); 358 359 $link = $defaultlink; 360 getStateAndFaults($db, "all_labels", $selectedState, "dist", $str, $anyFaults); 361 write_table_cell($class, '%s', $anyFaults ? $link : "", $str); 362 363 364 echo "</tr>\n"; 365 echo "</table>\n"; 366 } 367 368 ########################################################################### 369 # 370 # Returns whether this stage is reverting or not 371 # 372 ########################################################################### 373 function getRevertStatus($db, $stage) { 374 375 $anyFaults = false; 376 $sql = "SELECT reverting FROM $stage ORDER BY timestamp DESC LIMIT 1"; 377 if ($debug) {echo "$sql<br>";} 378 379 $qry = $db->query($sql); 380 if (dberror($qry)) {echo "<b>error with $sql </b><br>\n";} 381 $qry->fetchInto($row); 382 383 return $row[0]; 384 } 385 386 ########################################################################### 387 # 388 # Returns state and fault-count (if new) as a string 389 # 390 ########################################################################### 391 function getStateAndFaults($db, $label, $state, $stage, &$str, &$anyFaults) { 392 393 $anyFaults = false; 394 $sql = "SELECT pending, faults FROM $stage WHERE label LIKE '$label' ORDER BY timestamp DESC LIMIT 1"; 395 if ($debug) {echo "$sql<br>";} 396 397 $qry = $db->query($sql); 398 if (dberror($qry)) {echo "<b>error with $sql </b><br>\n";} 399 $qry->fetchInto($row); 400 401 $pending = $row[0]; 402 $faults = $row[1]; 403 404 $str = "$pending"; 405 406 if ($state == "new") { 407 408 if ($faults > 0) { 409 410 $str = $str."(".$faults.")"; 411 $anyFaults = true; 412 } 413 } 414 } 415 416 ########################################################################### 417 # 418 # Checks the status of all the pantasks servers 419 # 420 ########################################################################### 421 function createServersTable($pass, $proj, $db, $servers, $selectedLabel, $selectedStage) { 77 422 78 423 // set up table columns … … 80 425 echo "<table class=$class>\n"; 81 426 echo "<tr><td></td>\n"; 82 write_header_cell($class, "state"); 83 foreach ($stages as &$stage) {write_header_cell($class, $stage);} 427 write_header_cell($class, "Server"); 428 write_header_cell($class, "Alive?"); 429 write_header_cell($class, "Scheduler running?"); 84 430 echo "</tr>\n"; 85 431 86 // write rows 87 foreach ($states as &$state) { 88 89 $link = "czartool_labels.php?pass=" . $pass . "&proj=" . $proj . "&selection=" . $state; 90 $defaultlink = "czartool_labels.php?pass=" . $pass . "&proj=" . $proj; 432 foreach ($servers as &$server) { 433 434 $link = "czartool_labels.php?pass=".$pass."&proj=".$proj."&server=".$server."&label=".$selectedLabel."&stage=".$selectedStage; 435 // $link = ""; 436 437 getServerStatus($db, $server, $alive, $running); 91 438 92 439 echo "<tr><td></td>\n"; 93 write_table_cell($class, '%s', $link, $state); 94 95 $str = ""; 96 $anyFaults = false; 97 $link = "chipProcessedImfile_failure.php?menu=ipp.science.dat&pass=" . $pass . "&proj=" . $proj . "&label=" . $stdsLabel; 98 getStateAndFaults($db, $label,"chipRun", $state, "chip", $str, $anyFaults); 99 write_table_cell($class, '%s', $anyFaults ? $link : "", $str); 100 101 $link = "camProcessedExp_failure.php?pass=" . $pass . "&proj=" . $proj . "&label=" . $stdsLabel; 102 getStateAndFaults($db, $label,"camRun", $state, "cam", $str, $anyFaults); 103 write_table_cell($class, '%s', $anyFaults ? $link : "", $str); 104 105 $link = $defaultlink; 106 getStateAndFaults($db, $label,"fakeRun", $state, "fake", $str, $anyFaults); 107 write_table_cell($class, '%s', $anyFaults ? $link : "", $str); 108 109 $link = "warpFailedSkyfiles.php?pass=" . $pass . "&proj=" . $proj; 110 getStateAndFaults($db, $label,"warpRun", $state, "warp", $str, $anyFaults); 111 write_table_cell($class, '%s', $anyFaults ? $link : "", $str); 112 113 $link = "stackFailedSkyfile.php?pass=" . $pass . "&proj=" . $proj; 114 getStateAndFaults($db, $label,"stackRun", $state, "stack", $str, $anyFaults); 115 write_table_cell($class, '%s', $anyFaults ? $link : "", $str); 116 117 $link = "diffFailedSkyfile.php?pass=" . $pass . "&proj=" . $proj; 118 getStateAndFaults($db, $label,"diffRun", $state, "diff", $str, $anyFaults); 119 write_table_cell($class, '%s', $anyFaults ? $link : "", $str); 120 121 $link = $defaultlink; 122 getStateAndFaults($db, $label,"magicRun", $state, "magic", $str, $anyFaults); 123 write_table_cell($class, '%s', $anyFaults ? $link : "", $str); 124 125 $link = $defaultlink; 126 getStateAndFaults($db, $label,"magicDSRun", $state, "magicDS", $str, $anyFaults); 127 write_table_cell($class, '%s', $anyFaults ? $link : "", $str); 128 129 $link = $defaultlink; 130 getStateAndFaults($db, $label,"distRun", $state, "dist", $str, $anyFaults); 131 write_table_cell($class, '%s', $anyFaults ? $link : "", $str); 132 440 write_table_cell($class, '%s', $link, $server); 441 write_table_cell($class, '%s', "", $alive ? "yes" : "NO"); 442 write_table_cell($class, '%s', "", $running ? "yes" : "NO"); 133 443 echo "</tr>\n"; 134 444 } 135 445 136 446 echo "</table>\n"; 137 138 echo "<p> - Click on a state to see all labels for that state <br>";139 echo "- Click on a fault to find logfile </p>";140 }141 142 ###########################################################################143 #144 # Creates table for all labels showing all stages for given 'state'145 #146 ###########################################################################147 function showAllLabels($pass, $proj, $db, $stdsLabels, $distLabels, $stages, $states, $selectedState) {148 149 echo "<p> Current stdscience labels for '$selectedState' (any faults are shown in parentheses)</p>";150 151 // set up table columns152 $class = "list";153 //echo "<table class=$class BORDER=\"0\" CELLSPACING=\"0\" CELLPADDING=\"5\">\n";154 echo "<table class=$class >\n";155 echo "<tr><td></td>\n";156 write_header_cell($class, "label");157 write_header_cell($class, "distributing?");158 // echo "<td class=\"$class\"><a href=\"$link\"> $myValue </a></td>\n";159 // echo "<th class=\"$class\"><a href=\"czartool.php\">label</th>\n";160 161 foreach ($stages as &$stage) {write_header_cell($class, $stage);}162 //foreach ($stages as &$stage) {163 164 // $link = "czartool.php?pass=" . $pass . "&proj=" . $proj . "&label=" . $stage;165 // echo "<th class=\"$class\"><a href=\"$link\">$stage</th>\n";166 // }167 168 echo "</tr>\n";169 170 // write rows171 foreach ($stdsLabels as &$stdsLabel) {172 173 $distributing = false;174 foreach ($distLabels as &$distLabel) {175 176 if ($stdsLabel == $distLabel) { $distributing = true; break;}177 }178 179 180 // create link to label summary page for each label181 $link = "czartool_labels.php?pass=" . $pass . "&proj=" . $proj . "&selection=" . $stdsLabel;182 $defaultlink = "czartool_labels.php?pass=" . $pass . "&proj=" . $proj;183 184 echo "<tr><td></td>\n";185 write_table_cell($class, '%s', $link, $stdsLabel);186 write_table_cell($class, '%s', "", $distributing ? "yes" : "NO");187 188 $str = "";189 $anyFaults = false;190 191 $link = "chipProcessedImfile_failure.php?menu=ipp.science.dat&pass=" . $pass . "&proj=" . $proj . "&label=" . $stdsLabel;192 getStateAndFaults($db, $stdsLabel,"chipRun", $selectedState, "chip", $str, $anyFaults);193 write_table_cell($class, '%s', $anyFaults ? $link : "", $str);194 195 $link = "camProcessedExp_failure.php?pass=" . $pass . "&proj=" . $proj . "&label=" . $stdsLabel;196 getStateAndFaults($db, $stdsLabel,"camRun", $selectedState, "cam", $str, $anyFaults);197 write_table_cell($class, '%s', $anyFaults ? $link : "", $str);198 199 $link = $defaultlink;200 getStateAndFaults($db, $stdsLabel,"fakeRun", $selectedState, "fake", $str, $anyFaults);201 write_table_cell($class, '%s', $anyFaults ? $link : "", $str);202 203 $link = "warpFailedSkyfiles.php?pass=" . $pass . "&proj=" . $proj;204 getStateAndFaults($db, $stdsLabel,"warpRun", $selectedState, "warp", $str, $anyFaults);205 write_table_cell($class, '%s', $anyFaults ? $link : "", $str);206 207 $link = "stackFailedSkyfile.php?pass=" . $pass . "&proj=" . $proj;208 getStateAndFaults($db, $stdsLabel,"stackRun", $selectedState, "stack", $str, $anyFaults);209 write_table_cell($class, '%s', $anyFaults ? $link : "", $str);210 211 $link = "diffFailedSkyfile.php?pass=" . $pass . "&proj=" . $proj;212 getStateAndFaults($db, $stdsLabel,"diffRun", $selectedState, "diff", $str, $anyFaults);213 write_table_cell($class, '%s', $anyFaults ? $link : "", $str);214 215 $link = $defaultlink;216 getStateAndFaults($db, $stdsLabel,"magicRun", $selectedState, "magic", $str, $anyFaults);217 write_table_cell($class, '%s', $anyFaults ? $link : "", $str);218 219 $link = $defaultlink;220 getStateAndFaults($db, $stdsLabel,"magicDSRun", $selectedState, "magicDS", $str, $anyFaults);221 write_table_cell($class, '%s', $anyFaults ? $link : "", $str);222 223 $link = $defaultlink;224 getStateAndFaults($db, $stdsLabel,"distRun", $selectedState, "dist", $str, $anyFaults);225 write_table_cell($class, '%s', $anyFaults ? $link : "", $str);226 227 echo "</tr>\n";228 }229 230 echo "</table>\n";231 232 echo "<p> - Click on a label to see all states for that label (full, new, drop etc)<br>";233 echo "- Click on a fault to find logfile </p>";234 447 } 235 448 … … 239 452 # 240 453 ########################################################################### 241 function getStateAndFaults($db, $label, $table, $state, $stage, &$str, &$anyFaults) { 242 243 $anyFaults = false; 244 245 $str = checkLabel($db, $label, $table, $state, $stage); 246 247 if ($state == "new") { 248 249 $faults = countFaults($db, $label,$table,$stage); 250 251 if ($faults > 0) { 252 253 $str = $str."(".$faults.")"; 254 $anyFaults = true; 255 } 256 } 257 } 258 259 ########################################################################### 260 # 261 # Returns count of exposures with this state for this label 262 # 263 ########################################################################### 264 function checkLabel($db, $label, $table, $state, $stage) { 265 266 $sql = "SELECT COUNT(state) FROM $table WHERE label LIKE '$label' AND state = '$state'"; 267 if ($debug) {echo "$sql<br>";} 454 function getServerStatus($db, $server, &$alive, &$running) { 455 456 $sql = "SELECT alive, running FROM servers WHERE server LIKE '$server' ORDER BY timestamp DESC LIMIT 1"; 457 if($debug){echo "$sql<br>";} 268 458 269 459 $qry = $db->query($sql); 270 460 if (dberror($qry)) {echo "<b>error with $sql </b><br>\n";} 271 if (!$qry->fetchInto($row)) {echo "<b>error with $sql </b><br>\n";} 272 return $row[0]; 273 } 274 275 ########################################################################### 276 # 277 # Returns count of faults for this stage and label 278 # 279 ########################################################################### 280 function countFaults($db, $label, $table, $stage) { 281 282 $joinTable = 0; 283 $id = $stage."_id"; 284 285 if ($stage == "chip") {$joinTable="chipProcessedImfile";} 286 elseif ($stage == "cam") {$joinTable="camProcessedExp";} 287 elseif ($stage == "fake") {$joinTable="fakeProcessedImfile";} 288 elseif ($stage == "warp") {$joinTable="warpSkyfile";} 289 elseif ($stage == "stack") {$joinTable="stackSumSkyfile";} 290 elseif ($stage == "diff") {$joinTable="diffSkyfile";} 291 elseif ($stage == "magic") {$joinTable="magicNodeResult";} 292 elseif ($stage == "magicDS") {$id = "magic_ds_id"; $joinTable="magicDSFile";} 293 elseif ($stage == "dist") {$joinTable="distComponent";} 294 else {return -1;} 295 296 $faultCol = $joinTable.".fault"; 297 298 $sql = "SELECT COUNT(DISTINCT $id) FROM $table JOIN $joinTable USING ($id) WHERE label LIKE '$label' AND $faultCol != 0 AND $table.state = 'new'"; 461 $qry->fetchInto($row); 462 463 $alive = $row[0]; 464 $running = $row[1]; 465 } 466 467 ########################################################################### 468 # 469 # Returns time of last czarDb update 470 # 471 ########################################################################### 472 function getLastUpdateTime($db) { 473 474 $anyFaults = false; 475 $sql = "SELECT timestamp FROM chip ORDER BY timestamp DESC LIMIT 1"; 299 476 if ($debug) {echo "$sql<br>";} 300 477 301 478 $qry = $db->query($sql); 302 479 if (dberror($qry)) {echo "<b>error with $sql </b><br>\n";} 303 if (!$qry->fetchInto($row)) {echo "<b>error with $sql </b><br>\n";} 480 $qry->fetchInto($row); 481 304 482 return $row[0]; 305 483 } 484 485 ########################################################################### 486 # 487 # Shows the status of the provided pantasks server 488 # 489 ########################################################################### 490 function showServerStatus($server) { 491 492 echo "<p> Status for $server server </p>"; 493 494 $results=array(); 495 exec("czartool_getServerStatus.pl -s $server", $results, $status); 496 497 foreach ($results as &$line) { 498 echo "<pre>\n"; 499 echo "$line\n"; 500 echo "</pre>\n"; 501 502 } 503 504 } 505 506 306 507 ?> 307 508
Note:
See TracChangeset
for help on using the changeset viewer.
