Changeset 1763

Show
Ignore:
Timestamp:
12/03/08 17:02:06 (1 month ago)
Author:
jlmartinez
Message:

/rrdgraph

new legend type
param legend can have value 2

this activates legend with min max and avg values for each metric displayed. Still have to adjust the width of the COMMENT that adjusts the "Max Min Avg" titles.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/DEV-capside/opsview-web/lib/Opsview/Web/Controller/RRDgraph.pm

    r1756 r1763  
    8989        # List of datapoints 
    9090        my $ds = {}; 
     91        my $max_legend_length = 0; 
    9192        my @auth_errors; 
    9293        foreach my $host (@$hosts) { 
     
    153154                        my $vname = "$hash->{host}-$hash->{service}-$dsname"; 
    154155                        $vname =~ s/[^a-zA-Z0-9-_]/_/g; 
    155  
     156                        $hash->{'vname'} = $vname; 
     157                         
    156158                        my $legend = ""; 
    157                         if ($showlegend) { 
     159                        if ($showlegend == 1 or $showlegend == 2) { 
    158160                                # $displayname is a calculated name, based on whether there are multiple hosts/services or not 
    159161                                my $displayname = $dsname; 
     
    167169                                $displayname =~ s/\:/\\:/g; 
    168170                                $legend = "$displayname"; 
    169                         } 
    170  
     171                                $hash->{'displayname'} = $displayname; 
     172                                $hash->{'legend'}      = $legend; 
     173 
     174                                $max_legend_length = length($legend) if (length($legend) > $max_legend_length); 
     175                        } 
     176                } 
     177        } 
     178 
     179        @colours = split(",", $colours) unless (@colours); 
     180 
     181        if ($showlegend == 2){ 
     182                push @$rrdoptions, "COMMENT:" . (' ' x ($max_legend_length + 4)) . "    Max       Min       Avg\\n"; 
     183        } 
     184         
     185        foreach my $dsname (sort keys %$ds) { 
     186                foreach my $hash (@{ $ds->{$dsname} }) { 
    171187                        my $f = $hash->{file}; 
    172  
    173                         @colours = split(",", $colours) unless (@colours); 
     188                        my $vname = $hash->{'vname'}; 
     189 
    174190                        my $nextcolour = shift @colours; 
     191                        my $fixedw_legend = $hash->{'legend'} . (' ' x ($max_legend_length - length($hash->{'legend'}))); 
    175192                        push @$rrdoptions,  
    176193                                "DEF:$vname=$f:$dsname:AVERAGE", 
    177                                 "$type:$vname#$nextcolour:$legend$stacked"; 
    178                                 #"GPRINT:$vname".':LAST:\tCur\: %6.2lf%s\n'; 
     194                                "$type:$vname#$nextcolour:$fixedw_legend$stacked"; 
     195                        if ($showlegend == 2){ 
     196                                push @$rrdoptions, 
     197                                        "GPRINT:$vname:MAX:%7.02lf", 
     198                                        "GPRINT:$vname:MIN:%7.02lf ", 
     199                                        "GPRINT:$vname:AVERAGE:%7.02lf", 
     200                                        "COMMENT:\\n"; 
     201                        } 
    179202                } 
    180203        }