Index: trunk/scripts/munin/web/all-usage.cgi
===================================================================
--- trunk/scripts/munin/web/usage.cgi	(revision 1788)
+++ trunk/scripts/munin/web/all-usage.cgi	(revision 2058)
@@ -21,6 +21,6 @@
 --lower-limit 0
 --vertical-label %
---height 175
---width 400
+--height 600
+--width 800
 --units-exponent 0));
 
@@ -43,24 +43,33 @@
 $days = int($1);
 
-my $uuid = $q->param("uuid");
-$uuid =~ m|^([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})$| or die "Invalid UUID specified";
-$uuid = "$1_$2_$3_$4_$5";
-
 my $type = $q->param("type") || "cpu";
 $type =~ m|^(\w+)$| or die "Invalid graph type";
 $type = $graph_types{$1} or die "Invalid graph type";
 
-my $path = catfile(GRAPH_DIR, "*-$type-$uuid-?.rrd");
+my $path = catfile(GRAPH_DIR, "*-$type-????????_????_????_????_????????????-?.rrd");
 my @files = glob $path or die "No data found";
 
 push @args, "--start", "-".$days."d";
 
-foreach my $i (0..$#files) {
-  $files[$i] =~ m|^([^:]+)$|;
-  push @args, "DEF:odata$i=$1:42:AVERAGE";
-  push @args, "CDEF:data$i=odata$i,UN,0,odata$i,IF,10000,/";
+my %uuids = map { m|(........_...._...._...._............)-.\.rrd$|; $1, 1 } @files;
+
+# Color list shamelessly stolen from munin-graph
+my @COLOUR = ("#22ff22", "#0022ff", "#ff0000", "#00aaaa", "#ff00ff",
+              "#ffa500", "#cc0000", "#0000cc", "#0080C0", "#8080C0", "#FF0080",
+              "#800080", "#688e23", "#408080", "#808000", "#000000", "#00FF00",
+              "#0080FF", "#FF8000", "#800000", "#FB31FB");
+my $color_index = 0;
+
+foreach my $uuid (keys %uuids) {
+  my @uuid_files = grep { m|$uuid-.\.rrd$| } @files;
+  foreach my $i (0..$#uuid_files) {
+    $uuid_files[$i] =~ m|^([^:]+)$|;
+    push @args, "DEF:odata_${uuid}_$i=$1:42:AVERAGE";
+    push @args, "CDEF:data_${uuid}_$i=odata_${uuid}_$i,UN,0,odata_${uuid}_$i,IF,10000,/";
+  }
+  push @args, "CDEF:total_${uuid}=0,".join(",+,", map {"data_${uuid}_$_"} 0..$#uuid_files).",+";
+  push @args, "AREA:total_${uuid}".$COLOUR[($color_index++)%@COLOUR]."::STACK";
+  # print STDERR "VM $uuid: @uuid_files\n";
 }
-push @args, "CDEF:total=0,".join(",+,", map {"data$_"} 0..$#files).",+";
-push @args, "AREA:total#0000FF";
 
 $ENV{"PATH"} = "/usr/local/bin:/usr/bin:/bin";
