Zoomed graphs in 'proc.pm' now honour the 'global_zoom' option, and they also use the function RRDs::graphv to fit better in the browser pop up window (only for RRDtool v1.3+)

This commit is contained in:
Jordi Sanfeliu 2014-12-30 17:07:42 +01:00
parent b8a6c984a2
commit 1552587d24
1 changed files with 23 additions and 3 deletions

View File

@ -243,6 +243,8 @@ sub proc_update {
}
sub proc_cgi {
no strict "refs";
my ($package, $config, $cgi) = @_;
my $proc = $config->{proc};
@ -254,6 +256,15 @@ sub proc_cgi {
my $graph = $cgi->{graph};
my $silent = $cgi->{silent};
my $zoom = "--zoom=" . $config->{global_zoom};
my %rrd = (
'new' => \&RRDs::graphv,
'old' => \&RRDs::graph,
);
my $version = "new";
my $pic;
my $picz;
my $picz_width;
my $picz_height;
my $u = "";
my $width;
@ -271,6 +282,7 @@ sub proc_cgi {
my $str;
my $err;
$version = "old" if $RRDs::VERSION < 1.3;
my $rrd = $config->{base_lib} . $package . ".rrd";
my $title = $config->{graph_title}->{$package};
my $PNG_DIR = $config->{base_dir} . "/" . $config->{imgs_dir};
@ -602,7 +614,7 @@ sub proc_cgi {
}
($width, $height) = split('x', $config->{graph_size}->{$proc->{size}});
RRDs::graph("$PNG_DIR" . "$PNG[$n]",
$pic = $rrd{$version}->("$PNG_DIR" . "$PNG[$n]",
"--title=$config->{graphs}->{_proc} $n ($tf->{nwhen}$tf->{twhen})",
"--start=-$tf->{nwhen}$tf->{twhen}",
"--imgformat=PNG",
@ -629,7 +641,7 @@ sub proc_cgi {
print("ERROR: while graphing $PNG_DIR" . "$PNG[$n]: $err\n") if $err;
if(lc($config->{enable_zoom}) eq "y") {
($width, $height) = split('x', $config->{graph_size}->{zoom});
RRDs::graph("$PNG_DIR" . "$PNGz[$n]",
$picz = $rrd{$version}->("$PNG_DIR" . "$PNGz[$n]",
"--title=$config->{graphs}->{_proc} $n ($tf->{nwhen}$tf->{twhen})",
"--start=-$tf->{nwhen}$tf->{twhen}",
"--imgformat=PNG",
@ -637,6 +649,7 @@ sub proc_cgi {
"--width=$width",
"--height=$height",
@riglim,
$zoom,
@{$cgi->{version12}},
@{$cgi->{version12_small}},
@{$colors->{graph_colors}},
@ -660,7 +673,14 @@ sub proc_cgi {
print(" <a href=\"" . $config->{url} . "/" . $config->{imgs_dir} . $PNGz[$n] . "\"><img src='" . $config->{url} . "/" . $config->{imgs_dir} . $PNG[$n] . "' border='0'></a>\n");
}
else {
print(" <a href=\"javascript:void(window.open('" . $config->{url} . "/" . $config->{imgs_dir} . $PNGz[$n] . "','','width=" . ($width + 115) . ",height=" . ($height + 100) . ",scrollbars=0,resizable=0'))\"><img src='" . $config->{url} . "/" . $config->{imgs_dir} . $PNG[$n] . "' border='0'></a>\n");
if($version eq "new") {
$picz_width = $picz->{image_width} * $config->{global_zoom};
$picz_height = $picz->{image_height} * $config->{global_zoom};
} else {
$picz_width = $width + 115;
$picz_height = $height + 100;
}
print(" <a href=\"javascript:void(window.open('" . $config->{url} . "/" . $config->{imgs_dir} . $PNGz[$n] . "','','width=" . $picz_width . ",height=" . $picz_height . ",scrollbars=0,resizable=0'))\"><img src='" . $config->{url} . "/" . $config->{imgs_dir} . $PNG[$n] . "' border='0'></a>\n");
}
} else {
print(" <img src='" . $config->{url} . "/" . $config->{imgs_dir} . $PNG[$n] . "'>\n");