Index: unk/tools/czarclean.pl
===================================================================
--- /trunk/tools/czarclean.pl	(revision 32102)
+++ 	(revision )
@@ -1,65 +1,0 @@
-#!/usr/bin/perl -w
-
-use warnings;
-use strict;
-use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
-
-# local classes
-use czartool::Config;
-use czartool::CzarDb;
-
-my $czarDbName = undef;
-my $begin = undef;
-my $end = undef;
-my $interval = undef;
-my $verbose = undef;
-my $optimize = undef;
-my $config = new czartool::Config();
-
-GetOptions (
-        "dbname|d=s" => \$czarDbName,
-        "interval|i=s" => \$interval,
-        "begin|b=s" => \$begin,
-        "end|e=s" => \$end,
-        "optimize|o" => \$optimize,
-        "verbose|v" => \$verbose,
-        );
-
-print "\n*******************************************************************************\n";
-print "* \n";
-my $quit = 0;
-
-if (@ARGV) {
-    $quit=1;
-    print "* UNKNKOWN: option                          @ARGV\n";
-}
-if (!$begin) {
-    $quit=1;
-    print "* REQUIRED: choose a begin date                -b <datetime>\n";
-}
-if (!$end) {
-    if($begin) {$end=$begin;} else {$end="NULL";}
-    print "* OPTIONAL: choose an end date date            -e <datetime>                   (default=$end)\n";
-}
-if (!$czarDbName) {
-    $czarDbName = "czardb";
-    print "* OPTIONAL: choose czar Db name                -d <name>                       (default=$czarDbName\n";
-}
-if (!$interval) {
-    print "* OPTIONAL: choose time interval               -i <'30 MINUTE'|'1 hour'|etc>   (default=".$config->getCzarCleanupInterval().")\n";
-}
-if (!$optimize) {
-    $optimize = 0;
-    print "* OPTIONAL: optimize database after cleanup    -o                              (default=$optimize)\n";
-}
-print "*\n*******************************************************************************\n";
-
-if ($quit) { exit; }
-
-my $czarDb = $config->getCzarDbInstance();
-
-my $labels = undef;
-
-
-$czarDb->cleanupDateRange($begin, $end, $config->getCzarCleanupInterval());
-if ($optimize) {$czarDb->optimize();}
Index: unk/tools/czarmetrics.pl
===================================================================
--- /trunk/tools/czarmetrics.pl	(revision 32102)
+++ 	(revision )
@@ -1,97 +1,0 @@
-#!/usr/bin/perl -w
-
-use warnings;
-use strict;
-
-use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
-use POSIX qw/strftime/;
-use CGI::Pretty qw[:standard];
-
-use czartool::Config;
-use czartool::DayMetrics;
-use czartool::MultiDayMetrics;
-use czartool::MetricsIndex;
-
-my $czarDbName = "czardb";
-my $day = undef;
-my $begin = undef;
-my $end = undef;
-my $cumulative = undef;
-my $index = undef;
-my $verbose = undef;
-my $save_temps = undef;
-
-GetOptions (
-        "dbname=s" => \$czarDbName,
-        "begin|b=s" => \$begin,
-        "end|e=s" => \$end,
-        "day|d=s" => \$day,
-        "index|i" => \$index,
-        "cumulative|c" => \$cumulative,
-        "verbose|v" => \$verbose,
-        );
-
-print "\n*******************************************************************************\n";
-print "* \n";
-my $quit = 0;
-if (@ARGV) {
-    $quit=1;
-    print "* UNKNKOWN: option                          @ARGV\n";
-}
-if (!$day) {
-    print "* OPTIONAL: choose a single day                -d <date>               (default=today)\n";
-}
-if (!$begin) { 
-    print "* OPTIONAL: choose a begin date                -b <date>               (default=today)\n";
-}
-if (!$end) {
-    print "* OPTIONAL: choose an end date                 -e <date>               (default=today)\n";
-}
-if (!$cumulative) {
-    print "* OPTIONAL: cumulative metrics for date range  -c                      (default=off)\n";
-}
-if (!$index) {
-    print "* OPTIONAL: create index file for all metrics  -i                      (default=off)\n";
-}
-
-print "*\n*******************************************************************************\n";
-
-if ($quit) {exit;}
-
-my $config = new czartool::Config();
-
-if ($index) {
-
-    my $metricsIndex = new czartool::MetricsIndex($config, 1, 0);
-    $metricsIndex->writeHTML();
-    exit;
-}
-
-if (!$day && !$begin && !$end) {
-    
-    $day = strftime('%Y-%m-%d', localtime);
-}
-if ($day) {$begin = $end = $day;}
-
-
-my $thisDay = $begin;
-
-if ($cumulative) {
-
-        my $multiDayMetrics = new czartool::MultiDayMetrics($config, 1, 0, $begin, $end);
-        $multiDayMetrics->writeHTML();
-}
-else {
-
-    my $czarDb = $config->getCzarDbInstance();
-
-    while (1) {
-
-        my $dayMetrics = new czartool::DayMetrics($config, 1, 0, $thisDay);
-        $dayMetrics->writeHTML();
-
-        $thisDay = $czarDb->addInterval($thisDay, "1 DAY");
-        if ($czarDb->isBefore($end, $thisDay)) {last;}
-    }
-}
-
Index: unk/tools/czarplot.pl
===================================================================
--- /trunk/tools/czarplot.pl	(revision 32102)
+++ 	(revision )
@@ -1,188 +1,0 @@
-#!/usr/bin/perl -w
-
-use warnings;
-use strict;
-
-use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
-use POSIX qw/strftime/;
-
-use czartool::Config;
-use czartool::Plotter;
-use czartool::StageMetrics;
-
-my $label = undef;
-my $stage = undef;
-my $save_temps = undef;
-my $timeinpast = undef;
-my $begin = undef;
-my $end = undef;
-my $day = undef;
-my $path = undef;
-my $verbose = undef;
-my $histogram = undef;
-my $timeSeries = undef;
-my $rate = undef;
-my $magicMask = undef;
-my $rateInterval = undef;
-my $deriv = undef;
-my $nebulous = undef;
-my $savingToFile = undef;
-my $analysis = undef;
-my $exposureId = undef;
-my $log = undef;
-
-GetOptions (
-        "label|l=s" => \$label,
-        "stage|s=s" => \$stage,
-        "timeinpast|p=s" => \$timeinpast,
-        "rateinterval|i=s" => \$rateInterval,
-        "exposureid|x=s" => \$exposureId,
-        "mask|m" => \$magicMask,
-        "begin|b=s" => \$begin,
-        "end|e=s" => \$end,
-        "day|d=s" => \$day,
-        "output|o=s" => \$path,
-        "histogram|h" => \$histogram,
-        "nebulous|n" => \$nebulous,
-        "rate|r" => \$rate,
-        "deriv|f" => \$deriv,
-        "analysis|a" => \$analysis,
-        "timeseries|t" => \$timeSeries,
-        "verbose|v" => \$verbose,
-        "log|g" => \$log,
-        );
-
-print "\n*******************************************************************************\n";
-print "* \n";
-my $quit = 0;
-if (@ARGV) {
-    $quit=1;
-    print "* UNKNKOWN: option                          @ARGV\n";
-}
-if ($analysis && !$stage) {
-    $quit = 1;
-    print "* REQUIRED: choose a stage for analsis      -s <chip|cam|warp|etc>      (default=none)\n";}
-if (!$histogram) {
-    print "* OPTIONAL: plot histogram                  -h                          (default=off)\n";}
-if (!$timeSeries) {
-    print "* OPTIONAL: plot timeseries                 -t                          (default=on)\n";} 
-if (!$magicMask) {
-    print "* OPTIONAL: plot magic mask for these times -m                          (default=off)\n";} 
-if (!$exposureId) {
-    print "* OPTIONAL: set exposure ID for magic mask  -x                          (default=none)\n";} 
-if (!$rate) {
-    print "* OPTIONAL: plot histogram of rate          -r                          (default=off)\n";} 
-if (!$deriv) {
-    $deriv = 0;
-    print "* OPTIONAL: plot first derivative           -f                          (default=$deriv)\n";} 
-if (!$analysis) {
-    $analysis = 0;
-    print "* OPTIONAL: include analysis                -a                          (default=$analysis)\n";} 
-if (!$log) {
-    $log = 0;
-    print "* OPTIONAL: use log plots                   -g                          (default=$log)\n";}
-if (!$nebulous) {
-    print "* OPTIONAL: plot nebulous disk space        -n                          (default=off)\n";} 
-if (!$label) {
-    $label = "all_stdscience_labels";
-    print "* OPTIONAL: choose a label                  -l <labellName>             (default=$label)\n";}
-if (!$stage) {
-    print "* OPTIONAL: choose a stage                  -s <chip|cam|warp|etc>      (default=none)\n";}
-if (!$timeinpast) {
-    print "* OPTIONAL: choose time interval in past    -p <'1 hour'|'1 day'|etc>   (default=none\n";} 
-if (!$rateInterval) {
-    print "* OPTIONAL: time interval for rate plot     -i <'1 hour'|'1 day'|etc>   (default=depends on time frame)\n";} 
-if (!$begin) {
-    print "* OPTIONAL: choose a begin time             -b <datetime>               (default=6:35am this morning)\n";} 
-if (!$end) {
-    print "* OPTIONAL: choose an end time              -e <datetime>               (default=now)\n";} 
-if (!$day) {
-    print "* OPTIONAL: choose a single day to plot     -d <date>                   (default=today)\n";} 
-if (!$path) {
-    print "* OPTIONAL: choose an output location       -o <path>                   (default=none)\n";
-} 
-print "*\n*******************************************************************************\n";
-
-if ($quit) { exit; }
-
-my $config = new czartool::Config();
-
-# default values
-if (!$rate && !$magicMask && !$nebulous && !$histogram && !$analysis && !$timeSeries) {$timeSeries = 1;}
-if (!$verbose) {$verbose = 0;}
-if (!$save_temps) {$save_temps = 0;}
-if (!$path) {$savingToFile = 0; $path = ".";}
-else {$savingToFile = 1;}
-
-my $czarDb = $config->getCzarDbInstance();
-
-my $newDayTime =  $config->getMetricsStartTime();
-
-my $plotter = undef; 
-if ($savingToFile) {
-
-    $plotter = czartool::Plotter->new_file($config, $path, $save_temps);
-}
-else {
-
-    $plotter = czartool::Plotter->new_display($config, $save_temps);
-}
-
-# if a single day has been chosen 
-if($day) {
-
-    if ($magicMask) {
-
-        $begin = $day;
-        $end = $day;
-    }
-    else {
-
-        # plots should span 24 housr from previous day
-        my $dayBefore = $czarDb->subtractInterval($day, "1 DAY");
-                
-        $begin = "$dayBefore $newDayTime";
-        $end = "$day $newDayTime";
-    }
-}
-else {
-
-    if (!$end) {$end = $czarDb->getNowTimestamp();}
-    if (!$begin) {
-
-        my $today = strftime('%Y-%m-%d', localtime);
-        my $yesterday = $czarDb->subtractInterval($today, "1 DAY");
-
-        
-        if ($timeinpast) {$begin = $czarDb->subtractInterval($end, $timeinpast);}
-        elsif ($czarDb->isBefore($end, "$today $newDayTime")) {$begin = "$yesterday $newDayTime";}
-        else {$begin = "$today $newDayTime";}
-    }
-}
-
-if ($rate and !$timeSeries) {
-
-        $plotter->createRateHistogram($label, $stage, $begin, $end, $rateInterval);
-        exit;
-}
-
-if (!$histogram && !$nebulous) {
-    $plotter->createTimeSeries($label, $stage, $begin, $end, $timeSeries, $log, $rate);
-    exit;
-}
-
-if ($histogram) {$plotter->createHistogram($label, $begin, $end);}
-if ($nebulous && $timeSeries) {$plotter->plotStorageTimeSeries($begin, $end);}
-elsif ($nebulous) {$plotter->plotDiskUsageHistogram();}
-if ($magicMask) {
-
-    if ($exposureId) {$plotter->plotMagicMaskFractionForThisExposure($exposureId);}
-    else {$plotter->plotMagicMaskFraction($begin, $end);}
-
-}
-
-if($analysis) {
-
-    my $stageMetrics = new czartool::StageMetrics($stage, $label, $begin, $end);
-    if ($czarDb->runAnalysis($stageMetrics)) {$stageMetrics->printMe();}
-}
Index: unk/tools/czarpoll.pl
===================================================================
--- /trunk/tools/czarpoll.pl	(revision 32102)
+++ 	(revision )
@@ -1,342 +1,0 @@
-#!/usr/bin/perl -w
-
-###########################################################################
-#
-# Main polling program for czartool. Grabs stuff from various sources every few minutes.
-#
-###########################################################################
-
-use warnings;
-use strict;
-use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
-use POSIX qw/strftime/;
-
-# local classes
-use czartool::Config;
-use czartool::CzarDb;
-use czartool::Gpc1Db;
-use czartool::Pantasks;
-use czartool::Nebulous;
-use czartool::Plotter;
-use czartool::DayMetrics;
-use czartool::MetricsIndex;
-
-my $period = 60;
-my $save_temps = 0;
-
-GetOptions (
-        "period|p=s" => \$period, # TODO more Db args
-        );
-
-my $config = new czartool::Config();
-my $czarDb = $config->getCzarDbInstance(); 
-my $gpc1Db = $config->getGpc1Instance;
-my $nebulous = new czartool::Nebulous($czarDb);
-my $pantasks = new czartool::Pantasks();
-my $plotter = czartool::Plotter->new_file($config, "/tmp", $save_temps); 
-
-
-my @stages = ("burntool", "chip", "cam", "fake", "warp", "stack", "diff", "magic", "magicDS", "dist", "pub");
-
-
-timePoll($period);
-
-###########################################################################
-#
-# Updates the dates from pantasks for all interested servers 
-#
-###########################################################################
-sub updateDates {
-
-    print "* Updating dates\n";
-    my @servers = ("stdscience", "registration");
-
-    my $server = undef;
-    $czarDb->emptyServerDates();
-    foreach $server (@servers) {
-
-        my @dates = @{$pantasks->getDates($server)};
-        if (@dates) { 
-
-            $czarDb->updateServerDates($server, \@dates);
-        }
-        else {
-
-            print "WARNING: No dates to update for '$server'\n";
-        }
-    }
-}
-
-###########################################################################
-#
-# Updates the labels from pantasks for all interested servers 
-#
-###########################################################################
-sub updateLabels {
-
-    print "* Updating labels\n";
-    my @servers = ("stdscience", "distribution", "publishing", "update");
-
-    my $server = undef;
-    foreach $server (@servers) {
-
-        my @labels = @{$pantasks->getLabels($server)};
-        if (@labels) { 
-
-            $czarDb->updateCurrentLabels($server, \@labels);
-        }
-        else {
-
-            print "WARNING: No labels to update for '$server'\n";
-        }
-    }
-}
-
-###########################################################################
-#
-# Updates pantasks server status TODO should really get info for all servers at once 
-#
-###########################################################################
-sub updateServerStatus {
-    print "* Checking all pantasks servers\n";
-
-    my $servers = $pantasks->getServerList();
-
-    my $server = undef;
-    my $alive = undef;
-    my $running = undef;
-    foreach $server (@{$servers}) {
-
-        $pantasks->getServerStatus($server, \$alive, \$running);
-        $czarDb->updateServerStatus($server, $alive, $running);
-    }
-}
-
-###########################################################################
-#
-# Polls with provided period (seconds) 
-#
-###########################################################################
-sub timePoll {
-    my ($period) = @_;
-
-    my $label;
-    my $new;
-    my $full;
-    my $faults;
-    my $stage;
-    my $query = undef;
-    my $str = undef;
-    my $labels = undef;
-    my $updateLabels = undef;
-    my $row = undef;
-    my $begin = undef;
-    my $end = undef;
-    my $priority = undef;
-    my $newState = undef;
-    my $nsStatus = undef;
-    my $today = undef;
-    my $yesterday = undef;
-    my $newDayTime = $config->getMetricsStartTime();
-    my $lastDayDailyTasks = "2010-01-01";
-
-    # main polling loop
-    while (1) {
-
-        # sort out times
-        $today = strftime('%Y-%m-%d', localtime);
-        $yesterday = $czarDb->subtractInterval($today, "1 DAY");
-        $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 {
-
-            $begin = "$today $newDayTime";
-
-            # check whether yesterday was cleaned. if not, cleanup tables and optimize
-            if ($lastDayDailyTasks ne $yesterday) {
-
-                print "* performing daily tasks (clean-up, metrics)\n";
-
-                # create metrics for last 24 hours
-                print "* Creating metrics for last 24 hours\n";
-                my $dayMetrics = new czartool::DayMetrics($config, 1, 0, $today); 
-                $dayMetrics->writeHTML();
-
-                # now update metrics index page
-                my $metricsIndex = new czartool::MetricsIndex($config, 1, 0); 
-                $metricsIndex->writeHTML();
-
-                # now cleanup tables from yesterday and optimize
-                print "* Performing database cleanup\n";
-                $czarDb->cleanupDateRange($yesterday, $yesterday, $config->getCzarCleanupInterval());
-                print "* Optimizing the database\n";
-                $czarDb->optimize();
-                $lastDayDailyTasks = $yesterday;
-            }
-        }
-
-        # check nightly science status
-        print "* Checking nightly science status\n";
-        if (!$pantasks->getNightlyScienceStatus(\$nsStatus)) {$nsStatus = "Unknown";}
-        $czarDb->updateNightlyScience($nsStatus);
-
-        # check nebulous
-        print "* Checking Nebulous\n";
-        $nebulous->updateClusterSpaceInfo();
-        $plotter->plotStorageTimeSeries($czarDb->subtractInterval($begin, "1 WEEK") , $end);
-        $plotter->plotDiskUsageHistogram();
-        updateServerStatus();
-
-        # check pantasks dates
-        updateDates();
-
-        # check labels
-        updateLabels();
-
-        # servers to check
-        my @serversToCheck = ("stdscience", "update");
-
-        my $thisServer = undef;
-        foreach $thisServer (@serversToCheck) {
-
-            if ($thisServer eq "update") {$newState = "update";}
-            else {$newState = "new";}
-
-            # deal with stdscience labels
-            if (!$czarDb->getCurrentLabels($thisServer, \$labels)) {next;}
-            my $size = @{$labels};
-            if($size > 0) {
-
-                # get priority
-                foreach $row ( @{$labels} ) {
-                    my ($label) = @{$row};
-                    $priority = $gpc1Db->getPriority($label);
-                    $czarDb->setLabelPriority($label, $priority);
-                }
-
-                updateAllStages($thisServer, $newState, $labels, $begin, $end);
-                createPlots($thisServer, $labels, $begin, $end);
-            }
-            else { print "* WARNING: no $thisServer labels found in Db\n";}
-        }
-
-        print "--------------------------------------------------------------------------\n";
-        #print "* Going to sleep\n";
-        #sleep($period);
-        #print "* Waking up\n";
-    };
-}
-
-###########################################################################
-#
-# Loops through labels and creates time series and histogram plots
-#
-###########################################################################
-sub createPlots {
-    my ($server, $rows, $begin, $end) = @_;
-
-    my $stage = undef;
-    my $row = undef;
-
-    print "* Generating plots\n";
-
-    # create plots for each label for each stage
-    foreach $stage (@stages) {
-        foreach $row ( @{$rows} ) {
-            my ($label) = @{$row};
-
-            chomp($label);
-            $plotter->createTimeSeries($label, $stage, $begin, $end, 1, 1, 1);
-            $plotter->createRateHistogram($label, $stage, $begin, $end, undef);
-        }
-    }
-
-    my $allServerLabels = undef;
-
-    # create plots for each label for all stages
-    foreach $row ( @{$rows} ) {
-        my ($label) = @{$row};
-
-        $plotter->createTimeSeries($label, undef, $begin, $end, 1, 1, 1);
-        $plotter->createRateHistogram($label, undef, $begin, $end, undef);
-        $plotter->createHistogram($label, $begin, $end);
-    }
-
-    $allServerLabels = "all_".$server."_labels";
-
-    $plotter->createTimeSeries($allServerLabels, undef, $begin, $end, 1, 1, 1);
-    $plotter->createRateHistogram($allServerLabels, undef, $begin, $end, undef);
-    $plotter->createHistogram($allServerLabels, $begin, $end);
-
-    foreach $stage (@stages) {
-
-        $plotter->createTimeSeries($allServerLabels, $stage, $begin, $end, 1, 1, 1); # TODO must be a neater way...
-        $plotter->createRateHistogram($allServerLabels, $stage, $begin, $end, undef);
-    }
-}
-
-###########################################################################
-#
-# Loops through some labels and updates processed/pending/faults in the Db
-#
-###########################################################################
-sub updateAllStages {
-    my ($labelServer, $newState, $rows, $begin, $end) = @_;
-
-    print "* Updating stage data\n";
-    my $totalNew = undef;
-    my $totalFaults = undef;
-    my $totalFull = undef;
-    my $stage = undef;
-    my $reverting = 0;
-    my $row = undef;
-    my $new = undef;
-    my $full = undef;
-    my $faults = undef;
-    my $server = undef;
-    my $state = undef;
-    my $today = strftime('%Y-%m-%d', localtime);
-
-    foreach $stage (@stages) {
-
-        $server = $pantasks->getServerForThisStage($stage);
-        $pantasks->getRevertStatus($stage, \$reverting);
-        $czarDb->updateRevertStatus($stage, $reverting);
-
-        print "* Checking labels for $stage stage\n";
-
-        $totalNew=$totalFaults=$totalFull=0;
-        foreach $row ( @{$rows} ) {
-            my ($label) = @{$row};
-
-            chomp($label);
-
-            if ($stage eq "burntool") {
-
-                $new = $full = $faults = 0;
-                if ($labelServer eq "stdscience") {
-
-                    $full = $gpc1Db->countRegisteredExposures($label, $today);
-                }
-            }
-            else {
-
-                $new = $gpc1Db->countExposures($label, $stage, $newState);
-                $full = $gpc1Db->countExposures($label, $stage, "full");
-                $faults = $gpc1Db->countFaults($label, $stage, $newState);
-            }
-            #printf("%s  %s, %s, %d, %d\n", $labelServer, $label, $stage, $new, $faults);
-            $totalNew += $new;
-            $totalFull += $full;
-            $totalFaults += $faults;
-
-            $czarDb->insertNewTimeData($stage, $label, $new, $full, $faults);
-        }
-
-        $czarDb->insertNewTimeData($stage, "all_".$labelServer."_labels", $totalNew, $totalFull, $totalFaults);
-    }
-}
-
Index: unk/tools/czartool.pl
===================================================================
--- /trunk/tools/czartool.pl	(revision 32102)
+++ 	(revision )
@@ -1,257 +1,0 @@
-#!/usr/bin/perl -w
-
-use warnings;
-use strict;
-use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
-
-# local classes
-use czartool::Config;
-use czartool::CzarDb;
-use czartool::Gpc1Db;
-use czartool::Pantasks;
-
-
-my $czarDbName = "czardb";
-my $save_temps = 1;
-my $interval = undef;
-
-GetOptions ( 
-        "dbname|d=s" => \$czarDbName,
-        "interval|i=s" => \$interval,
-        );
-
-
-my @states = ("full", "new", "drop", "wait");
-my $config = new czartool::Config();
-my $czarDb = $config->getCzarDbInstance();
-my $gpc1Db = $config->getGpc1Instance();
-my $pantasks = new czartool::Pantasks();
-
-my @stdscienceLabels = undef;
-my @distributionLabels = undef;
-my @publishingLabels = undef;
-
-my @stages = ("chip", "cam", "fake", "warp", "stack", "diff", "magic", "magicDS", "dist", "pub"); 
-promptPoll();
-
-
-###########################################################################
-#
-# Prints simple instructions
-#
-###########################################################################
-sub printInstructions {
-
-    print "| Usage: (s)ervers, (l)abels, (q)uit, or label number from table above: ";
-}
-
-###########################################################################
-#
-# Polls waiting for input from user 
-#
-###########################################################################
-sub promptPoll {
-
-    @stdscienceLabels = @{$pantasks->getLabels("stdscience")};
-    @distributionLabels = @{$pantasks->getLabels("distribution")};
-    @publishingLabels = @{$pantasks->getLabels("publishing")};
-    checkAllLabels("new");
-    printInstructions();
-
-    my $key;
-    system "stty cbreak < /dev/tty > /dev/tty 2>&1";
-    while (($key=getc) ) {
-        last if $key eq "q";
-
-        if ($key eq "s") {checkServers();}
-        elsif ($key eq "l") {checkAllLabels("new");}
-        elsif ($key eq "u") {$pantasks->getServerCurrentStatus("stdscience");}
-        elsif ($key =~ m/[0-9]/) {my $key2=getc; checkOneLabel($stdscienceLabels[($key.$key2)-1]);}
-        printInstructions();
-
-    };
-    system "stty -cbreak < /dev/tty > /dev/tty 2>&1";
-}
-
-###########################################################################
-#
-# Compares two arrays and stores the differences
-#
-###########################################################################
-sub getArrayDifferences {
-
-    my @array1 = @{$_[0]};
-    my @array2 = @{$_[1]};
-
-    my @isect;
-    my @diff;
-    my %count;
-
-    my $item;
-    foreach $item (@array1, @array2) {$count{$item}++;}
-
-    foreach $item (keys %count) {
-        if ($count{$item} == 2) {
-            push @isect, $item;
-        } else {
-            push @diff, $item;
-        }
-    }
-
-    return \@diff;
-}
-
-###########################################################################
-#
-# Checks all servers to see if they are alive and running
-#
-###########################################################################
-sub checkServers {
-
-    my @servers = ("addstar", "cleanup", "detrend", "distribution", "pstamp", "update", "publishing", "registration", "replication", "stdscience", "summitcopy");
-    printf("\n+-----------------------------------------------+\n");
-    printf("|                      Servers                  |\n");
-    printf("+--------------+---------+----------------------+\n");
-    printf("|    server    |  alive? |  Scheduler running?  |\n");
-    printf("+--------------+---------+----------------------+\n");
-    my $server;
-    foreach $server (@servers) {
-
-        my @results = `czartool_checkServer.pl -s $server`;
-
-        printf("| %12s ", $server);
-        chomp($results[0]);
-        chomp($results[1]); 
-        printf("|   %3s   |         %3s          |\n", $results[0], $results[1]);
-    }
-
-    printf("+--------------+---------+----------------------+\n");
-}
-
-###########################################################################
-#
-# Takes label name or number
-#
-###########################################################################
-sub labelDetails {
-
-    print "\nPlease enter the label name, or number from table above: ";
-    my $input = <STDIN>;
-    chomp($input);
-    if ($input =~ m/^([0-9]|[1-9][0-9]|[1-9][0-9][0-9])$/) {
-        return checkOneLabel($stdscienceLabels[$input]);
-    }
-
-    checkOneLabel($input);
-}
-
-###########################################################################
-#
-# Checks one label and prints results in a table
-#
-###########################################################################
-sub checkOneLabel {
-    my ($label) = @_;
-
-    chomp($label);
-
-    printf("\n+----------------------------------------------------------------------------------------------------------------------------------------------+\n");
-    printf("|                                                         %32s                                                     |\n", $label);
-    printf("+------------+------------+------------+------------+------------+------------+------------+------------+------------+------------+------------+\n");
-    printf("|   state    |    chip    |    cam     |    fake    |    warp    |   stack    |    diff    |   magic    |  destreak  |    dist    |   publish  |\n");
-    printf("+------------+------------+------------+------------+------------+------------+------------+------------+------------+------------+------------+\n");
-
-    my $state;
-    my $stage;
-    my $i=0;
-    foreach $state (@states) {
-
-        chomp($label);
-        printf("| %10s ", $state);
-
-        foreach $stage (@stages) {
-
-            printf("| %10s ", getStateAndFaultsString($label, $state, $stage));
-        }
-
-        printf("|\n");
-        $i++;
-    }
-
-    printf("+------------+------------+------------+------------+------------+------------+------------+------------+------------+------------+------------+\n");
-
-}
-
-###########################################################################
-#
-# Checks all labels for a particular state and prints results in a table
-#
-###########################################################################
-sub checkAllLabels {
-    my ($state) = @_;
-#print time, $/;
-    printf("\n+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n");
-    printf("|                                                                                         %10s (any faults are shown in parentheses)                                                                 |\n", $state);
-    printf("+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------+\n");
-    printf("| no  |              label               | distributing? |  publishing?  |    chip    |    cam     |    fake    |    warp    |   stack    |    diff    |   magic    |  destreak  |    dist    |   publish  |\n");
-    printf("+-----+----------------------------------+---------------+---------------+------------+------------+------------+------------+------------+------------+------------+------------+------------+------------+\n");
-
-    my $stdsLabel;
-    my $distLabel;
-    my $pubLabel;
-    my $distributing;
-    my $publishing;
-    my $stage;
-    my $i=1;
-    foreach $stdsLabel (@stdscienceLabels) {
-
-        $distributing = 0;
-        chomp($stdsLabel);
-        foreach $distLabel (@distributionLabels) {
-            chomp($distLabel);
-            if ($stdsLabel eq $distLabel) { $distributing = 1; last;}
-        }
-
-        foreach $pubLabel (@publishingLabels) {
-            chomp($pubLabel);
-            if ($stdsLabel eq $pubLabel) { $publishing = 1; last;}
-        }
-
-        printf("| %3d ", $i);
-        printf("| %32s ", $stdsLabel);
-        printf("| %10s    ", $distributing ? "yes" : "NO" );
-        printf("| %10s    ", $publishing ? "yes" : "NO" );
-
-        foreach $stage (@stages) {
-
-            printf("| %10s ", getStateAndFaultsString($stdsLabel, $state, $stage));
-        }
-
-        printf("|\n");
-        $i++;
-    }
-
-    printf("+-----+----------------------------------+---------------+---------------+------------+------------+------------+------------+------------+------------+------------+------------+------------+------------+\n");
-
-}
-
-###########################################################################
-#
-# Returns state and fault-count (if new) as a string TODO untidy
-#
-###########################################################################
-sub getStateAndFaultsString {
-    my ($label, $state, $stage) = @_;
-
-    my $new = $gpc1Db->countExposures($label, $stage, $state);
-
-    #if ($state ne "new") {return $new;}
-
-    my $faults = $gpc1Db->countFaults($label, $stage, $state);
-
-    if ($faults < 1) {return $new;}
-
-    return $new."(".$faults.")";
-}
-
-
Index: unk/tools/roboczar.pl
===================================================================
--- /trunk/tools/roboczar.pl	(revision 32102)
+++ 	(revision )
@@ -1,151 +1,0 @@
-#!/usr/bin/perl -w
-
-use warnings;
-use strict;
-use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
-use POSIX qw/strftime/;
-
-# local classes
-use czartool::Config;
-use czartool::CzarDb;
-use czartool::Gpc1Db;
-use czartool::Pantasks;
-use czartool::Nebulous;
-use czartool::Plotter;
-use czartool::Burntool;
-use czartool::StageMetrics;
-
-my $save_temps = 0;
-
-my $config = new czartool::Config();
-my $czarDb = $config->getCzarDbInstance();
-
-my @stages = ("burntool", "chip", "cam", "fake", "warp", "stack", "diff", "magic", "magicDS", "dist"); # TODO get from Pantasks
-
-my @interestedServers = $config->getRoboczarInterestedServers();
-
-my $stuckMessage;
-my $serversMessage;
-my $message;
-my $lastMessage = "";
-my $anythingToReport;
-while(1) {
-
-    $anythingToReport = 0;
-
-    $message = "";
-
-    if (anyStoppedServers($config->getRoboczarServerInterval(), \$serversMessage)) {
-
-        $message .= "\n\n" . $serversMessage;
-        $anythingToReport = 1;
-    }
-#    if (anyStuckStages("2 HOUR", \$stuckMessage)) {
-
- #       $message .= "\n\n" . $stuckMessage;
-  #      $anythingToReport = 1;
-   # }
-
-    if ($anythingToReport && $message ne $lastMessage) {
-    
-print "\n\n$message\n\n";
-
-        sendEmail($config->getRoboczarEmail(),
-                "Roboczar warnings", 
-                "$message\n");
-    }
-
-    $lastMessage = $message;
-
-    print "* Going to sleep\n";
-    sleep(1200);
-}
-
-
-###########################################################################
-#
-# Checks if anything is stuck
-#
-###########################################################################
-sub anyStuckStages {
-    my ($interval, $message) = @_;
-
-    my $end = $czarDb->getNowTimestamp();
-    #$end = '2010-10-24 15';
-    my $begin = $czarDb->subtractInterval($end, $interval);
-    my $anyStuckStages = 0;
-
-    # exception - we don't care if burntool is stalled before 6:30am TODO we do now
-    my $burntime = strftime('%Y-%m-%d 06:35', localtime);
-    my $worryAboutBurntool = $czarDb->isBefore($burntime, $end);
-
-    ${$message} = "Processing stages:\n";
-
-    my $stage;
-    foreach $stage (@stages) {
-
-    my $stageMetrics = new czartool::StageMetrics($stage, "all_stdscience_labels", $begin, $end);
-
-    if ($czarDb->runAnalysis($stageMetrics)) {$stageMetrics->printMe();}
-
-        if ($stageMetrics->getStuck() && $stage eq "burntool" && !$worryAboutBurntool) {next;}
-
-        if ($stageMetrics->getStuck()) {
-        
-            ${$message} = ${$message} ."\n - '$stage' is stuck with ".$stageMetrics->getFinalPending()." pending exposures (and ".$stageMetrics->getFaults()." faults)";
-            $anyStuckStages = 1;
-        }
-    }
-
-    return $anyStuckStages;
-}
-
-###########################################################################
-#
-# Checks that the important servers are running 
-#
-###########################################################################
-sub anyStoppedServers {
-    my ($interval, $message) = @_;
-
-    my $anythingToReport = 0;
-    my $server;
-    my $since;
-
-    ${$message} = "Pantasks servers:\n";
-
-    foreach $server (@interestedServers) {
-
-        # is server alice?
-        if ($czarDb->isServerDown($server, $interval, \$since)) {
-
-            ${$message} = ${$message} . "\n - '$server' has been DOWN since '$since'";
-            $anythingToReport = 1;
-        }
-        # is it running?
-        elsif ($czarDb->isServerStopped($server, $interval, \$since)) {
-
-            ${$message} = ${$message} . "\n - '$server' has been stopped since '$since'";
-            $anythingToReport = 1;
-        }
-    }
-
-    return $anythingToReport;
-} 
-
-###########################################################################
-#
-# Sends an email 
-#
-###########################################################################
-sub sendEmail {
-    my ($to, $subject, $message) = @_;
-
-    my $sendmail = '/usr/lib/sendmail';
-    open(MAIL, "|$sendmail -oi -t");
-    print MAIL "From: roboczar\@ipp.org\n";
-    print MAIL "To: $to\n";
-    print MAIL "Subject: $subject\n\n";
-    print MAIL "$message\n";
-    close(MAIL);
-}
