Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

master: get graph width/height for html in graph-cgi mode also #1498

Open
wants to merge 1 commit into
base: stable-2.0
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions master/lib/Munin/Master/HTMLConfig.pm
Original file line number Diff line number Diff line change
Expand Up @@ -511,8 +511,14 @@ sub generate_service_templates {
$srv{zoomyear} = "$common_url&start_epoch=$start_year&stop_epoch=$epoch_now";
}

my $svccfg = { %$service };
if ( munin_get($config, "graph_strategy", "cron") eq "cgi" ) {
my $cgitmpdir = munin_get($config, "cgitmpdir", "$Munin::Common::Defaults::MUNIN_DBDIR/cgi-tmp");
$svccfg->{htmldir} = $cgitmpdir . "/munin-cgi-graph";
}

for my $scale (@times) {
my ($w, $h) = get_png_size(munin_get_picture_filename($service, $scale));
my ($w, $h) = get_png_size(munin_get_picture_filename($svccfg, $scale));
if ($w && $h) {
$srv{"img" . $scale . "width"} = $w;
$srv{"img" . $scale . "height"} = $h;
Expand All @@ -524,7 +530,7 @@ sub generate_service_templates {
$srv{imgyearsum} = "$srv{node}-year-sum.png";

for my $scale (["week", "year"]) {
my ($w, $h) = get_png_size(munin_get_picture_filename($service, $scale, 1));
my ($w, $h) = get_png_size(munin_get_picture_filename($svccfg, $scale, 1));
if ($w && $h) {
$srv{"img" . $scale . "sumwidth"} = $w;
$srv{"img" . $scale . "sumheight"} = $h;
Expand Down Expand Up @@ -725,14 +731,11 @@ sub borrowed_path {
}
}

#TODO: This method is obsolete when cgi-graphing is the only strategy left
sub get_png_size {
my $filename = shift;
my $width = undef;
my $height = undef;

return (undef, undef) if (munin_get($config, "graph_strategy", "cron") eq "cgi") ;

if (open(my $PNG, '<', $filename)) {
my $incoming;
binmode($PNG);
Expand Down