Changeset 2058 for trunk/scripts/munin


Ignore:
Timestamp:
Jan 31, 2009, 7:13:52 AM (16 years ago)
Author:
quentin
Message:

Add script for graphing every VM at once

File:
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/scripts/munin/web/all-usage.cgi

    r1788 r2058  
    2121--lower-limit 0
    2222--vertical-label %
    23 --height 175
    24 --width 400
     23--height 600
     24--width 800
    2525--units-exponent 0));
    2626
     
    4343$days = int($1);
    4444
    45 my $uuid = $q->param("uuid");
    46 $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";
    47 $uuid = "$1_$2_$3_$4_$5";
    48 
    4945my $type = $q->param("type") || "cpu";
    5046$type =~ m|^(\w+)$| or die "Invalid graph type";
    5147$type = $graph_types{$1} or die "Invalid graph type";
    5248
    53 my $path = catfile(GRAPH_DIR, "*-$type-$uuid-?.rrd");
     49my $path = catfile(GRAPH_DIR, "*-$type-????????_????_????_????_????????????-?.rrd");
    5450my @files = glob $path or die "No data found";
    5551
    5652push @args, "--start", "-".$days."d";
    5753
    58 foreach my $i (0..$#files) {
    59   $files[$i] =~ m|^([^:]+)$|;
    60   push @args, "DEF:odata$i=$1:42:AVERAGE";
    61   push @args, "CDEF:data$i=odata$i,UN,0,odata$i,IF,10000,/";
     54my %uuids = map { m|(........_...._...._...._............)-.\.rrd$|; $1, 1 } @files;
     55
     56# Color list shamelessly stolen from munin-graph
     57my @COLOUR = ("#22ff22", "#0022ff", "#ff0000", "#00aaaa", "#ff00ff",
     58              "#ffa500", "#cc0000", "#0000cc", "#0080C0", "#8080C0", "#FF0080",
     59              "#800080", "#688e23", "#408080", "#808000", "#000000", "#00FF00",
     60              "#0080FF", "#FF8000", "#800000", "#FB31FB");
     61my $color_index = 0;
     62
     63foreach my $uuid (keys %uuids) {
     64  my @uuid_files = grep { m|$uuid-.\.rrd$| } @files;
     65  foreach my $i (0..$#uuid_files) {
     66    $uuid_files[$i] =~ m|^([^:]+)$|;
     67    push @args, "DEF:odata_${uuid}_$i=$1:42:AVERAGE";
     68    push @args, "CDEF:data_${uuid}_$i=odata_${uuid}_$i,UN,0,odata_${uuid}_$i,IF,10000,/";
     69  }
     70  push @args, "CDEF:total_${uuid}=0,".join(",+,", map {"data_${uuid}_$_"} 0..$#uuid_files).",+";
     71  push @args, "AREA:total_${uuid}".$COLOUR[($color_index++)%@COLOUR]."::STACK";
     72  # print STDERR "VM $uuid: @uuid_files\n";
    6273}
    63 push @args, "CDEF:total=0,".join(",+,", map {"data$_"} 0..$#files).",+";
    64 push @args, "AREA:total#0000FF";
    6574
    6675$ENV{"PATH"} = "/usr/local/bin:/usr/bin:/bin";
Note: See TracChangeset for help on using the changeset viewer.