Index: trunk/ippMonitor/czartool/czarplot.pl
===================================================================
--- trunk/ippMonitor/czartool/czarplot.pl	(revision 38257)
+++ trunk/ippMonitor/czartool/czarplot.pl	(revision 38258)
@@ -30,7 +30,9 @@
 my $log = undef;
 my $psps = undef;
+my $project = 'gpc1';
 
 GetOptions (
         "label|l=s" => \$label,
+        "project=s" => \$project,
         "stage|s=s" => \$stage,
         "timeinpast|p=s" => \$timeinpast,
@@ -110,12 +112,16 @@
 my $newDayTime =  $config->getMetricsStartTime();
 
+my $projectDb = $config->getDbInstanceForProject($project);
+die "Failed to open database for $project.\n" unless $projectDb;
+
+
 my $plotter = undef;
 if ($savingToFile) {
 
-    $plotter = czartool::Plotter->new_file($config, $path, $save_temps);
+    $plotter = czartool::Plotter->new_file($config, $projectDb, $path, $save_temps);
 }
 else {
 
-    $plotter = czartool::Plotter->new_display($config, $save_temps);
+    $plotter = czartool::Plotter->new_display($config, $projectDb, $save_temps);
 }
 
Index: trunk/ippMonitor/czartool/czarpoll.pl
===================================================================
--- trunk/ippMonitor/czartool/czarpoll.pl	(revision 38257)
+++ trunk/ippMonitor/czartool/czarpoll.pl	(revision 38258)
@@ -26,5 +26,5 @@
 
 GetOptions (
-        "period|p=s" => \$period, # TODO more Db args
+        "period|p=s" => \$period,
         );
 
@@ -35,6 +35,11 @@
 my $nebulous = new czartool::Nebulous($czarDb);
 my $pantasks = new czartool::Pantasks();
-my $plotter = czartool::Plotter->new_file($config, $config->getGnuplotPath(), $save_temps);
-
+
+# We have a top level directory that gets general plots and then one for each database
+my $plotter0 = czartool::Plotter->new_file($config, undef, $config->getGnuplotPath(), $save_temps);
+
+# for now hardcode two databases. Later I'll look into handling a variable number
+my $plotter1 = czartool::Plotter->new_file($config, $gpc1Db, $config->getGnuplotPath() . "/gpc1", $save_temps);
+my $plotter2 = czartool::Plotter->new_file($config, $gpc2Db, $config->getGnuplotPath() . "/gpc2", $save_temps);
 
 my @stages = (
@@ -59,4 +64,7 @@
         "merged",
         "deleted_local");
+
+# The ippToPsps pages are no longer operational
+@ippToPspsStages = ();
 
 my @allStages = (@stages, @ippToPspsStages);
@@ -167,4 +175,6 @@
     while (1) {
 
+        my $iterationStartTime = time();
+
         # sort out times
         $today = strftime('%Y-%m-%d', localtime);
@@ -172,8 +182,9 @@
         $end = $czarDb->getNowTimestamp();
 
-        # if before 18:00 today, then start plots from 18:00 yesterday
-        if ($czarDb->isBefore($end, "$today $newDayTime")) {$begin = "$yesterday $newDayTime";}
-        # if after 18:00 today, then perform some daily tasks and start plots from 18:00 today
-        else {
+        if ($czarDb->isBefore($end, "$today $newDayTime")) {
+            # if before $newDayTime today (configured to 18:00), then start plots from $newDayTime yesterday
+            $begin = "$yesterday $newDayTime";
+        } else {
+            # if after $newDayTime today (configured to 18:00), then perform some daily tasks and start plots from $newDayTime  today
 
             $begin = "$today $newDayTime";
@@ -186,9 +197,9 @@
                 # create metrics for last 24 hours
                 print "* Creating metrics for last 24 hours\n";
-                my $dayMetrics = new czartool::DayMetrics($config, 1, 0, $today);
+                my $dayMetrics = new czartool::DayMetrics($config, $gpc1Db, 1, 0, $today);
                 $dayMetrics->writeHTML();
 
                 # now update metrics index page
-                my $metricsIndex = new czartool::MetricsIndex($config, 1, 0);
+                my $metricsIndex = new czartool::MetricsIndex($config, $gpc1Db, 1, 0);
                 $metricsIndex->writeHTML();
 
@@ -210,7 +221,7 @@
         print "* Checking Nebulous\n";
         $nebulous->updateClusterSpaceInfo();
-        $plotter->plotStorageTimeSeries($czarDb->subtractInterval($begin, "1 WEEK") , $end);
-        $plotter->plotDiskUsageHistogram();
-        $plotter->plotDiskUsageHistogramLarge();
+        $plotter0->plotStorageTimeSeries($czarDb->subtractInterval($begin, "1 WEEK") , $end);
+        $plotter0->plotDiskUsageHistogram();
+        $plotter0->plotDiskUsageHistogramLarge();
         updateServerStatus();
 
@@ -239,4 +250,5 @@
                 foreach $row ( @{$labels} ) {
                     my ($label) = @{$row};
+                    # for now use priorities from gpc1 database
                     $priority = $gpc1Db->getPriority($label);
                     $czarDb->setLabelPriority($label, $priority);
@@ -244,13 +256,22 @@
 
                 updateAllStages($thisServer, $newState, $labels, $begin, $end);
-                if ($thisServer eq "stdscience") {createPlots($thisServer, $labels, $begin, $end);}
+                if ($thisServer eq "stdscience") {
+                    createPlots($thisServer, $plotter1, $labels, $begin, $end);
+                    createPlots($thisServer, $plotter2, $labels, $begin, $end);
+                }
             }
             else { print "* WARNING: no $thisServer labels found in Db\n";}
         }
 
+        my $iterationTime = time() - $iterationStartTime;
+
+        print "done with czarpoll iteration after $iterationTime seconds\n";
+
         print "--------------------------------------------------------------------------\n";
-        #print "* Going to sleep\n";
-        #sleep($period);
-        #print "* Waking up\n";
+        if ($iterationTime < $period) {
+            print "* Going to sleep\n";
+            sleep($period - $iterationTime);
+            print "* Waking up\n";
+        }
     };
 }
@@ -262,40 +283,48 @@
 ###########################################################################
 sub createPlots {
-    my ($server, $rows, $begin, $end) = @_;
+    my ($server, $plotter, $rows, $begin, $end) = @_;
 
     my $stage = undef;
     my $row = undef;
 
-    print "* Generating plots\n";
-
-    # get ippToPsps labels
-    my $ippToPspsLabels = undef;
-    $czarDb->getCurrentIppToPspsLabels($begin, $end, \$ippToPspsLabels);
-    $plotter->setIppToPspsMode();
-
-    # create ippToPsps labels
-    foreach $stage (@ippToPspsStages) {
+    my $project = $plotter->getProject();
+    print "* Generating plots for $project\n";
+
+    # XXX The ippToPsps stuff is not project specific so it should be done somewhere
+    # else
+    if (scalar @ippToPspsStages) {
+        # get ippToPsps labels
+        my $ippToPspsLabels = undef;
+        $czarDb->getCurrentIppToPspsLabels($begin, $end, \$ippToPspsLabels);
+        $plotter->setIppToPspsMode();
+
+        # create ippToPsps labels
+        foreach $stage (@ippToPspsStages) {
+            foreach $row ( @{$ippToPspsLabels} ) {
+                my ($label) = @{$row};
+
+                chomp($label);
+                $plotter->createTimeSeries($label, $stage, $begin, $end, 1, 0, 1);
+            }
+        }
+
+        # create plots for each label for all stages for ippToPsps
         foreach $row ( @{$ippToPspsLabels} ) {
             my ($label) = @{$row};
 
-            chomp($label);
-            $plotter->createTimeSeries($label, $stage, $begin, $end, 1, 0, 1);
-        }
-    }
-
-    # create plots for each label for all stages for ippToPsps
-    foreach $row ( @{$ippToPspsLabels} ) {
-        my ($label) = @{$row};
-
-        $plotter->createTimeSeries($label, undef, $begin, $end, 1, 1, 1);
-    }
-
+            $plotter->createTimeSeries($label, undef, $begin, $end, 1, 1, 1);
+        }
+    }
 
     # create plots for each label for each stage
     $plotter->setStandardMode();
+
     foreach $stage (@stages) {
         foreach $row ( @{$rows} ) {
             my ($label) = @{$row};
 
+            # skip update labels for now. The plots are not relevant.
+            next if $label =~ 'ps_ud';
+
             chomp($label);
             $plotter->createTimeSeries($label, $stage, $begin, $end, 1, 0, 1);
@@ -308,4 +337,7 @@
     foreach $row ( @{$rows} ) {
         my ($label) = @{$row};
+
+        # skip update labels for now. The plots are not relevant.
+        next if $label =~ 'ps_ud';
 
         $plotter->createTimeSeries($label, undef, $begin, $end, 1, 1, 1);
@@ -362,4 +394,5 @@
             chomp($label);
 
+            # Move this to a function and pass in the database
             $new = $gpc1Db->countExposures($label, $stage, $newState);
             $full = $gpc1Db->countExposures($label, $stage, "full");
Index: trunk/ippMonitor/czartool/czartool/Config.pm
===================================================================
--- trunk/ippMonitor/czartool/czartool/Config.pm	(revision 38257)
+++ trunk/ippMonitor/czartool/czartool/Config.pm	(revision 38258)
@@ -126,4 +126,21 @@
 ###########################################################################
 #
+# Returns an instance of a database for the given project
+#
+###########################################################################
+sub getDbInstanceForProject {
+    my ($self, $project) = @_;
+
+    if ($project eq 'gpc1') {
+        return $self->getGpc1Instance();
+    } elsif ($project eq 'gpc2') {
+        return $self->getGpc2Instance();
+    } else {
+        return undef;
+    }
+}
+
+###########################################################################
+#
 # Returns the interval used in czarDB cleanup
 #
Index: trunk/ippMonitor/czartool/czartool/CzarDb.pm
===================================================================
--- trunk/ippMonitor/czartool/czartool/CzarDb.pm	(revision 38257)
+++ trunk/ippMonitor/czartool/czartool/CzarDb.pm	(revision 38258)
@@ -214,5 +214,5 @@
 ###########################################################################
 #
-# Updates current_labels table
+# Update server_dates table
 #
 ###########################################################################
@@ -380,4 +380,8 @@
     my ($self, $label, $stage, $fromTime, $toTime, $minX, $maxX, $timeDiff) = @_;
 
+    # XXX: I'm not splitting this by project (dbname).
+    # Is that ok? Seems like a good idea because this will make the time
+    # range of the plots for both projects the same.
+
     my $query = $self->{_db}->prepare(<<SQL);
     SELECT
@@ -411,13 +415,13 @@
 ###########################################################################
 sub getDayTimings {
-    my ($self, $label, $startStage, $endStage, $begin, $started, $finished, $timeTaken) = @_;
+    my ($self, $label, $dbname, $startStage, $endStage, $begin, $started, $finished, $timeTaken) = @_;
 
     my $end = $self->addInterval($begin, "1 DAY");
 
-    my $startStageMetrics = new czartool::StageMetrics($startStage, $label, $begin, $end);
-    my $endStageMetrics = new czartool::StageMetrics($endStage, $label, $begin, $end);
-
-    if (!$self->runAnalysis($startStageMetrics)) {return 0;}
-    if (!$self->runAnalysis($endStageMetrics)) {return 0;}
+    my $startStageMetrics = new czartool::StageMetrics($startStage, $label, $dbname, $begin, $end);
+    my $endStageMetrics = new czartool::StageMetrics($endStage, $label, $dbname, $begin, $end);
+
+    if (!$self->runAnalysis($startStageMetrics, $dbname)) {return 0;}
+    if (!$self->runAnalysis($endStageMetrics, $dbname)) {return 0;}
 
     ${$started} = $startStageMetrics->getStarted();
@@ -436,5 +440,5 @@
 ###########################################################################
 sub runAnalysis {
-    my ($self, $stageMetrics) = @_;
+    my ($self, $stageMetrics, $dbname) = @_;
 
     if (!$stageMetrics) {return 0;}
@@ -445,4 +449,5 @@
     my $toTime = $stageMetrics->getEndTime();
 
+
     $toTime = $self->addInterval($toTime, "20 MINUTE"); # TODO dodgy
 
@@ -452,4 +457,5 @@
         FROM $stage
         WHERE label LIKE '$label'
+        AND dbname LIKE '$dbname'
         AND timestamp >= '$fromTime' AND timestamp <= '$toTime'
         ORDER BY timestamp;
@@ -656,5 +662,5 @@
 ###########################################################################
 sub createTimeSeriesData {
-    my ($self, $label, $stage, $fromTime, $toTime, $minX, $maxX, $timeDiff, $linDataFile, $logDataFile, $ratDataFile) = @_;
+    my ($self, $label, $dbname, $stage, $fromTime, $toTime, $minX, $maxX, $timeDiff, $linDataFile, $logDataFile, $ratDataFile) = @_;
 
     # get total number of data points
@@ -663,4 +669,5 @@
         FROM $stage
         WHERE label LIKE '$label'
+        AND dbname LIKE '$dbname'
         AND timestamp >= '$fromTime' AND timestamp <= '$toTime';
 SQL
@@ -680,4 +687,5 @@
         FROM $stage
         WHERE label LIKE '$label'
+        AND dbname LIKE '$dbname'
         AND timestamp >= '$fromTime' AND timestamp <= '$toTime'
         ORDER BY timestamp;
@@ -854,5 +862,5 @@
 ###########################################################################
 sub countFaultsInPast {
-    my ($self, $label, $stage, $interval) = @_; # TODO use time not interval
+    my ($self, $label, $dbname, $stage, $interval) = @_; # TODO use time not interval
 
     # get earliest time for this label
@@ -860,5 +868,6 @@
     SELECT GREATEST(MIN(timestamp), now() - INTERVAL $interval)
         FROM $stage
-        WHERE label LIKE '$label';
+        WHERE label LIKE '$label'
+        AND dbname LIKE '$dbname';
 SQL
     $query->execute;
@@ -870,4 +879,5 @@
         FROM $stage
         WHERE label LIKE '$label'
+        AND dbname LIKE '$dbname'
         AND timestamp <= '$timestamp' LIMIT 1;
 SQL
@@ -883,5 +893,5 @@
 ###########################################################################
 sub countPendingNow {
-    my ($self, $label, $stage) = @_;
+    my ($self, $label, $dbname, $stage) = @_;
 
     my $query = $self->{_db}->prepare(<<SQL);
@@ -889,4 +899,5 @@
         FROM $stage
         WHERE label LIKE '$label'
+        AND dbname LIKE '$dbname'
         ORDER BY timestamp DESC LIMIT 1;
 SQL
@@ -902,5 +913,5 @@
 ###########################################################################
 sub countProcessedPendingAndFaults {
-    my ($self, $label, $stage, $fromTime, $toTime, $processed, $pending, $faults) = @_;
+    my ($self, $label, $dbname, $stage, $fromTime, $toTime, $processed, $pending, $faults) = @_;
 
     my $query = $self->{_db}->prepare(<<SQL);
@@ -909,4 +920,5 @@
         FROM $stage
         WHERE label LIKE '$label'
+        AND dbname like '$dbname'
         AND timestamp >= '$fromTime' AND timestamp <= '$toTime'
         ORDER BY timestamp DESC LIMIT 1;
@@ -917,5 +929,5 @@
     (${$pending}, ${$faults}) = $query->fetchrow_array();
 
-    ${$processed} = $self->countProcessed($label, $stage, $fromTime, $toTime);
+    ${$processed} = $self->countProcessed($label, $dbname, $stage, $fromTime, $toTime);
 
     if (!${$pending}) {${$pending} = 0;}
@@ -1066,5 +1078,5 @@
 ###########################################################################
 sub createProcessingRateData {
-    my ($self, $stage, $label, $begin, $end, $interval, $dataFile, $minX, $maxX, $timeDiff) = @_;
+    my ($self, $stage, $label, $dbname, $begin, $end, $interval, $dataFile, $minX, $maxX, $timeDiff) = @_;
 
     my $startTime = $begin;
@@ -1089,5 +1101,5 @@
         if (!$self->isBefore($startTime, $end)) {last;}
         $endTime = $self->addInterval($startTime, $interval);
-        if (!$self->countProcessedPendingAndFaults($label, $stage, $startTime, $endTime, \$processed, \$pending, \$faults)) {}
+        if (!$self->countProcessedPendingAndFaults($label, $dbname, $stage, $startTime, $endTime, \$processed, \$pending, \$faults)) {}
         $timestamp = $self->getFormattedDate($endTime);
         if (!$processed) {$processed = 0;}
@@ -1108,5 +1120,5 @@
 ###########################################################################
 sub countProcessed {
-    my ($self, $label, $stage, $begin, $end) = @_;
+    my ($self, $label, $dbname, $stage, $begin, $end) = @_;
 
     my $query = $self->{_db}->prepare(<<SQL);
@@ -1115,4 +1127,5 @@
         FROM $stage
         WHERE label LIKE '$label'
+        AND dbname LIKE '$dbname'
         AND timestamp >= '$begin'
         AND timestamp < '$end'
Index: trunk/ippMonitor/czartool/czartool/DayMetrics.pm
===================================================================
--- trunk/ippMonitor/czartool/czartool/DayMetrics.pm	(revision 38257)
+++ trunk/ippMonitor/czartool/czartool/DayMetrics.pm	(revision 38258)
@@ -29,9 +29,10 @@
     my $self = $class->SUPER::new(
             $_[1],  # config object
-            $_[2],  # verbose
-            $_[3]   # save_temps
+            $_[2],  # projectDb
+            $_[3],  # verbose
+            $_[4]   # save_temps
             );
 
-    $self->{day} = $_[4];
+    $self->{day} = $_[5];
 
     my $yesterday =  $self->{czarDb}->subtractInterval($self->{day}, "1 DAY");
@@ -68,7 +69,8 @@
 
     # summit and chip exposures
-    my $summitExposures = $self->{gpc1Db}->countScienceExposuresFromLastNight($self->{day});
-    my $chipMetrics = new czartool::StageMetrics("chip", "all_stdscience_labels", $self->{begin}, $self->{chipEnd});
-    $self->{czarDb}->runAnalysis($chipMetrics);
+    my $summitExposures = $self->{projectDb}->countScienceExposuresFromLastNight($self->{day});
+    my $dbname = $self->{projectDb}->getDbName();
+    my $chipMetrics = new czartool::StageMetrics("chip", "all_stdscience_labels", $dbname, $self->{begin}, $self->{chipEnd});
+    $self->{czarDb}->runAnalysis($chipMetrics, $dbname);
 
     my $previousDay = $self->{czarDb}->subtractInterval($self->{day}, "1 DAY");
@@ -136,6 +138,6 @@
         foreach my $stage ( @stages ){
 
-            my $stageMetrics = new czartool::StageMetrics($stage, $label, $self->{begin}, ($stage eq "chip") ? $self->{chipEnd} : $self->{end});
-            if (!$self->{czarDb}->runAnalysis($stageMetrics)) {next;}
+            my $stageMetrics = new czartool::StageMetrics($stage, $label, $dbname, $self->{begin}, ($stage eq "chip") ? $self->{chipEnd} : $self->{end});
+            if (!$self->{czarDb}->runAnalysis($stageMetrics, $dbname)) {next;}
 
             if (!$stageMetrics->anythingProcessed()) {next;}
@@ -268,7 +270,9 @@
     print $htmlFile "  </tr>\n";
 
+    my $dbname = $self->{projectDb}->getDbName();
+
     # OSS survey
     my ($started, $finished, $timeTaken) = undef;
-    $self->{czarDb}->getDayTimings("OSS.nightlyscience", "chip", "diff", $self->{begin}, \$started, \$finished, \$timeTaken);
+    $self->{czarDb}->getDayTimings("OSS.nightlyscience", $dbname, "chip", "diff", $self->{begin}, \$started, \$finished, \$timeTaken);
     $self->printSurveyDetails("OSS", $started, $finished, $timeTaken);
 
@@ -295,5 +299,5 @@
     foreach $mdf (@mdfs) {
 
-        if ($self->{czarDb}->getDayTimings($mdf, "chip", "dist", $self->{begin}, \$started, \$finished, \$timeTaken)) {
+        if ($self->{czarDb}->getDayTimings($mdf, $dbname, "chip", "dist", $self->{begin}, \$started, \$finished, \$timeTaken)) {
 
             if ($started && $self->{czarDb}->isBefore($started, $earliest)) {$earliest = $started; $haveStart = 1;}
@@ -309,5 +313,5 @@
     $self->printSurveyDetails("MDF", $earliest, $latest, $timeTaken);
 
-    $self->{czarDb}->getDayTimings("all_stdscience_labels", "chip", "dist", $self->{begin}, \$started, \$finished, \$timeTaken);
+    $self->{czarDb}->getDayTimings("all_stdscience_labels", $dbname, "chip", "dist",  $self->{begin}, \$started, \$finished, \$timeTaken);
     $self->printSurveyDetails("All", $started, $finished, $timeTaken);
 
Index: trunk/ippMonitor/czartool/czartool/Gpc1Db.pm
===================================================================
--- trunk/ippMonitor/czartool/czartool/Gpc1Db.pm	(revision 38257)
+++ trunk/ippMonitor/czartool/czartool/Gpc1Db.pm	(revision 38258)
@@ -1,3 +1,5 @@
 #!/usr/bin/perl i-w
+
+# This class is now misnamed. Should be ProjectDb or something like that.
 
 package czartool::Gpc1Db;
Index: trunk/ippMonitor/czartool/czartool/Metrics.pm
===================================================================
--- trunk/ippMonitor/czartool/czartool/Metrics.pm	(revision 38257)
+++ trunk/ippMonitor/czartool/czartool/Metrics.pm	(revision 38258)
@@ -25,9 +25,11 @@
     my $self = {
         config => shift,
+        projectDb => shift,
         verbose => shift,
         save_temps => shift,
     };
 
-    $self->{gpc1Db} = $self->{config}->getGpc1Instance();
+    # $self->{gpc1Db} = $self->{config}->getGpc1Instance();
+
     $self->{czarDb} = $self->{config}->getCzarDbInstance();
     $self->{baseDir} = $self->{config}->getMetricsSaveLocation();
@@ -39,4 +41,5 @@
     $self->{plotter} = czartool::Plotter->new_file(
             $self->{config},
+            $self->{projectDb},
             ".",
             $self->{save_temps});
Index: trunk/ippMonitor/czartool/czartool/MetricsIndex.pm
===================================================================
--- trunk/ippMonitor/czartool/czartool/MetricsIndex.pm	(revision 38257)
+++ trunk/ippMonitor/czartool/czartool/MetricsIndex.pm	(revision 38258)
@@ -29,6 +29,7 @@
     my $self = $class->SUPER::new(
             $_[1],  # config object 
-            $_[2],  # verbose
-            $_[3]   # save_temps
+            $_[2],  # database
+            $_[3],  # verbose
+            $_[4]   # save_temps
             );
 
Index: trunk/ippMonitor/czartool/czartool/MySQLDb.pm
===================================================================
--- trunk/ippMonitor/czartool/czartool/MySQLDb.pm	(revision 38257)
+++ trunk/ippMonitor/czartool/czartool/MySQLDb.pm	(revision 38258)
@@ -65,4 +65,9 @@
 }                                                                               
 
+sub getDbName {
+    my( $self ) = @_;                                                       
+    return $self->{_dbName};                                                 
+}                                                                               
+
 ###########################################################################
 #
Index: trunk/ippMonitor/czartool/czartool/Plotter.pm
===================================================================
--- trunk/ippMonitor/czartool/czartool/Plotter.pm	(revision 38257)
+++ trunk/ippMonitor/czartool/czartool/Plotter.pm	(revision 38258)
@@ -46,4 +46,5 @@
     my $self = {
         _config => shift,
+        _projectDb => shift,
         _dateFormat => shift,
         _outputFormat => shift,
@@ -52,4 +53,5 @@
     };
 
+
     bless $self, $class;
     $self->init();
@@ -66,4 +68,5 @@
     my $self = {
         _config => shift,
+        _projectDb => shift,
         _outputPath => shift,
         _save_temps => shift,
@@ -86,4 +89,5 @@
     my $self = {
         _config => shift,
+        _projectDb => shift,
         _save_temps => shift,
     };
@@ -128,7 +132,23 @@
     my ($self) = @_;
 
-    $self->{_gpc1Db} = $self->{_config}->getGpc1Instance();
+    if ($self->{_projectDb}) {
+        $self->{_project} = $self->{_projectDb}->getDbName();
+    } else {
+        $self->{_project} = undef;
+    }
+        
+
     $self->{_czarDb} = $self->{_config}->getCzarDbInstance();
     $self->setStandardMode();
+}
+
+###########################################################################
+#
+# Get the project (dbname) associated with this Plotter
+#
+###########################################################################
+sub getProject {
+    my ($self) = @_;
+    return $self->{_project};
 }
 
@@ -209,4 +229,5 @@
                     $stage,
                     $label,
+                    $self->{_project},
                     $beginTime,
                     $endTime,
@@ -301,4 +322,5 @@
         if($self->{_czarDb}->createTimeSeriesData(
                     $label,
+                    $self->{_project},
                     $stage,
                     $beginTime,
@@ -403,4 +425,5 @@
         if (!$self->{_czarDb}->countProcessedPendingAndFaults(
                 $label,
+                $self->{_project},
                 $stage,
                 $beginTime,
@@ -547,5 +570,5 @@
     $title .= " for '$label'\\nFrom '$fromTime' to '$toTime' HST";
 
-    open (GP, "|$GNUPLOT -persist") or die "no gnuplot";
+    open (GP, "|$GNUPLOT -persist > /dev/null 2>&1") or die "no gnuplot";
     use FileHandle;
     GP->autoflush(1);
@@ -747,5 +770,5 @@
 
     my $fracs;
-    if (!$self->{_gpc1Db}->getMagicMaskFraction($exp_id, \$fracs)) {return 0;}
+    if (!$self->{_projectDb}->getMagicMaskFraction($exp_id, \$fracs)) {return 0;}
 
     open (GNUDAT, ">".$tmpFile->filename);
@@ -809,5 +832,5 @@
     # get exposures between these dates
     my $exp_ids = undef;
-    if (!$self->{_gpc1Db}->getProcessedExposures($begin, $end, \$exp_ids)) {return 0;}
+    if (!$self->{_projectDb}->getProcessedExposures($begin, $end, \$exp_ids)) {return 0;}
     my $totalExp = @{$exp_ids};
     if ($totalExp < 1) {return 0;}
@@ -844,5 +867,5 @@
         $exp_id = @{$row}[0];
 
-        if (!$self->{_gpc1Db}->getMagicMaskStats($exp_id, \$meanMask, \$sumMask, \$chipCount )) {next;}
+        if (!$self->{_projectDb}->getMagicMaskStats($exp_id, \$meanMask, \$sumMask, \$chipCount )) {next;}
 
 
Index: trunk/ippMonitor/czartool/czartool/StageMetrics.pm
===================================================================
--- trunk/ippMonitor/czartool/czartool/StageMetrics.pm	(revision 38257)
+++ trunk/ippMonitor/czartool/czartool/StageMetrics.pm	(revision 38258)
@@ -17,4 +17,5 @@
         stage => shift,
         label => shift,
+        dbname => shift,
         startTime => shift,
         endTime => shift
@@ -111,4 +112,5 @@
 sub getEndTime() {my $self = shift; return $self->{endTime};}
 sub getLabel() {my $self = shift; return $self->{label};}
+sub getDbname() {my $self = shift; return $self->{dbname};}
 sub getStage() {my $self = shift; return $self->{stage};}
 sub getStarted() {my $self = shift; return $self->{started};}
Index: trunk/ippMonitor/raw/czartool_exposures.php
===================================================================
--- trunk/ippMonitor/raw/czartool_exposures.php	(revision 38257)
+++ trunk/ippMonitor/raw/czartool_exposures.php	(revision 38258)
@@ -6,5 +6,5 @@
 
 if (! $ID['proj']) { projectform ($ID); }
-$gpc1db = dbconnect($ID['proj']);
+$projectdb = dbconnect($ID['proj']);
 
 $PATH = getenv("PATH");
@@ -46,5 +46,5 @@
 echo "</form>\n";
 
-createTableForThisSurvey($gpc1db, $date, $survey);
+createTableForThisSurvey($projectdb, $date, $survey);
 
 menu_end();
Index: trunk/ippMonitor/raw/czartool_getplot.php
===================================================================
--- trunk/ippMonitor/raw/czartool_getplot.php	(revision 38257)
+++ trunk/ippMonitor/raw/czartool_getplot.php	(revision 38258)
@@ -18,10 +18,12 @@
 $plottype = $_GET[plottype];
 
-$path = "/data/ipp009.0/czartool_plots"; # TODO horrible hard-coded path - read from config
+$proj = $_GET[proj];
+
+$path = $CZARPLOTDIR;
 
 if ($label == "all") $label = "all_".$mode."_labels";
 
 if ($type=="t" || $type=="r" || $type=="rt" || $type=="rh")
-$filePath = "$path/czarplot_".$plottype."_".$label."_".$stage."_".$type.".png";
+$filePath = "$path/$proj/czarplot_".$plottype."_".$label."_".$stage."_".$type.".png";
 else if ($type=="h")
 $filePath = "$path/czarplot_".$plottype."_".$label."_all_stages_".$type.".png";
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>";}
 
Index: trunk/ippMonitor/raw/ipp.czar.dat
===================================================================
--- trunk/ippMonitor/raw/ipp.czar.dat	(revision 38257)
+++ trunk/ippMonitor/raw/ipp.czar.dat	(revision 38258)
@@ -4,5 +4,4 @@
 
 menulink   | menuselect      | link    | czartool - standard          | czartool_labels.php
-menulink   | menuselect      | link    | czartool - ipptopsps         | czartool_ipptopsps.php
 menulink   | menuselect      | link    | mask stats                   | maskStats.php
 menulink   | menuselect      | link    | night summary                | nightSummary.php
Index: trunk/ippMonitor/raw/ipp.php
===================================================================
--- trunk/ippMonitor/raw/ipp.php	(revision 38257)
+++ trunk/ippMonitor/raw/ipp.php	(revision 38258)
@@ -69,4 +69,6 @@
   global $DBUSER;
   global $DBPASS;
+  global $CZARDBNAME;
+  global $CZARDBHOST;
 
   $success = 0;
@@ -86,5 +88,9 @@
   // connect to the database
   if ($DBI == "DB") {
-    $db = DB::connect("mysql://$DBUSER:$DBPASS@$DBHOST/$database");
+    if ($database == $CZARDBNAME) {
+        $db = DB::connect("mysql://$DBUSER:$DBPASS@$CZARDBHOST/$database");
+    } else {
+        $db = DB::connect("mysql://$DBUSER:$DBPASS@$DBHOST/$database");
+    }
   }
   if ($DBI == "MDB2") {
@@ -192,5 +198,9 @@
 function checkID () {
 
+
   $VERBOSE = 0;
+  if ($VERBOSE > 1) {
+      phpinfo(32);
+  }
 
   // check for valid server method
