Index: /trunk/tools/czartool/CzarDb.pm
===================================================================
--- /trunk/tools/czartool/CzarDb.pm	(revision 28782)
+++ /trunk/tools/czartool/CzarDb.pm	(revision 28783)
@@ -5,6 +5,4 @@
 use warnings;
 use strict;
-
-use File::Temp qw(tempfile);
 
 my @stages = ("chip", "cam", "fake", "warp", "stack", "diff", "magic", "magicDS", "dist"); # TODO put elsewhere
@@ -125,8 +123,8 @@
 ###########################################################################
 sub insertNewTimeData {
-    my ($self, $table, $label, $pending, $processed, $faults, $reverting) = @_;
-
-    my $query = $self->{_db}->prepare(<<SQL);
-    INSERT INTO $table
+    my ($self, $stage, $label, $pending, $processed, $faults, $reverting) = @_;
+
+    my $query = $self->{_db}->prepare(<<SQL);
+    INSERT INTO $stage
         (label, pending, processed, faults, reverting)
         VALUES
@@ -140,5 +138,5 @@
 ###########################################################################
 #
-# Gets timedifference in seconds for these two times 
+# Gets time difference in seconds for these two times 
 #
 ###########################################################################
@@ -146,6 +144,4 @@
     my ($self, $fromTime, $toTime) = @_; 
 
-    my ($tempFile, $tempName) = tempfile( "/tmp/czartool_gnuplot_timeseries.XXXX", UNLINK => !$self->{_save_temps});
-
     my $query = $self->{_db}->prepare(<<SQL);
     SELECT 
@@ -164,7 +160,8 @@
 ###########################################################################
 sub createTimeSeriesData {
-    my ($self, $label, $table, $fromTime, $toTime, $minX, $maxX, $minY, $maxY, $timeDiff) = @_;
-
-    my ($tempFile, $tempName) = tempfile( "/tmp/czartool_gnuplot_timeseries.XXXX", UNLINK => !$self->{_save_temps});
+    my ($self, $label, $stage, $fromTime, $toTime, $minX, $maxX, $minY, $maxY, $timeDiff) = @_;
+
+    my $dataFile = "/tmp/czarplot_gnuplot_".$label."_".$stage."_t.dat"; # TODO use stage not table
+    open (GNUDAT, ">$dataFile");
 
     my $query = $self->{_db}->prepare(<<SQL);
@@ -175,5 +172,5 @@
         DATE_FORMAT(MIN(timestamp),'$self->{_dateFormat}'),
         TIME_TO_SEC(TIMEDIFF(max(timestamp ), min(timestamp)))
-            FROM $table 
+            FROM $stage 
             WHERE label LIKE '$label'
             AND timestamp >= '$fromTime' AND timestamp <= '$toTime'; 
@@ -191,5 +188,5 @@
     SELECT 
         DATE_FORMAT(timestamp, '$self->{_dateFormat}'), pending, faults, processed-$minProcessed 
-        FROM $table 
+        FROM $stage 
         WHERE label LIKE '$label' 
         AND timestamp >= '$fromTime' AND timestamp <= '$toTime' 
@@ -204,9 +201,9 @@
         my ($timestamp, $pending, $faults, $processed) = @row;
     #    print  "'$timestamp' '$pending' '$faults' '$processed'\n";
-        print $tempFile "$timestamp $pending $faults $processed\n";
-    }
-    close($tempFile);
-
-    return $tempName;
+        print GNUDAT "$timestamp $pending $faults $processed\n";
+    }
+    close(GNUDAT);
+
+    return $dataFile;
 }
 
@@ -217,10 +214,10 @@
 ###########################################################################
 sub countFaultsInPast {
-    my ($self, $label, $table, $interval) = @_; # TODO use time not interval
+    my ($self, $label, $stage, $interval) = @_; # TODO use time not interval
 
     # get earliest time for this label
     my $query = $self->{_db}->prepare(<<SQL);
     SELECT GREATEST(MIN(timestamp), now() - INTERVAL $interval) 
-        FROM $table
+        FROM $stage
         WHERE label LIKE '$label'; 
 SQL
@@ -231,5 +228,5 @@
     $query = $self->{_db}->prepare(<<SQL);
     SELECT faults 
-        FROM $table
+        FROM $stage
         WHERE label LIKE '$label' 
         AND timestamp <= '$timestamp' LIMIT 1;
@@ -246,9 +243,9 @@
 ###########################################################################
 sub countPendingNow {
-    my ($self, $label, $table) = @_;
+    my ($self, $label, $stage) = @_;
 
     my $query = $self->{_db}->prepare(<<SQL);
     SELECT pending - faults 
-        FROM $table 
+        FROM $stage 
         WHERE label LIKE '$label' 
         ORDER BY timestamp DESC LIMIT 1;
@@ -265,5 +262,5 @@
 ###########################################################################
 sub countProcessedPendingAndFaults {
-    my ($self, $label, $table, $fromTime, $toTime, $processed, $pending, $faults) = @_;
+    my ($self, $label, $stage, $fromTime, $toTime, $processed, $pending, $faults) = @_;
 
 
@@ -271,5 +268,5 @@
     SELECT 
         pending, faults 
-        FROM $table
+        FROM $stage
         WHERE label LIKE '$label'
         AND timestamp >= '$fromTime' AND timestamp <= '$toTime'
@@ -283,5 +280,5 @@
     SELECT 
         MAX(processed) - MIN(processed) 
-        FROM $table 
+        FROM $stage 
         WHERE label LIKE '$label' 
         AND timestamp >= '$fromTime' AND timestamp <= '$toTime'; 
@@ -298,10 +295,10 @@
 ###########################################################################
 sub countProcessed { # TODO use time not interval
-    my ($self, $label, $table, $interval) = @_;
+    my ($self, $label, $stage, $interval) = @_;
 
     my $query = $self->{_db}->prepare(<<SQL);
     SELECT 
         MAX(processed) - MIN(processed) 
-        FROM $table 
+        FROM $stage 
         WHERE label LIKE '$label' 
         AND timestamp > (now() - INTERVAL $interval); 
Index: /trunk/tools/czartool/Czarplot.pm
===================================================================
--- /trunk/tools/czartool/Czarplot.pm	(revision 28782)
+++ /trunk/tools/czartool/Czarplot.pm	(revision 28783)
@@ -4,6 +4,4 @@
 use warnings;
 use strict;
-
-use File::Temp qw(tempfile);
 
 my @allStages = ("chip", "cam", "fake", "warp", "stack", "diff", "magic", "magicDS", "dist");
@@ -100,5 +98,7 @@
     my $outputFile = createImageFileName($self, $label, undef, "h");
 
-    my ($tempFile, $inputFile) = tempfile( "/tmp/czartool_gnuplot_histogram.XXXX", UNLINK => !$self->{_save_temps});
+    my $inputFile = "/tmp/czarplot_gnuplot_".$label."_h.dat"; # TODO use stage not table
+    open (GNUDAT, ">$inputFile");
+
     my ($processed, $pending, $faults);
     my $stage = undef;
@@ -106,8 +106,8 @@
 
         $self->{_czarDb}->countProcessedPendingAndFaults($label, $stage, $beginTime, $endTime, \$processed, \$pending, \$faults);
-        print $tempFile "$stage $processed, $pending, $faults\n";
-    }
-
-    close($tempFile);
+        print GNUDAT "$stage $processed, $pending, $faults\n";
+    }
+
+    close(GNUDAT);
 
     plotHistogram($self, $inputFile, $outputFile, $label, $beginTime, $endTime);
