--- collection.cgi.orig 2010-04-06 20:58:50.000000000 +0200 +++ collection.cgi 2010-04-06 21:07:07.000000000 +0200 @@ -763,8 +763,10 @@ sub action_show_graph return $MetaGraphDefs->{$type}->($host, $plugin, $plugin_instance, $type, $types{$type}); } - return if (!defined ($GraphDefs->{$type})); - @rrd_args = @{$GraphDefs->{$type}}; + if (defined ($GraphDefs->{$type})) + { + @rrd_args = @{$GraphDefs->{$type}}; + } $title = "$host/$plugin" . (defined ($plugin_instance) ? "-$plugin_instance" : '') . "/$type" . (defined ($type_instance) ? "-$type_instance" : ''); @@ -774,6 +776,38 @@ sub action_show_graph my $file = $DataDirs[$i] . "/$title.rrd"; next if (!-f $file); + # generate generic rrdargs if no known definition exists (needs to be done per file) + if (not defined ($GraphDefs->{$type})) + { + my $Canvas = 'FFFFFF'; + my @FullColors = ('0000FF', '00E000', 'FF0000', 'F0A000', '00A0FF', 'A000FF'); + my @HalfColors = ('B7B7F7', 'B7EFB7', 'F7B7B7', 'F3DFB7', 'B7DFF7', 'DFB7F7'); + my $ColorCount = 0; + + my $rrd_info = RRDs::info($file); + foreach my $info (keys %$rrd_info) { + if ($info =~ m/^ds\[(.*)\].type$/) + { + my $value = $1; + push (@rrd_args, ( + "DEF:avg$ColorCount={file}:$value:AVERAGE", + "DEF:min$ColorCount={file}:$value:MIN", + "DEF:max$ColorCount={file}:$value:MAX", + "AREA:max$ColorCount#".($HalfColors[$ColorCount % 6]), + "AREA:min$ColorCount#$Canvas", + "LINE1:avg$ColorCount#".($FullColors[$ColorCount % 6]).":". + ($value eq "value" ? "$type".(defined ($type_instance) ? "-$type_instance" : '') : "$value"), + "GPRINT:min$ColorCount:MIN:\%5.1lf\%s Min,", + "GPRINT:avg$ColorCount:AVERAGE:\%5.1lf\%s Avg,", + "GPRINT:max$ColorCount:MAX:\%5.1lf\%s Max,", + "GPRINT:avg$ColorCount:LAST:\%5.1lf\%s Last\\n" + ) + ); + $ColorCount++; + } + } + } + $file =~ s/:/\\:/g; s/{file}/$file/ for (@rrd_args);