Index: trunk/tools/czartool.pl
===================================================================
--- trunk/tools/czartool.pl	(revision 27860)
+++ trunk/tools/czartool.pl	(revision 27861)
@@ -118,5 +118,5 @@
 
     my $item;
-    foreach $item (@array1, @array2) { $count{$item}++;}
+    foreach $item (@array1, @array2) {$count{$item}++;}
 
     foreach $item (keys %count) {
@@ -350,8 +350,9 @@
     elsif ($stage eq "magic") {$joinTable="magicNodeResult";}
     elsif ($stage eq "magicDS") {$id = "magic_ds_id"; $joinTable="magicDSFile";}
-    elsif ($stage eq "dist") {return countDistFaults($label);}
+    elsif ($stage eq "dist") {$joinTable="distComponent";}
     else {return -1;}
 
     my $faultCol =  $joinTable.".fault";
+    my $stateCol =  $table.".state";
 
     my $query = $db->prepare(<<SQL);
@@ -361,5 +362,5 @@
         WHERE label LIKE '$label'
         AND $faultCol != 0
-        AND state = 'new'
+        AND $stateCol = 'new'
 
 SQL
@@ -369,37 +370,2 @@
 }
 
-###########################################################################
-#
-# Counts total distribution faults
-#
-###########################################################################
-sub countDistFaults {
-    my ($label) = @_;
-
-    my $query = $db->prepare(<<SQL);
-    SELECT COUNT(*) 
-        FROM distRun 
-        JOIN distComponent USING(dist_id) 
-        WHERE label LIKE '$label' 
-        AND distComponent.fault > 0
-        AND distRun.state = 'new'
-
-SQL
-
-        $query->execute;
-    my $count = $query->fetchrow_array();
-
-    $query = $db->prepare(<<SQL);
-    SELECT COUNT(*) 
-        FROM distRun 
-        WHERE label LIKE '$label' 
-        AND fault > 0
-        AND distRun.state = 'new'
-
-SQL
-
-        $query->execute;
-
-    return $count + $query->fetchrow_array();
-}
-
