Changeset 2058 for trunk/scripts
- Timestamp:
- Jan 31, 2009, 7:13:52 AM (16 years ago)
- File:
-
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/scripts/munin/web/all-usage.cgi
r1788 r2058 21 21 --lower-limit 0 22 22 --vertical-label % 23 --height 17524 --width 40023 --height 600 24 --width 800 25 25 --units-exponent 0)); 26 26 … … 43 43 $days = int($1); 44 44 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 49 45 my $type = $q->param("type") || "cpu"; 50 46 $type =~ m|^(\w+)$| or die "Invalid graph type"; 51 47 $type = $graph_types{$1} or die "Invalid graph type"; 52 48 53 my $path = catfile(GRAPH_DIR, "*-$type- $uuid-?.rrd");49 my $path = catfile(GRAPH_DIR, "*-$type-????????_????_????_????_????????????-?.rrd"); 54 50 my @files = glob $path or die "No data found"; 55 51 56 52 push @args, "--start", "-".$days."d"; 57 53 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,/"; 54 my %uuids = map { m|(........_...._...._...._............)-.\.rrd$|; $1, 1 } @files; 55 56 # Color list shamelessly stolen from munin-graph 57 my @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"); 61 my $color_index = 0; 62 63 foreach 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"; 62 73 } 63 push @args, "CDEF:total=0,".join(",+,", map {"data$_"} 0..$#files).",+";64 push @args, "AREA:total#0000FF";65 74 66 75 $ENV{"PATH"} = "/usr/local/bin:/usr/bin:/bin";
Note: See TracChangeset
for help on using the changeset viewer.