Index: trunk/ippMonitor/raw/czartool_labels.php
===================================================================
--- trunk/ippMonitor/raw/czartool_labels.php	(revision 38257)
+++ trunk/ippMonitor/raw/czartool_labels.php	(revision 38258)
@@ -8,9 +8,9 @@
 if (! $ID['proj']) { projectform ($ID); }
 
-//$db = dbconnect($ID['proj']);
-$czardb = dbconnect("czardb"); // HACK to connect to czarDb 
+// connect to czarDb 
+$czardb = dbconnect($CZARDBNAME); 
 $lastUpdateTime = getLastUpdateTime($czardb);
 
-$gpc1db = dbconnect($ID['proj']);
+$projectdb = dbconnect($ID['proj']);
 
 $PATH = getenv("PATH");
@@ -99,5 +99,9 @@
 $menu = $ID['menu'];
 
-$selectedMode = $_GET[mode];
+// The Update mode of czartool is obsolete since we don't use the update
+// pantasks. 
+// $selectedMode = $_GET[mode];
+$selectedMode = "stdscience";
+
 $selectedStage = $_GET[stage];
 $selectedLabel = $_GET[label];
@@ -135,4 +139,5 @@
 $labels = getLabels($czardb, $selectedMode);
 $distLabels = getLabels($czardb, "distribution");
+// publishing is in stdscience now
 # $pubLabels = getLabels($czardb, "publishing");
 $pubLabels = $labels;
@@ -145,9 +150,18 @@
 }
 
+// The Update mode of czartool is obsolete. selectedMode is hardcoded to stdscience above.
 $isUpdate = ($selectedMode == "update");
-$modeText = $isUpdate ? "Showing update processing" : "Showing standard processing";
-$modeLinkText = $isUpdate ? "standard" : "update";
-$modeLink = $isUpdate ? "stdscience" : "update";
-$link = "czartool_labels.php?pass=".$pass."&proj=".$proj."&mode=".$modeLink."&label=all&stage=" . $selectedStage . "&revertstage=" . $stage . "&plottype=$plotType";
+$isUpdate = 0;
+
+// hijack the text and link at the top to create a link to the czartool monitoring the other project database
+// I.E. Switch from gpc1 to gpc2 or gpc2 to gpc1
+
+$modeText = "Monitoring $proj";
+if ($proj == 'gpc1') {
+    $newproj = 'gpc2';
+} else {
+    $newproj = 'gpc1';
+}
+$link = "czartool_labels.php?pass=".$pass."&mode=".$selectedMode."&label=all&stage=" . $selectedStage . "&revertstage=" . $stage . "&plottype=$plotType";
 
 // set up the form
@@ -164,18 +178,19 @@
 echo "<td colspan=\"3\" style=\"background-color:#0080c0;\">";
 echo "<h1 align=\"middle\">Czartool</h1>";
-echo "<h4 align=\"middle\">$modeText (change to <a href=\"$link\"><font color=\"blue\">$modeLinkText</font></a>)</h4>";
+echo "<h2 align=\"middle\">$modeText (change to <a href=\"$link&proj=$newproj\"><font color=\"blue\">$newproj</font></a>)</h2>";
 echo "</td>";
 echo "</tr>";
 
+// PLOTS
 echo "<tr valign=\"top\">";
 echo "<td style=width:100px;text-align:top;\">";
  # time series plot
-echo "<br><img src=\"czartool_getplot.php?mode=$selectedMode&type=t&label=$selectedLabel&stage=$selectedStage&plottype=$plotType\"><br>";
+echo "<br><img src=\"czartool_getplot.php?mode=$selectedMode&type=t&label=$selectedLabel&proj=$proj&stage=$selectedStage&plottype=$plotType\"><br>";
  # rate time series plot
-echo "<br><img src=\"czartool_getplot.php?mode=$selectedMode&type=rt&label=$selectedLabel&stage=$selectedStage&plottype=linear\"><br>";
+echo "<br><img src=\"czartool_getplot.php?mode=$selectedMode&type=rt&label=$selectedLabel&proj=$proj&stage=$selectedStage&plottype=linear\"><br>";
  # rate stacked histo plot
-# echo "<img src=\"czartool_getplot.php?mode=$selectedMode&type=rh&label=$selectedLabel&stage=$selectedStage&plottype=linear\"><br>";
+# echo "<img src=\"czartool_getplot.php?mode=$selectedMode&type=rh&label=$selectedLabel&proj=$proj&stage=$selectedStage&plottype=linear\"><br>";
  # histogram plot
-# echo "<img src=\"czartool_getplot.php?mode=$selectedMode&type=h&label=$selectedLabel&stage=$selectedStage&plottype=linear\"><br>";
+# echo "<img src=\"czartool_getplot.php?mode=$selectedMode&type=h&label=$selectedLabel&proj=$proj&stage=$selectedStage&plottype=linear\"><br>";
  # storage plot
 echo "<br><a href=\"czartool_getplot.php?type=sl\"><img title=\"Click to enlarge me\" src=\"czartool_getplot.php?type=s\"></a><br>";
