Index: unk/tools/czartool/Czarplot.pm
===================================================================
--- /trunk/tools/czartool/Czarplot.pm	(revision 29117)
+++ 	(revision )
@@ -1,425 +1,0 @@
-#!/usr/bin/perl -w
-package czartool::Czarplot;
-
-use warnings;
-use strict;
-
-my @allStages = ("burntool", "chip", "cam", "fake", "warp", "stack", "diff", "magic", "magicDS", "dist");
-
-
-###########################################################################
-#
-# Constructor
-#
-###########################################################################
-sub new {
-    my $class = shift;
-    my $self = {
-        _czarDb => shift,
-        _dateFormat => shift,
-        _outputFormat => shift,
-        _outputPath => shift,
-        _save_temps => shift,
-    };
-
-    bless $self, $class;
-    return $self;
-}
-
-###########################################################################
-#
-# Generates a suitable filename for this plot
-#
-###########################################################################
-sub createImageFileName {
-    my ($self, $label, $stage, $suffix, $isLog) = @_;
-
-    my $prefix = $self->{_outputPath} ? $self->{_outputPath} : ".";
-    my $stagePart = $stage ? $stage : "all_stages";
-    my $type = $isLog ? "log" : "linear";
-    return $prefix . "/czarplot_" . $type . "_" . $label . "_" . $stagePart . "_$suffix.png";
-}
-
-###########################################################################
-#
-# Plots a time series for all stages for this label
-#
-###########################################################################
-sub createTimeSeries {
-    my ($self, $label, $selectedStage, $beginTime, $endTime, $makeLinear, $makeLog) = @_;
-
-    my ($minX, $maxX, $minY, $maxY, $timeDiff);
-    $minX = 999999999;      
-    $maxX = -9999999999;
-    $minY = 999999999;          
-    $maxY = -99999999;
-
-    my $stages = undef;                 
-
-    if (!$selectedStage) {$stages = \@allStages;}
-    else {$stages = ["$selectedStage"]};        
-
-    my %gnuplotFilesLin;
-    my %gnuplotFilesLog;
-    my $stage = undef;
-    my $gnuplotFileLin = undef;
-    my $gnuplotFileLog = undef;
-    foreach $stage (@{$stages}) {
-
-        if($self->{_czarDb}->createTimeSeriesData(
-                    $label, 
-                    $stage, 
-                    $beginTime, 
-                    $endTime, 
-                    \$minX, 
-                    \$maxX, 
-                    \$minY, 
-                    \$maxY, 
-                    \$timeDiff, 
-                    \$gnuplotFileLin,
-                    \$gnuplotFileLog)) {
-
-            $gnuplotFilesLin{$stage} = $gnuplotFileLin;
-            $gnuplotFilesLog{$stage} = $gnuplotFileLog;
-        }
-
-    }                                                           
-
-    my $numOfPlots =  keys(%gnuplotFilesLin);
-
-    if ($numOfPlots == 0 ) {
-
-        print "Warning: No plots could be generated for stage '$selectedStage' and label '$label' during time period '$beginTime', '$endTime'\n";
-        return;
-    } 
-
-    if ($timeDiff == 0) {
-
-        print "WARNING: Zero time difference for '$label' during time period '$beginTime', '$endTime'\n";
-        return;
-    }
-
-    my $outputFile;
-    if ($makeLinear) {
-
-        $outputFile = createImageFileName($self, $label, $selectedStage, "t", 0);
-        $self->plotTimeSeries(\%gnuplotFilesLin, $outputFile, $label, $beginTime, $endTime, $maxX, $minX, $maxY, $minY, $timeDiff, 0);
-    }
-    if ($makeLog) {
-
-        $outputFile = createImageFileName($self, $label, $selectedStage, "t", 1);
-        $self->plotTimeSeries(\%gnuplotFilesLog, $outputFile, $label, $beginTime, $endTime, $maxX, $minX, $maxY, $minY, $timeDiff, 1);
-    }
-}                                                    
-
-###########################################################################
-#
-# Plots a histogram of stuff processed in provided interval and label for all stages
-#
-###########################################################################
-sub createHistogram {
-    my ($self, $label, $beginTime, $endTime) = @_;
-
-    my $outputFile = createImageFileName($self, $label, undef, "h", 0);
-
-    my $inputFile = "/tmp/czarplot_gnuplot_".$label."_h.dat"; # TODO use stage not table
-        open (GNUDAT, ">$inputFile");
-
-    my ($processed, $pending, $faults);
-    my $stage = undef;
-    my $pendingMinusFaults = undef;
-    foreach $stage (@allStages) {
-
-        $self->{_czarDb}->countProcessedPendingAndFaults($label, $stage, $beginTime, $endTime, \$processed, \$pending, \$faults);
-
-        $pendingMinusFaults = $pending - $faults;
-        print GNUDAT "$stage $faults $processed, $pendingMinusFaults\n";
-    }
-
-    close(GNUDAT);
-
-    plotHistogram($self, $inputFile, $outputFile, $label, $beginTime, $endTime);
-}
-
-
-###########################################################################
-#
-# Sets the output path 
-#
-###########################################################################
-sub setOutputFormat {
-    my ($self, $outputFormat) = @_;
-    $self->{_outputFormat} = $outputFormat if defined($outputFormat);
-}           
-
-###########################################################################
-#
-# Sets the output type 
-#
-###########################################################################
-sub setOutputPath {
-    my ($self, $outputPath) = @_;
-    $self->{_outputPath} = $outputPath if defined($outputPath);
-}           
-
-###########################################################################
-#
-# Sets the date format to be used
-#
-###########################################################################
-sub setDateFormat {
-    my ($self, $dateFormat) = @_;
-    $self->{_dateFormat} = $dateFormat if defined($dateFormat);
-    return $self->{_dateFormat};
-}       
-
-###########################################################################
-#
-# Sorts out plotting max/min x/y
-#
-###########################################################################
-sub sortOutMaxMinY {
-    my ($self, $minY, $maxY) = @_;
-
-    my $tmp;
-    if (${$maxY} < ${$minY}) {
-
-        $tmp = ${$maxY};
-        ${$maxY} = ${$minY};
-        ${$minY} = $tmp;
-    }
-
-    my $border = (${$maxY} - ${$minY})/10;
-
-    ${$maxY} += $border;
-    ${$minY} -= $border ;
-    if (${$maxY} == 0) {${$maxY} = 1;}
-    if (${$minY} == 0) {${$minY} = -1;}
-}
-
-
-###########################################################################
-#
-# Figures out suitable spacing for time tics on time-series pliots
-#
-###########################################################################
-sub getTimeSpacing {
-    my ($self, $timeDiff, $divX, $timeFormat) = @_;
-
-    # if less than a couple of hour's data plotted, show 30 mins tics
-    if ($timeDiff < 7200) {
-        ${$timeFormat} = "%H:%M";
-        ${$divX} = 1800;
-    }
-    # if less than half a day's data plotted, show hourly tics
-    elsif ($timeDiff < 43200) {
-        ${$timeFormat} = "%H:%M";
-        ${$divX} = 3600;
-    }
-    # if less than one day's data plotted, show 2 hourly tics
-    elsif ($timeDiff < 86400) {
-        ${$timeFormat} = "%H:%M";
-        ${$divX} = 7200;
-    }
-    # if less than 1 week's data is data plotted, show daily tics
-    elsif ($timeDiff < 604800) {
-
-        ${$timeFormat} = "%m/%d";
-        ${$divX} = 86400;
-    }
-    else {
-
-        ${$timeFormat} = "%m/%d";
-        ${$divX} = 172800;
-    }
-}
-
-###########################################################################
-#
-# Plots a time-series of pending/faults
-#
-###########################################################################
-sub plotTimeSeries {
-    my ($self, $gnuplotFiles, $outputFile, $label, $fromTime, $toTime, $maxX, $minX, $maxY, $minY, $timeDiff, $isLog) = @_;
-
-    $self->sortOutMaxMinY(\$minY, \$maxY);
-
-    my $timeFormat = undef;
-    my $divX = undef;
-    my $yTitle = undef;
-    if ($isLog) {$yTitle = "Log(Num of Exposures)";}
-    else {$yTitle = "Num of Exposures";}
-    $self->getTimeSpacing($timeDiff, \$divX, \$timeFormat);
-
-    my $numOfPlots = keys %$gnuplotFiles;
-    my $title = undef;
-
-    # sort out plot title
-    if ($numOfPlots == 1) {foreach my $stage (keys %$gnuplotFiles) {$title = "'".$stage."'";}}
-    else {$title = "'All stages'"}
-
-    $title .= " for '$label', '$fromTime' to '$toTime'";
-
-    open (GP, "|/usr/bin/gnuplot -persist") or die "no gnuplot";
-    use FileHandle;
-    GP->autoflush(1);
-
-    print GP
-        "set term $self->{_outputFormat};" .
-        "set output \"$outputFile\";" .
-        "set title \"$title\";" .
-        "set key left top;" .
-        "set xdata time;" .
-        "set timefmt \"$self->{_dateFormat}\";" .
-        #    "set yrange [\"$minY\":\"$maxY\"];" .
-        "set xrange [\"$minX\":\"$maxX\"];" .
-        "set format x \"$timeFormat\";" .
-        "set xtics \"$minX\", $divX, \"$maxX\";" .
-        "set grid xtics;" .
-        "set xlabel \"Time\";" .
-        "set ylabel \"$yTitle\";" .
-        "plot ";
-
-    my $firstIn = 1;
-    foreach my $stage (keys %$gnuplotFiles) {
-        if (!$firstIn) {print GP ",";}
-
-        # for single stage plots, show pending/processed/faults
-        if ($numOfPlots == 1) {
-
-            print GP "'" . $gnuplotFiles->{$stage} . "' using 1:4 title \"Processed\" with lines lt 2 lw 2,";
-            print GP "'" . $gnuplotFiles->{$stage} . "' using 1:2 title \"Pending\" with lines lt 4 lw 2,";
-            print GP "'" . $gnuplotFiles->{$stage} . "' using 1:3 title \"Faults\" with lines lt 7 lw 2";
-        }
-        # when plotting multiple stages, show only processed
-        else {
-            print GP "'" . $gnuplotFiles->{$stage} . "' using 1:4 title \"$stage\" with lines lw 2";
-        }
-        $firstIn = 0;
-    }
-
-    print GP "\n";
-    close GP;
-}
-
-###########################################################################
-#
-# Plots a time-series of cluster storage
-#
-###########################################################################
-sub plotStorageTimeSeries {
-    my ($self, $fromTime, $toTime) = @_;
-
-    my $prefix = $self->{_outputPath} ? $self->{_outputPath} : ".";
-    my $outputFile = "$prefix/czarplot_cluster.png";
-    my ($minX, $maxX, $minY, $maxY, $timeDiff);
-
-    my $gnuplotFile = $self->{_czarDb}->createStorageTimeSeriesData($fromTime, $toTime, \$minX, \$maxX, \$minY, \$maxY, \$timeDiff);
-
-    $self->sortOutMaxMinY(\$minY, \$maxY);
-
-    my $timeFormat = undef;
-    my $divX = undef;
-
-    $self->getTimeSpacing($timeDiff, \$divX, \$timeFormat);
-
-    open (GP, "|/usr/bin/gnuplot -persist") or die "no gnuplot";
-    use FileHandle;
-    GP->autoflush(1);
-
-    print GP
-        "set term $self->{_outputFormat};" .
-        "set output \"$outputFile\";" .
-        "set title \"Total available cluster space over time\";" .
-        "set key left top;" .
-        "set xdata time;" .
-        "set timefmt \"$self->{_dateFormat}\";" .
-        "set xrange [\"$minX\":\"$maxX\"];" .
-        "set yrange [\"$minY\":\"$maxY\"];" .
-        "set format x \"$timeFormat\";" .
-        "set xtics \"$minX\", $divX, \"$maxX\";" .
-        "set grid xtics;" .
-        "set xlabel \"Time\";" .
-        "set ylabel \"Available (TB)\";" .
-        "plot " . 
-#        "'$gnuplotFile' using 1:2 title \"Total\" with lines lt 1," .
-        "'$gnuplotFile' using 1:2 title \"Available\" with lines lt 2\n";
-
-    print GP "\n";
-    close GP;
-}
-
-###########################################################################
-#
-# Plots a histogram of processed stuff
-#
-###########################################################################
-sub plotHistogram {
-    my ($self, $inputFile, $outputFile, $label, $fromTime, $toTime) = @_;
-
-    open (GP, "|/usr/bin/gnuplot -persist") or die "no gnuplot";
-    use FileHandle;
-    GP->autoflush(1);
-
-    print GP
-        "set term $self->{_outputFormat};" .
-        "set output \"$outputFile\";" .
-        "set title \"'$label', '$fromTime' to '$toTime'\";" .
-        "set grid;" .
-        "set boxwidth;" .
-        "set style data histogram;" .
-        "set style histogram rowstacked;" .
-        "set style fill solid border -1;" .
-        "set ylabel \"Exposures\";" .
-        "set boxwidth 0.75;" .
-        "plot '$inputFile' using 2:xtic(1) title \"Faults\" lt 1, '' using 3 title \"Processed\" lt 2, '' using 4 title \"Pending\" lt 7;" . 
-        "\n";
-
-
-
-    close GP;
-}
-
-###########################################################################
-#
-# Plots disk usage across cluster as a stacked histogram
-#
-###########################################################################
-sub plotDiskUsageHistogram {
-    my ($self) = @_;
-
-    my $prefix = $self->{_outputPath} ? $self->{_outputPath} : "."; # TODO should be function for this
-        my $outputFile = "$prefix/czarplot_hosts_space.png";
-    my $limit = 97.0;
-    my $inputFile = $self->{_czarDb}->createHostsData($limit);
-
-    my $totalUsed = $self->{_czarDb}->getTotalClusterStorageAsPercentage();
-
-    my $totalPercent = sprintf("%.1f%%", $totalUsed);
-
-    open (GP, "|/usr/bin/gnuplot -persist") or die "no gnuplot";
-    use FileHandle;
-    GP->autoflush(1);
-
-    print GP
-        "set term $self->{_outputFormat};" .
-        "set output \"$outputFile\";" .
-        "set title \"Nebulous disk use across IPP cluster ($totalPercent of total allocated)\";" .
-        "set style fill solid 1.00 border -1;" .
-        "set style histogram rowstacked;" .
-        "set style data histograms;" .
-        "set ylabel \"Space (TB)\";" .
-        "set xtic rotate by -90 scale 0;" .
-        "plot '$inputFile' " .
-        "using 2:xtic(1) t \"Used\" lt 7," .
-        "'' using 3 t \"Over $limit% used\" lt 1," . 
-        "'' using 4 t \"Unavailable\" fs solid 0.50 lt -1 ," . 
-        "'' using 5 t \"Free\" lt 2," . 
-        "'' using 6 notitle fs solid 0.50 lt -1" . 
-        ";" .
-
-        "\n";
-
-    close GP;
-}
-1;
Index: /trunk/tools/czartool/Plotter.pm
===================================================================
--- /trunk/tools/czartool/Plotter.pm	(revision 29118)
+++ /trunk/tools/czartool/Plotter.pm	(revision 29118)
@@ -0,0 +1,423 @@
+#!/usr/bin/perl -w
+package czartool::Plotter;
+
+use warnings;
+use strict;
+
+my @allStages = ("burntool", "chip", "cam", "fake", "warp", "stack", "diff", "magic", "magicDS", "dist");
+
+
+###########################################################################
+#
+# Constructor
+#
+###########################################################################
+sub new {
+    my $class = shift;
+    my $self = {
+        _czarDb => shift,
+        _dateFormat => shift,
+        _outputFormat => shift,
+        _outputPath => shift,
+        _save_temps => shift,
+    };
+
+    bless $self, $class;
+    return $self;
+}
+
+###########################################################################
+#
+# Generates a suitable filename for this plot
+#
+###########################################################################
+sub createImageFileName {
+    my ($self, $label, $stage, $suffix, $isLog) = @_;
+
+    my $prefix = $self->{_outputPath} ? $self->{_outputPath} : ".";
+    my $stagePart = $stage ? $stage : "all_stages";
+    my $type = $isLog ? "log" : "linear";
+    return $prefix . "/czarplot_" . $type . "_" . $label . "_" . $stagePart . "_$suffix.png";
+}
+
+###########################################################################
+#
+# Plots a time series for all stages for this label, bith log and linear
+#
+###########################################################################
+sub createLogAndLinearTimeSeries {
+    my ($self, $label, $selectedStage, $beginTime, $endTime) = @_;
+
+    $self->createTimeSeries($label, $selectedStage, $beginTime, $endTime, 1);
+    $self->createTimeSeries($label, $selectedStage, $beginTime, $endTime, 0);
+}
+
+###########################################################################
+#
+# Plots a time series for all stages for this label
+#
+###########################################################################
+sub createTimeSeries {
+    my ($self, $label, $selectedStage, $beginTime, $endTime, $isLog) = @_;
+
+    my ($minX, $maxX, $minY, $maxY, $timeDiff);
+    $minX = 999999999;      
+    $maxX = -9999999999;
+    $minY = 999999999;          
+    $maxY = -99999999;
+    $timeDiff = 0;
+
+    my $stages = undef;                 
+
+    if (!$selectedStage) {$stages = \@allStages;}
+    else {$stages = ["$selectedStage"]};        
+
+    my %gnuplotFiles;
+    my $stage = undef;
+    my $gnuplotFile = undef;
+    foreach $stage (@{$stages}) {
+
+        if($self->{_czarDb}->createTimeSeriesData(
+                    $label, 
+                    $stage, 
+                    $beginTime, 
+                    $endTime, 
+                    \$minX, 
+                    \$maxX, 
+                    \$minY, 
+                    \$maxY, 
+                    \$timeDiff, 
+                    \$gnuplotFile,
+                    $isLog)) {
+
+            $gnuplotFiles{$stage} = $gnuplotFile;
+        }
+    }                                                           
+
+    my $numOfPlots =  keys(%gnuplotFiles);
+
+    if ($numOfPlots == 0 ) {
+
+        print "Warning: No plots could be generated for stage '$selectedStage' and label '$label' during time period '$beginTime', '$endTime'\n";
+        return;
+    } 
+
+    if ($timeDiff == 0) {
+
+        print "WARNING: Zero time difference for '$label' during time period '$beginTime', '$endTime'\n";
+        return;
+    }
+
+    my $outputFile = createImageFileName($self, $label, $selectedStage, "t", $isLog);
+    $self->plotTimeSeries(
+            \%gnuplotFiles, 
+            $outputFile, 
+            $label, 
+            $beginTime, 
+            $endTime, 
+            $maxX, 
+            $minX, 
+            $maxY, 
+            $minY, 
+            $timeDiff, 
+            $isLog);
+}                                                    
+
+###########################################################################
+#
+# Plots a histogram of stuff processed in provided interval and label for all stages
+#
+###########################################################################
+sub createHistogram {
+    my ($self, $label, $beginTime, $endTime) = @_;
+
+    my $outputFile = createImageFileName($self, $label, undef, "h", 0);
+
+    my $inputFile = "/tmp/czarplot_gnuplot_".$label."_h.dat"; # TODO use stage not table
+        open (GNUDAT, ">$inputFile");
+
+    my ($processed, $pending, $faults);
+    my $stage = undef;
+    my $pendingMinusFaults = undef;
+    my $maxY = 0;
+    my $sum;
+    foreach $stage (@allStages) {
+
+        $self->{_czarDb}->countProcessedPendingAndFaults(
+                $label, 
+                $stage, 
+                $beginTime, 
+                $endTime, 
+                \$processed, 
+                \$pending, 
+                \$faults);
+
+        $pendingMinusFaults = $pending - $faults;
+        print GNUDAT "$stage $faults $processed, $pendingMinusFaults\n";
+        my $sum = $faults + $processed + $pendingMinusFaults;
+        if ($sum > $maxY) {$maxY = $sum;}
+    }
+
+    close(GNUDAT);
+
+    plotHistogram($self, $inputFile, $outputFile, $label, $beginTime, $endTime, $maxY);
+    unlink($inputFile);
+}
+
+
+###########################################################################
+#
+# Sets the output path 
+#
+###########################################################################
+sub setOutputFormat {
+    my ($self, $outputFormat) = @_;
+    $self->{_outputFormat} = $outputFormat if defined($outputFormat);
+}           
+
+###########################################################################
+#
+# Sets the output type 
+#
+###########################################################################
+sub setOutputPath {
+    my ($self, $outputPath) = @_;
+    $self->{_outputPath} = $outputPath if defined($outputPath);
+}           
+
+###########################################################################
+#
+# Sets the date format to be used
+#
+###########################################################################
+sub setDateFormat {
+    my ($self, $dateFormat) = @_;
+    $self->{_dateFormat} = $dateFormat if defined($dateFormat);
+    return $self->{_dateFormat};
+}       
+
+###########################################################################
+#
+# Figures out suitable spacing for time tics on time-series pliots
+#
+###########################################################################
+sub getTimeSpacing {
+    my ($self, $timeDiff, $divX, $timeFormat) = @_;
+
+    # if less than a couple of hour's data plotted, show 30 mins tics
+    if ($timeDiff < 7200) {
+        ${$timeFormat} = "%H:%M";
+        ${$divX} = 1800;
+    }
+    # if less than half a day's data plotted, show hourly tics
+    elsif ($timeDiff < 43200) {
+        ${$timeFormat} = "%H:%M";
+        ${$divX} = 3600;
+    }
+    # if less than one day's data plotted, show 2 hourly tics
+    elsif ($timeDiff < 86400) {
+        ${$timeFormat} = "%H:%M";
+        ${$divX} = 7200;
+    }
+    # if less than 1 week's data is data plotted, show daily tics
+    elsif ($timeDiff < 604800) {
+
+        ${$timeFormat} = "%m/%d";
+        ${$divX} = 86400;
+    }
+    else {
+
+        ${$timeFormat} = "%m/%d";
+        ${$divX} = 172800;
+    }
+}
+
+###########################################################################
+#
+# Plots a time-series of pending/faults
+#
+###########################################################################
+sub plotTimeSeries {
+    my ($self, $gnuplotFiles, $outputFile, $label, $fromTime, $toTime, $maxX, $minX, $maxY, $minY, $timeDiff, $isLog) = @_;
+
+    my $timeFormat = undef;
+    my $divX = undef;
+    my $yTitle = undef;
+    if ($isLog) {$yTitle = "Log( numExposures )";}
+    else {$yTitle = "numExposures";}
+    $self->getTimeSpacing($timeDiff, \$divX, \$timeFormat);
+
+    my $numOfPlots = keys %$gnuplotFiles;
+    my $title = undef;
+
+    # sort out plot title
+    if ($numOfPlots == 1) {foreach my $stage (keys %$gnuplotFiles) {$title = "'".$stage."'";}}
+    else {$title = "'All stages'"}
+
+    $title .= " for '$label', '$fromTime' to '$toTime'";
+
+    open (GP, "|/usr/bin/gnuplot -persist") or die "no gnuplot";
+    use FileHandle;
+    GP->autoflush(1);
+
+    print GP
+        "set term $self->{_outputFormat};" .
+        "set output \"$outputFile\";" .
+        "set title \"$title\";" .
+        "set key left top;" .
+        "set xdata time;" .
+        "set timefmt \"$self->{_dateFormat}\";" .
+        "set format x \"$timeFormat\";" .
+        "set xtics \"$minX\", $divX, \"$maxX\";" .
+        "set grid xtics;" .
+        "set xlabel \"Time\";" .
+        "set ylabel \"$yTitle\";" .
+        "plot ";
+
+    my $firstIn = 1;
+    foreach my $stage (keys %$gnuplotFiles) {
+        if (!$firstIn) {print GP ",";}
+
+        # for single stage plots, show pending/processed/faults
+        if ($numOfPlots == 1) {
+
+            print GP "'" . $gnuplotFiles->{$stage} . "' using 1:4 title \"Processed\" with lines lt 2 lw 2,";
+            print GP "'" . $gnuplotFiles->{$stage} . "' using 1:2 title \"Pending\" with lines lt 4 lw 2,";
+            print GP "'" . $gnuplotFiles->{$stage} . "' using 1:3 title \"Faults\" with lines lt 7 lw 2";
+        }
+        # when plotting multiple stages, show only processed
+        else {
+            print GP "'" . $gnuplotFiles->{$stage} . "' using 1:4 title \"$stage\" with lines lw 2";
+        }
+        $firstIn = 0;
+    }
+
+    print GP "\n";
+    close GP;
+
+    # now delete temp dat files
+    foreach my $stage (keys %$gnuplotFiles) {
+
+        unlink($gnuplotFiles->{$stage});
+    }
+}
+
+###########################################################################
+#
+# Plots a time-series of cluster storage
+#
+###########################################################################
+sub plotStorageTimeSeries {
+    my ($self, $fromTime, $toTime) = @_;
+
+    my $prefix = $self->{_outputPath} ? $self->{_outputPath} : ".";
+    my $outputFile = "$prefix/czarplot_cluster.png";
+    my ($minX, $maxX, $minY, $maxY, $timeDiff);
+
+    my $gnuplotFile = $self->{_czarDb}->createStorageTimeSeriesData($fromTime, $toTime, \$minX, \$maxX, \$minY, \$maxY, \$timeDiff);
+
+    my $timeFormat = undef;
+    my $divX = undef;
+
+    $self->getTimeSpacing($timeDiff, \$divX, \$timeFormat);
+
+    open (GP, "|/usr/bin/gnuplot -persist") or die "no gnuplot";
+    use FileHandle;
+    GP->autoflush(1);
+
+    print GP
+        "set term $self->{_outputFormat};" .
+        "set output \"$outputFile\";" .
+        "set title \"Total available cluster space over time\";" .
+        "set key left top;" .
+        "set xdata time;" .
+        "set timefmt \"$self->{_dateFormat}\";" .
+        "set format x \"$timeFormat\";" .
+        "set xtics \"$minX\", $divX, \"$maxX\";" .
+        "set grid xtics;" .
+        "set xlabel \"Time\";" .
+        "set ylabel \"Available (TB)\";" .
+        "plot " . 
+        "'$gnuplotFile' using 1:2 title \"Available\" with lines lt 2 lw 2\n";
+
+    print GP "\n";
+    close GP;
+    unlink($gnuplotFile);
+}
+
+###########################################################################
+#
+# Plots a histogram of processed stuff
+#
+###########################################################################
+sub plotHistogram {
+    my ($self, $inputFile, $outputFile, $label, $fromTime, $toTime, $maxY) = @_;
+
+    open (GP, "|/usr/bin/gnuplot -persist") or die "no gnuplot";
+    use FileHandle;
+    GP->autoflush(1);
+
+    if ($maxY == 0) {$maxY = 1;}
+    else {$maxY = $maxY*1.1;}
+
+    print GP
+        "set term $self->{_outputFormat};" .
+        "set output \"$outputFile\";" .
+        "set title \"'$label', '$fromTime' to '$toTime'\";" .
+        "set grid;" .
+        "set boxwidth;" .
+        "set yrange [\"0\":\"$maxY\"];" .
+        "set style data histogram;" .
+        "set style histogram rowstacked;" .
+        "set style fill solid border -1;" .
+        "set ylabel \"Exposures\";" .
+        "set boxwidth 0.75;" .
+        "plot '$inputFile' using 2:xtic(1) title \"Faults\" lt 1, '' using 3 title \"Processed\" lt 2, '' using 4 title \"Pending\" lt 7;" . 
+        "\n";
+
+    close GP;
+}
+
+###########################################################################
+#
+# Plots disk usage across cluster as a stacked histogram
+#
+###########################################################################
+sub plotDiskUsageHistogram {
+    my ($self) = @_;
+
+    my $prefix = $self->{_outputPath} ? $self->{_outputPath} : "."; # TODO should be function for this
+        my $outputFile = "$prefix/czarplot_hosts_space.png";
+    my $limit = 97.0;
+    my $inputFile = $self->{_czarDb}->createHostsData($limit);
+
+    my $totalUsed = $self->{_czarDb}->getTotalClusterStorageAsPercentage();
+
+    my $totalPercent = sprintf("%.1f%%", $totalUsed);
+
+    open (GP, "|/usr/bin/gnuplot -persist") or die "no gnuplot";
+    use FileHandle;
+    GP->autoflush(1);
+
+    print GP
+        "set term $self->{_outputFormat};" .
+        "set output \"$outputFile\";" .
+        "set title \"Nebulous disk use across IPP cluster ($totalPercent of total allocated)\";" .
+        "set style fill solid 1.00 border -1;" .
+        "set style histogram rowstacked;" .
+        "set style data histograms;" .
+        "set ylabel \"Space (TB)\";" .
+        "set xtic rotate by -90 scale 0;" .
+        "plot '$inputFile' " .
+        "using 2:xtic(1) t \"Used\" lt 7," .
+        "'' using 3 t \"Over $limit% used\" lt 1," . 
+        "'' using 4 t \"Unavailable\" fs solid 0.50 lt -1 ," . 
+        "'' using 5 t \"Free\" lt 2," . 
+        "'' using 6 notitle fs solid 0.50 lt -1" . 
+        ";" .
+
+        "\n";
+
+    close GP;
+}
+1;
