At present graph.cgi is extremely slowly on servers with large numbers of
RRD files.  This is because it issues an unnecessary stat() call to _every_
RRD file on the local system before loading and rendering graph data.
Patch originally from:
http://mailman.verplant.org/pipermail/collectd/2011-May/004519.html
The patch was improved so that it correctly handles multiple hostnames.
I'm seeing a 5x improvement in speed, the original patch creator
had a 24x speedup.
   my $ident = shift;
   my $all_files;
   my @ret = ();
+  my $temp;
+  my $hosts;
 
   my $cache_key = ident_to_string ($ident);
   if (defined ($Cache->{'get_files_by_ident'}{$cache_key}))
     return ($ret)
   }
 
-  $all_files = _get_all_files ();
+  if ($ident->{'hostname'})
+  {
+    $all_files = [];
+    $hosts = $ident->{'hostname'};
+    foreach (@$hosts)
+    {
+      $temp = get_files_for_host ($_);
+      push (@$all_files, @$temp);
+    }
+  }
+  else
+  {
+    $all_files = _get_all_files ();
+  }
 
   @ret = grep { _filter_ident ($ident, $_) == 0 } (@$all_files);