@@ -186,4 +201,6 @@
  if ($selectedServer && !$serverCmd) showServerStatus($selectedServer);
 echo "</td>";
+
+
 echo "<td style=height:200px;width:10px;text-align:top;\">";
 echo "<td style=height:200px;width:400px;text-align:top;\">";
@@ -240,5 +257,5 @@
       createServersTable($pass, $proj,$selectedMode,$czardb, $servers, $selectedLabel, $selectedStage, $plotType);
 echo "<br>";
-      createSummitDataTable($gpc1db);
+      createSummitDataTable($projectdb);
 echo "<br>";
       createDatesTable($czardb);
@@ -253,4 +270,8 @@
       createTableColumnHeader("Status (sec behind master)");
       showReplicationsStatus($REPL_HOST_GPC1, $REPL_USER_GPC1, $REPL_PASSWORD_GPC1, $REPL_DBNAME_GPC1);
+
+// XXX: avoid replication status checking errors due to missing passwords from my test host
+// XXX: TODO: remove this conditional before committing changes
+if (0) {
       # XXX EAM : problem showReplicationsStatus($REPL_HOST_NEBULOUS, $REPL_USER_NEBULOUS, $REPL_PASSWORD_NEBULOUS, $REPL_DBNAME_NEBULOUS);
       showReplicationsStatus($REPL_HOST_PSTAMP, $REPL_USER_PSTAMP, $REPL_PASSWORD_PSTAMP, $REPL_DBNAME_PSTAMP);
@@ -258,4 +279,5 @@
       showReplicationsStatus($REPL_HOST_ISP, $REPL_USER_ISP, $REPL_PASSWORD_ISP, $REPL_DBNAME_ISP);
       showReplicationsStatus($REPL_HOST_NEBULOUS_SECONDARY, $REPL_USER_NEBULOUS_SECONDARY, $REPL_PASSWORD_NEBULOUS_SECONDARY, $REPL_DBNAME_NEBULOUS_SECONDARY);
+}
       echo "</table>";
 
@@ -315,10 +337,10 @@
 #
 ###########################################################################
-function createSummitDataTable($gpc1db) {
+function createSummitDataTable($projectdb) {
 
     $date = date("Y-m-d");
     $sql = "SELECT DISTINCT exp_type FROM summitExp WHERE dateobs > '$date'";
 
-    $qry = $gpc1db->query($sql);
+    $qry = $projectdb->query($sql);
     if (dberror($qry)) {
         echo "<b>error reading newExp table</b><br>\n";
@@ -343,8 +365,8 @@
 
         $sql = "SELECT COUNT(*) FROM summitExp WHERE dateobs > '$date' AND exp_type = '$expType[0]'";
-        $qry2 = $gpc1db->query($sql);
+        $qry2 = $projectdb->query($sql);
         $qry2->fetchInto($summit);
         $sql = "SELECT COUNT(*) FROM summitExp JOIN rawExp ON summitExp.exp_name = rawExp.exp_name WHERE summitExp.dateobs > '$date' AND summitExp.exp_type = '$expType[0]'";
-        $qry2 = $gpc1db->query($sql);
+        $qry2 = $projectdb->query($sql);
         $qry2->fetchInto($mhpcc);
 
@@ -373,5 +395,5 @@
 function getLabels($db, $server) {
 
-    # order by descending priority as set in gpc1 database
+    # order by descending priority as set in project database
     $sql = "SELECT label FROM current_labels WHERE server LIKE '$server' ORDER BY priority DESC";
     if ($debug) {echo "$sql<br>";}
@@ -490,5 +512,5 @@
 	  $myTable    = $mainTable[$stage];
 	  $myFailures = $getFailures[$stage];
-	  # echo "myTable: $myTable";
+          # echo "myTable: $myTable";
 
 	  if ("$myFailures" == "NONE") {
@@ -501,5 +523,5 @@
             }
           }
-          getStateAndFaults($db, $thisLabel, $selectedState, $stage, $str, $anyFaults);
+          getStateAndFaults($db, $thisLabel, $proj, $selectedState, $stage, $str, $anyFaults);
 
 	  $cellcolor = 0;
@@ -647,8 +669,8 @@
 #
 ###########################################################################
-function getStateAndFaults($db, $label, $state, $stage, &$str, &$anyFaults) {
+function getStateAndFaults($db, $label, $proj, $state, $stage, &$str, &$anyFaults) {
 
     $anyFaults = false;
-    $sql = "SELECT pending, faults FROM $stage WHERE label LIKE '$label' ORDER BY timestamp DESC LIMIT 1";
+    $sql = "SELECT pending, faults FROM $stage WHERE label LIKE '$label' AND dbname LIKE '$proj' ORDER BY timestamp DESC LIMIT 1";
     if ($debug) {echo "$sql<br>";}
 
