Ticket #480: munin-html-use-cache-img-size-for-cgi.diff

File munin-html-use-cache-img-size-for-cgi.diff, 2.7 kB (added by blueyed, 4 years ago)

Patch to use the image size for existing files also for "cgi". Additionally removes obsolete calculate_png_size function

  • server/munin-html.in

    old new  
    216216    } 
    217217} 
    218218 
    219 sub calculate_png_size 
    220 { 
    221         my $config = shift; 
    222         my $domain = shift; 
    223         my $node   = shift; 
    224         my $serv   = shift; 
    225  
    226         # base size of graph rectangle + space outside graph rectangle 
    227         my $height = munin_get ($config, "graph_height", 100, $domain, $node, $serv) + 156; 
    228         my $width  = munin_get ($config, "graph_width" , 400, $domain, $node, $serv) + 93; 
    229  
    230         # In addition, the height increases by 15 pixels for each label underneath 
    231         foreach my $field (keys %{$config->{domain}->{$domain}->{node}->{$node}->{client}->{$serv}}) 
    232         { 
    233             if ($field =~ /^([^\.]+)\.label/) 
    234             { 
    235                 if (munin_draw_field ($config->{domain}->{$domain}->{node}->{$node}, $serv, $1)) 
    236                 { 
    237                     $height += 15; 
    238                     my $tmpline = munin_get ($config, "line", undef, $domain, $node, $serv, $1); 
    239                     if ($tmpline) 
    240                     { 
    241                         my @tmparr = ($tmpline =~ /:/g); 
    242                         if (scalar (@tmparr) > 2) 
    243                         { # We've got line definitions with labels... 
    244                             $height += 15; 
    245                         } 
    246                     } 
    247                 } 
    248             } 
    249         } 
    250         # ...and +15 if there's a graph total 
    251         $height += 15 if (munin_get ($config, "graph_total", undef, $domain, $node, $serv)); 
    252         # ...and +15 if there's min/max-headers above the labels 
    253         $height += 15 if (munin_graph_column_headers ($config, $domain, $node, $serv)); 
    254  
    255         return ($width, $height); 
    256 } 
    257  
    258219sub get_png_size 
    259220{ 
    260221        my $filename = shift; 
     
    574535        $srv{'cimgweek'} ="$parent/$srv{node}-week.png"; 
    575536        $srv{'cimgmonth'}="$parent/$srv{node}-month.png"; 
    576537        $srv{'cimgyear'} ="$parent/$srv{node}-year.png"; 
     538    } 
    577539 
    578         for my $scale (@times) { 
    579             if (my ($w, $h) = get_png_size(munin_get_picture_filename($service, $scale))) { 
     540    for my $scale (@times) { 
     541        if (my ($w, $h) = get_png_size(munin_get_picture_filename($service, $scale))) { 
     542            if ($w and $h) { 
    580543                $srv{"img".$scale."width"} = $w; 
    581544                $srv{"img".$scale."height"} = $h; 
    582545            } 
    583546        } 
     547    } 
    584548 
    585         if (munin_get_bool ($service, "graph_sums", 0)) { 
    586             $srv{imgweeksum} = "$srv{node}-week-sum.png"; 
    587             $srv{imgyearsum} = "$srv{node}-year-sum.png"; 
    588             for my $scale (["week", "year"]) { 
    589                 if (my ($w, $h) = get_png_size (munin_get_picture_filename($service, $scale, 1))) { 
     549    if (munin_get_bool ($service, "graph_sums", 0)) { 
     550        $srv{imgweeksum} = "$srv{node}-week-sum.png"; 
     551        $srv{imgyearsum} = "$srv{node}-year-sum.png"; 
     552        for my $scale (["week", "year"]) { 
     553            if (my ($w, $h) = get_png_size (munin_get_picture_filename($service, $scale, 1))) { 
     554                if ($w and $h) { 
    590555                    $srv{"img".$scale."sumwidth"} = $w; 
    591556                    $srv{"img".$scale."sumheight"} = $h; 
    592557                }