diff --git a/lib/netstat.pm b/lib/netstat.pm
index f41f813..950083a 100644
--- a/lib/netstat.pm
+++ b/lib/netstat.pm
@@ -298,6 +298,8 @@ sub netstat_update {
}
sub netstat_cgi {
+ no strict "refs";
+
my ($package, $config, $cgi) = @_;
my $netstat = $config->{netstat};
@@ -308,6 +310,15 @@ sub netstat_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;
@@ -319,6 +330,7 @@ sub netstat_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};
@@ -459,7 +471,7 @@ sub netstat_cgi {
($width, $height) = split('x', $config->{graph_size}->{main}) if $silent eq "imagetagbig";
@tmp = @tmpz;
}
- RRDs::graph("$PNG_DIR" . "$PNG1",
+ $pic = $rrd{$version}->("$PNG_DIR" . "$PNG1",
"--title=$config->{graphs}->{_netstat1} ($tf->{nwhen}$tf->{twhen})",
"--start=-$tf->{nwhen}$tf->{twhen}",
"--imgformat=PNG",
@@ -484,7 +496,7 @@ sub netstat_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}->{_netstat1} ($tf->{nwhen}$tf->{twhen})",
"--start=-$tf->{nwhen}$tf->{twhen}",
"--imgformat=PNG",
@@ -492,6 +504,7 @@ sub netstat_cgi {
"--width=$width",
"--height=$height",
@riglim,
+ $zoom,
@{$cgi->{version12}},
@{$colors->{graph_colors}},
"DEF:i4_closed=$rrd:nstat4_closed:AVERAGE",
@@ -513,7 +526,14 @@ sub netstat_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");
@@ -577,7 +597,7 @@ sub netstat_cgi {
($width, $height) = split('x', $config->{graph_size}->{main}) if $silent eq "imagetagbig";
@tmp = @tmpz;
}
- RRDs::graph("$PNG_DIR" . "$PNG2",
+ $pic = $rrd{$version}->("$PNG_DIR" . "$PNG2",
"--title=$config->{graphs}->{_netstat2} ($tf->{nwhen}$tf->{twhen})",
"--start=-$tf->{nwhen}$tf->{twhen}",
"--imgformat=PNG",
@@ -602,7 +622,7 @@ sub netstat_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}->{_netstat2} ($tf->{nwhen}$tf->{twhen})",
"--start=-$tf->{nwhen}$tf->{twhen}",
"--imgformat=PNG",
@@ -610,6 +630,7 @@ sub netstat_cgi {
"--width=$width",
"--height=$height",
@riglim,
+ $zoom,
@{$cgi->{version12}},
@{$colors->{graph_colors}},
"DEF:i6_closed=$rrd:nstat6_closed:AVERAGE",
@@ -631,7 +652,14 @@ sub netstat_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");
@@ -674,7 +702,7 @@ sub netstat_cgi {
push(@tmp, "COMMENT: \\n");
push(@tmp, "COMMENT: \\n");
}
- RRDs::graph("$PNG_DIR" . "$PNG3",
+ $pic = $rrd{$version}->("$PNG_DIR" . "$PNG3",
"--title=$config->{graphs}->{_netstat3} ($tf->{nwhen}$tf->{twhen})",
"--start=-$tf->{nwhen}$tf->{twhen}",
"--imgformat=PNG",
@@ -698,7 +726,7 @@ sub netstat_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}->{_netstat3} ($tf->{nwhen}$tf->{twhen})",
"--start=-$tf->{nwhen}$tf->{twhen}",
"--imgformat=PNG",
@@ -706,6 +734,7 @@ sub netstat_cgi {
"--width=$width",
"--height=$height",
@riglim,
+ $zoom,
@{$cgi->{version12}},
@{$cgi->{version12_small}},
@{$colors->{graph_colors}},
@@ -725,7 +754,14 @@ sub netstat_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");
@@ -770,7 +806,7 @@ sub netstat_cgi {
push(@tmp, "COMMENT: \\n");
push(@tmp, "COMMENT: \\n");
}
- RRDs::graph("$PNG_DIR" . "$PNG4",
+ $pic = $rrd{$version}->("$PNG_DIR" . "$PNG4",
"--title=$config->{graphs}->{_netstat4} ($tf->{nwhen}$tf->{twhen})",
"--start=-$tf->{nwhen}$tf->{twhen}",
"--imgformat=PNG",
@@ -796,7 +832,7 @@ sub netstat_cgi {
print("ERROR: while graphing $PNG_DIR" . "$PNG4: $err\n") if $err;
if(lc($config->{enable_zoom}) eq "y") {
($width, $height) = split('x', $config->{graph_size}->{zoom});
- RRDs::graph("$PNG_DIR" . "$PNG4z",
+ $picz = $rrd{$version}->("$PNG_DIR" . "$PNG4z",
"--title=$config->{graphs}->{_netstat4} ($tf->{nwhen}$tf->{twhen})",
"--start=-$tf->{nwhen}$tf->{twhen}",
"--imgformat=PNG",
@@ -804,6 +840,7 @@ sub netstat_cgi {
"--width=$width",
"--height=$height",
@riglim,
+ $zoom,
@{$cgi->{version12}},
@{$cgi->{version12_small}},
@{$colors->{graph_colors}},
@@ -825,7 +862,14 @@ sub netstat_cgi {
print(" {url} . "/" . $config->{imgs_dir} . $PNG4z . "\">\n");
}
else {
- print(" {url} . "/" . $config->{imgs_dir} . $PNG4z . "','','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} . $PNG4z . "','','width=" . $picz_width . ",height=" . $picz_height . ",scrollbars=0,resizable=0'))\">\n");
}
} else {
print(" \n");
@@ -856,7 +900,7 @@ sub netstat_cgi {
push(@tmp, "COMMENT: \\n");
push(@tmp, "COMMENT: \\n");
}
- RRDs::graph("$PNG_DIR" . "$PNG5",
+ $pic = $rrd{$version}->("$PNG_DIR" . "$PNG5",
"--title=$config->{graphs}->{_netstat5} ($tf->{nwhen}$tf->{twhen})",
"--start=-$tf->{nwhen}$tf->{twhen}",
"--imgformat=PNG",
@@ -878,7 +922,7 @@ sub netstat_cgi {
print("ERROR: while graphing $PNG_DIR" . "$PNG5: $err\n") if $err;
if(lc($config->{enable_zoom}) eq "y") {
($width, $height) = split('x', $config->{graph_size}->{zoom});
- RRDs::graph("$PNG_DIR" . "$PNG5z",
+ $picz = $rrd{$version}->("$PNG_DIR" . "$PNG5z",
"--title=$config->{graphs}->{_netstat5} ($tf->{nwhen}$tf->{twhen})",
"--start=-$tf->{nwhen}$tf->{twhen}",
"--imgformat=PNG",
@@ -886,6 +930,7 @@ sub netstat_cgi {
"--width=$width",
"--height=$height",
@riglim,
+ $zoom,
@{$cgi->{version12}},
@{$cgi->{version12_small}},
@{$colors->{graph_colors}},
@@ -903,7 +948,14 @@ sub netstat_cgi {
print(" {url} . "/" . $config->{imgs_dir} . $PNG5z . "\">\n");
}
else {
- print(" {url} . "/" . $config->{imgs_dir} . $PNG5z . "','','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} . $PNG5z . "','','width=" . $picz_width . ",height=" . $picz_height . ",scrollbars=0,resizable=0'))\">\n");
}
} else {
print(" \n");