mirror of https://github.com/mikaku/Monitorix.git
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:
parent
b8a6c984a2
commit
1552587d24
26
lib/proc.pm
26
lib/proc.pm
|
@ -243,6 +243,8 @@ sub proc_update {
|
||||||
}
|
}
|
||||||
|
|
||||||
sub proc_cgi {
|
sub proc_cgi {
|
||||||
|
no strict "refs";
|
||||||
|
|
||||||
my ($package, $config, $cgi) = @_;
|
my ($package, $config, $cgi) = @_;
|
||||||
|
|
||||||
my $proc = $config->{proc};
|
my $proc = $config->{proc};
|
||||||
|
@ -254,6 +256,15 @@ sub proc_cgi {
|
||||||
my $graph = $cgi->{graph};
|
my $graph = $cgi->{graph};
|
||||||
my $silent = $cgi->{silent};
|
my $silent = $cgi->{silent};
|
||||||
my $zoom = "--zoom=" . $config->{global_zoom};
|
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 $u = "";
|
||||||
my $width;
|
my $width;
|
||||||
|
@ -271,6 +282,7 @@ sub proc_cgi {
|
||||||
my $str;
|
my $str;
|
||||||
my $err;
|
my $err;
|
||||||
|
|
||||||
|
$version = "old" if $RRDs::VERSION < 1.3;
|
||||||
my $rrd = $config->{base_lib} . $package . ".rrd";
|
my $rrd = $config->{base_lib} . $package . ".rrd";
|
||||||
my $title = $config->{graph_title}->{$package};
|
my $title = $config->{graph_title}->{$package};
|
||||||
my $PNG_DIR = $config->{base_dir} . "/" . $config->{imgs_dir};
|
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}});
|
($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})",
|
"--title=$config->{graphs}->{_proc} $n ($tf->{nwhen}$tf->{twhen})",
|
||||||
"--start=-$tf->{nwhen}$tf->{twhen}",
|
"--start=-$tf->{nwhen}$tf->{twhen}",
|
||||||
"--imgformat=PNG",
|
"--imgformat=PNG",
|
||||||
|
@ -629,7 +641,7 @@ sub proc_cgi {
|
||||||
print("ERROR: while graphing $PNG_DIR" . "$PNG[$n]: $err\n") if $err;
|
print("ERROR: while graphing $PNG_DIR" . "$PNG[$n]: $err\n") if $err;
|
||||||
if(lc($config->{enable_zoom}) eq "y") {
|
if(lc($config->{enable_zoom}) eq "y") {
|
||||||
($width, $height) = split('x', $config->{graph_size}->{zoom});
|
($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})",
|
"--title=$config->{graphs}->{_proc} $n ($tf->{nwhen}$tf->{twhen})",
|
||||||
"--start=-$tf->{nwhen}$tf->{twhen}",
|
"--start=-$tf->{nwhen}$tf->{twhen}",
|
||||||
"--imgformat=PNG",
|
"--imgformat=PNG",
|
||||||
|
@ -637,6 +649,7 @@ sub proc_cgi {
|
||||||
"--width=$width",
|
"--width=$width",
|
||||||
"--height=$height",
|
"--height=$height",
|
||||||
@riglim,
|
@riglim,
|
||||||
|
$zoom,
|
||||||
@{$cgi->{version12}},
|
@{$cgi->{version12}},
|
||||||
@{$cgi->{version12_small}},
|
@{$cgi->{version12_small}},
|
||||||
@{$colors->{graph_colors}},
|
@{$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");
|
print(" <a href=\"" . $config->{url} . "/" . $config->{imgs_dir} . $PNGz[$n] . "\"><img src='" . $config->{url} . "/" . $config->{imgs_dir} . $PNG[$n] . "' border='0'></a>\n");
|
||||||
}
|
}
|
||||||
else {
|
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 {
|
} else {
|
||||||
print(" <img src='" . $config->{url} . "/" . $config->{imgs_dir} . $PNG[$n] . "'>\n");
|
print(" <img src='" . $config->{url} . "/" . $config->{imgs_dir} . $PNG[$n] . "'>\n");
|
||||||
|
|
Loading…
Reference in New Issue