diff --git a/lib/kern.pm b/lib/kern.pm index d698b15..f815a19 100644 --- a/lib/kern.pm +++ b/lib/kern.pm @@ -375,6 +375,8 @@ sub kern_update { } sub kern_cgi { + no strict "refs"; + my ($package, $config, $cgi) = @_; my $kern = $config->{kern}; @@ -385,6 +387,15 @@ sub kern_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; @@ -397,6 +408,7 @@ sub kern_cgi { my $n; 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}; @@ -685,7 +697,7 @@ sub kern_cgi { push(@tmp, "COMMENT: \\n"); push(@tmp, "COMMENT: \\n"); } - RRDs::graph("$PNG_DIR" . "$PNG1", + $pic = $rrd{$version}->("$PNG_DIR" . "$PNG1", "--title=$config->{graphs}->{_kern1} ($tf->{nwhen}$tf->{twhen})", "--start=-$tf->{nwhen}$tf->{twhen}", "--imgformat=PNG", @@ -711,7 +723,7 @@ sub kern_cgi { print("ERROR: while graphing $PNG_DIR" . "$PNG1: $err\n") if $err; if(lc($config->{enable_zoom}) eq "y") { ($width, $height) = split('x', $config->{graph_size}->{zoom}); - RRDs::graph("$PNG_DIR" . "$PNG1z", + $picz = $rrd{$version}->("$PNG_DIR" . "$PNG1z", "--title=$config->{graphs}->{_kern1} ($tf->{nwhen}$tf->{twhen})", "--start=-$tf->{nwhen}$tf->{twhen}", "--imgformat=PNG", @@ -719,6 +731,7 @@ sub kern_cgi { "--width=$width", "--height=$height", @riglim, + $zoom, @{$cgi->{version12}}, @{$colors->{graph_colors}}, "DEF:user=$rrd:kern_user:AVERAGE", @@ -741,7 +754,14 @@ sub kern_cgi { print(" {url} . "/" . $config->{imgs_dir} . $PNG1z . "\">\n"); } else { - print(" {url} . "/" . $config->{imgs_dir} . $PNG1z . "','','width=" . ($width + 115) . ",height=" . ($height + 100) . ",scrollbars=0,resizable=0'))\">\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(" {url} . "/" . $config->{imgs_dir} . $PNG1z . "','','width=" . $picz_width . ",height=" . $picz_height . ",scrollbars=0,resizable=0'))\">\n"); } } else { print(" \n"); @@ -788,7 +808,7 @@ sub kern_cgi { push(@tmp, "COMMENT: \\n"); push(@tmp, "COMMENT: \\n"); } - RRDs::graph("$PNG_DIR" . "$PNG2", + $pic = $rrd{$version}->("$PNG_DIR" . "$PNG2", "--title=$config->{graphs}->{_kern2} ($tf->{nwhen}$tf->{twhen})", "--start=-$tf->{nwhen}$tf->{twhen}", "--imgformat=PNG", @@ -810,7 +830,7 @@ sub kern_cgi { print("ERROR: while graphing $PNG_DIR" . "$PNG2: $err\n") if $err; if(lc($config->{enable_zoom}) eq "y") { ($width, $height) = split('x', $config->{graph_size}->{zoom}); - RRDs::graph("$PNG_DIR" . "$PNG2z", + $picz = $rrd{$version}->("$PNG_DIR" . "$PNG2z", "--title=$config->{graphs}->{_kern2} ($tf->{nwhen}$tf->{twhen})", "--start=-$tf->{nwhen}$tf->{twhen}", "--imgformat=PNG", @@ -818,6 +838,7 @@ sub kern_cgi { "--width=$width", "--height=$height", @riglim, + $zoom, @{$cgi->{version12}}, @{$cgi->{version12_small}}, @{$colors->{graph_colors}}, @@ -836,7 +857,14 @@ sub kern_cgi { print(" {url} . "/" . $config->{imgs_dir} . $PNG2z . "\">\n"); } else { - print(" {url} . "/" . $config->{imgs_dir} . $PNG2z . "','','width=" . ($width + 115) . ",height=" . ($height + 100) . ",scrollbars=0,resizable=0'))\">\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(" {url} . "/" . $config->{imgs_dir} . $PNG2z . "','','width=" . $picz_width . ",height=" . $picz_height . ",scrollbars=0,resizable=0'))\">\n"); } } else { print(" \n"); @@ -880,7 +908,7 @@ sub kern_cgi { push(@tmp, "COMMENT: \\n"); push(@tmp, "COMMENT: \\n"); } - RRDs::graph("$PNG_DIR" . "$PNG3", + $pic = $rrd{$version}->("$PNG_DIR" . "$PNG3", "--title=$config->{graphs}->{_kern3} ($tf->{nwhen}$tf->{twhen})", "--start=-$tf->{nwhen}$tf->{twhen}", "--imgformat=PNG", @@ -902,7 +930,7 @@ sub kern_cgi { print("ERROR: while graphing $PNG_DIR" . "$PNG3: $err\n") if $err; if(lc($config->{enable_zoom}) eq "y") { ($width, $height) = split('x', $config->{graph_size}->{zoom}); - RRDs::graph("$PNG_DIR" . "$PNG3z", + $picz = $rrd{$version}->("$PNG_DIR" . "$PNG3z", "--title=$config->{graphs}->{_kern3} ($tf->{nwhen}$tf->{twhen})", "--start=-$tf->{nwhen}$tf->{twhen}", "--imgformat=PNG", @@ -910,6 +938,7 @@ sub kern_cgi { "--width=$width", "--height=$height", @riglim, + $zoom, @{$cgi->{version12}}, @{$cgi->{version12_small}}, @{$colors->{graph_colors}}, @@ -928,7 +957,14 @@ sub kern_cgi { print(" {url} . "/" . $config->{imgs_dir} . $PNG3z . "\">\n"); } else { - print(" {url} . "/" . $config->{imgs_dir} . $PNG3z . "','','width=" . ($width + 115) . ",height=" . ($height + 100) . ",scrollbars=0,resizable=0'))\">\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(" {url} . "/" . $config->{imgs_dir} . $PNG3z . "','','width=" . $picz_width . ",height=" . $picz_height . ",scrollbars=0,resizable=0'))\">\n"); } } else { print(" \n");