mirror of https://github.com/mikaku/Monitorix.git
Zoomed graphs in 'raspberrypi.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
60551c334b
commit
5f57633987
|
@ -213,6 +213,15 @@ sub raspberrypi_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;
|
||||||
|
@ -236,6 +245,7 @@ sub raspberrypi_cgi {
|
||||||
"#444444",
|
"#444444",
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$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};
|
||||||
|
@ -391,7 +401,7 @@ sub raspberrypi_cgi {
|
||||||
push(@tmp, "COMMENT: \\n");
|
push(@tmp, "COMMENT: \\n");
|
||||||
push(@tmp, "COMMENT: \\n");
|
push(@tmp, "COMMENT: \\n");
|
||||||
}
|
}
|
||||||
RRDs::graph("$PNG_DIR" . "$PNG1",
|
$pic = $rrd{$version}->("$PNG_DIR" . "$PNG1",
|
||||||
"--title=$config->{graphs}->{_raspberrypi1} ($tf->{nwhen}$tf->{twhen})",
|
"--title=$config->{graphs}->{_raspberrypi1} ($tf->{nwhen}$tf->{twhen})",
|
||||||
"--start=-$tf->{nwhen}$tf->{twhen}",
|
"--start=-$tf->{nwhen}$tf->{twhen}",
|
||||||
"--imgformat=PNG",
|
"--imgformat=PNG",
|
||||||
|
@ -418,7 +428,7 @@ sub raspberrypi_cgi {
|
||||||
print("ERROR: while graphing $PNG_DIR" . "$PNG1: $err\n") if $err;
|
print("ERROR: while graphing $PNG_DIR" . "$PNG1: $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" . "$PNG1z",
|
$picz = $rrd{$version}->("$PNG_DIR" . "$PNG1z",
|
||||||
"--title=$config->{graphs}->{_raspberrypi1} ($tf->{nwhen}$tf->{twhen})",
|
"--title=$config->{graphs}->{_raspberrypi1} ($tf->{nwhen}$tf->{twhen})",
|
||||||
"--start=-$tf->{nwhen}$tf->{twhen}",
|
"--start=-$tf->{nwhen}$tf->{twhen}",
|
||||||
"--imgformat=PNG",
|
"--imgformat=PNG",
|
||||||
|
@ -426,6 +436,7 @@ sub raspberrypi_cgi {
|
||||||
"--width=$width",
|
"--width=$width",
|
||||||
"--height=$height",
|
"--height=$height",
|
||||||
@riglim,
|
@riglim,
|
||||||
|
$zoom,
|
||||||
@{$cgi->{version12}},
|
@{$cgi->{version12}},
|
||||||
@{$colors->{graph_colors}},
|
@{$colors->{graph_colors}},
|
||||||
"DEF:clock0=$rrd:rpi_clock0:AVERAGE",
|
"DEF:clock0=$rrd:rpi_clock0:AVERAGE",
|
||||||
|
@ -449,7 +460,14 @@ sub raspberrypi_cgi {
|
||||||
print(" <a href=\"" . $config->{url} . "/" . $config->{imgs_dir} . $PNG1z . "\"><img src='" . $config->{url} . "/" . $config->{imgs_dir} . $PNG1 . "' border='0'></a>\n");
|
print(" <a href=\"" . $config->{url} . "/" . $config->{imgs_dir} . $PNG1z . "\"><img src='" . $config->{url} . "/" . $config->{imgs_dir} . $PNG1 . "' border='0'></a>\n");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
print(" <a href=\"javascript:void(window.open('" . $config->{url} . "/" . $config->{imgs_dir} . $PNG1z . "','','width=" . ($width + 115) . ",height=" . ($height + 100) . ",scrollbars=0,resizable=0'))\"><img src='" . $config->{url} . "/" . $config->{imgs_dir} . $PNG1 . "' 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} . $PNG1z . "','','width=" . $picz_width . ",height=" . $picz_height . ",scrollbars=0,resizable=0'))\"><img src='" . $config->{url} . "/" . $config->{imgs_dir} . $PNG1 . "' border='0'></a>\n");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
print(" <img src='" . $config->{url} . "/" . $config->{imgs_dir} . $PNG1 . "'>\n");
|
print(" <img src='" . $config->{url} . "/" . $config->{imgs_dir} . $PNG1 . "'>\n");
|
||||||
|
@ -487,7 +505,7 @@ sub raspberrypi_cgi {
|
||||||
push(@tmp, "COMMENT: \\n");
|
push(@tmp, "COMMENT: \\n");
|
||||||
push(@tmp, "COMMENT: \\n");
|
push(@tmp, "COMMENT: \\n");
|
||||||
}
|
}
|
||||||
RRDs::graph("$PNG_DIR" . "$PNG2",
|
$pic = $rrd{$version}->("$PNG_DIR" . "$PNG2",
|
||||||
"--title=$config->{graphs}->{_raspberrypi2} ($tf->{nwhen}$tf->{twhen})",
|
"--title=$config->{graphs}->{_raspberrypi2} ($tf->{nwhen}$tf->{twhen})",
|
||||||
"--start=-$tf->{nwhen}$tf->{twhen}",
|
"--start=-$tf->{nwhen}$tf->{twhen}",
|
||||||
"--imgformat=PNG",
|
"--imgformat=PNG",
|
||||||
|
@ -507,7 +525,7 @@ sub raspberrypi_cgi {
|
||||||
print("ERROR: while graphing $PNG_DIR" . "$PNG2: $err\n") if $err;
|
print("ERROR: while graphing $PNG_DIR" . "$PNG2: $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" . "$PNG2z",
|
$picz = $rrd{$version}->("$PNG_DIR" . "$PNG2z",
|
||||||
"--title=$config->{graphs}->{_raspberrypi2} ($tf->{nwhen}$tf->{twhen})",
|
"--title=$config->{graphs}->{_raspberrypi2} ($tf->{nwhen}$tf->{twhen})",
|
||||||
"--start=-$tf->{nwhen}$tf->{twhen}",
|
"--start=-$tf->{nwhen}$tf->{twhen}",
|
||||||
"--imgformat=PNG",
|
"--imgformat=PNG",
|
||||||
|
@ -515,6 +533,7 @@ sub raspberrypi_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}},
|
||||||
|
@ -531,7 +550,14 @@ sub raspberrypi_cgi {
|
||||||
print(" <a href=\"" . $config->{url} . "/" . $config->{imgs_dir} . $PNG2z . "\"><img src='" . $config->{url} . "/" . $config->{imgs_dir} . $PNG2 . "' border='0'></a>\n");
|
print(" <a href=\"" . $config->{url} . "/" . $config->{imgs_dir} . $PNG2z . "\"><img src='" . $config->{url} . "/" . $config->{imgs_dir} . $PNG2 . "' border='0'></a>\n");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
print(" <a href=\"javascript:void(window.open('" . $config->{url} . "/" . $config->{imgs_dir} . $PNG2z . "','','width=" . ($width + 115) . ",height=" . ($height + 100) . ",scrollbars=0,resizable=0'))\"><img src='" . $config->{url} . "/" . $config->{imgs_dir} . $PNG2 . "' 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} . $PNG2z . "','','width=" . $picz_width . ",height=" . $picz_height . ",scrollbars=0,resizable=0'))\"><img src='" . $config->{url} . "/" . $config->{imgs_dir} . $PNG2 . "' border='0'></a>\n");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
print(" <img src='" . $config->{url} . "/" . $config->{imgs_dir} . $PNG2 . "'>\n");
|
print(" <img src='" . $config->{url} . "/" . $config->{imgs_dir} . $PNG2 . "'>\n");
|
||||||
|
@ -568,7 +594,7 @@ sub raspberrypi_cgi {
|
||||||
push(@tmp, "COMMENT: \\n");
|
push(@tmp, "COMMENT: \\n");
|
||||||
push(@tmp, "COMMENT: \\n");
|
push(@tmp, "COMMENT: \\n");
|
||||||
}
|
}
|
||||||
RRDs::graph("$PNG_DIR" . "$PNG3",
|
$pic = $rrd{$version}->("$PNG_DIR" . "$PNG3",
|
||||||
"--title=$config->{graphs}->{_raspberrypi3} ($tf->{nwhen}$tf->{twhen})",
|
"--title=$config->{graphs}->{_raspberrypi3} ($tf->{nwhen}$tf->{twhen})",
|
||||||
"--start=-$tf->{nwhen}$tf->{twhen}",
|
"--start=-$tf->{nwhen}$tf->{twhen}",
|
||||||
"--imgformat=PNG",
|
"--imgformat=PNG",
|
||||||
|
@ -591,7 +617,7 @@ sub raspberrypi_cgi {
|
||||||
print("ERROR: while graphing $PNG_DIR" . "$PNG3: $err\n") if $err;
|
print("ERROR: while graphing $PNG_DIR" . "$PNG3: $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" . "$PNG3z",
|
$picz = $rrd{$version}->("$PNG_DIR" . "$PNG3z",
|
||||||
"--title=$config->{graphs}->{_raspberrypi3} ($tf->{nwhen}$tf->{twhen})",
|
"--title=$config->{graphs}->{_raspberrypi3} ($tf->{nwhen}$tf->{twhen})",
|
||||||
"--start=-$tf->{nwhen}$tf->{twhen}",
|
"--start=-$tf->{nwhen}$tf->{twhen}",
|
||||||
"--imgformat=PNG",
|
"--imgformat=PNG",
|
||||||
|
@ -599,6 +625,7 @@ sub raspberrypi_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}},
|
||||||
|
@ -618,7 +645,14 @@ sub raspberrypi_cgi {
|
||||||
print(" <a href=\"" . $config->{url} . "/" . $config->{imgs_dir} . $PNG3z . "\"><img src='" . $config->{url} . "/" . $config->{imgs_dir} . $PNG3 . "' border='0'></a>\n");
|
print(" <a href=\"" . $config->{url} . "/" . $config->{imgs_dir} . $PNG3z . "\"><img src='" . $config->{url} . "/" . $config->{imgs_dir} . $PNG3 . "' border='0'></a>\n");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
print(" <a href=\"javascript:void(window.open('" . $config->{url} . "/" . $config->{imgs_dir} . $PNG3z . "','','width=" . ($width + 115) . ",height=" . ($height + 100) . ",scrollbars=0,resizable=0'))\"><img src='" . $config->{url} . "/" . $config->{imgs_dir} . $PNG3 . "' 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} . $PNG3z . "','','width=" . $picz_width . ",height=" . $picz_height . ",scrollbars=0,resizable=0'))\"><img src='" . $config->{url} . "/" . $config->{imgs_dir} . $PNG3 . "' border='0'></a>\n");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
print(" <img src='" . $config->{url} . "/" . $config->{imgs_dir} . $PNG3 . "'>\n");
|
print(" <img src='" . $config->{url} . "/" . $config->{imgs_dir} . $PNG3 . "'>\n");
|
||||||
|
|
Loading…
Reference in New Issue