diff --git a/lib/nvidia.pm b/lib/nvidia.pm
index deedf5b..c4f5dbb 100644
--- a/lib/nvidia.pm
+++ b/lib/nvidia.pm
@@ -232,6 +232,8 @@ sub nvidia_update {
}
sub nvidia_cgi {
+ no strict "refs";
+
my ($package, $config, $cgi) = @_;
my $nvidia = $config->{nvidia};
@@ -242,6 +244,15 @@ sub nvidia_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;
@@ -265,6 +276,7 @@ sub nvidia_cgi {
"#963C74",
);
+ $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};
@@ -417,7 +429,7 @@ sub nvidia_cgi {
@tmp = @tmpz;
push(@tmp, "COMMENT: \\n");
}
- RRDs::graph("$PNG_DIR" . "$PNG1",
+ $pic = $rrd{$version}->("$PNG_DIR" . "$PNG1",
"--title=$config->{graphs}->{_nvidia1} ($tf->{nwhen}$tf->{twhen})",
"--start=-$tf->{nwhen}$tf->{twhen}",
"--imgformat=PNG",
@@ -446,7 +458,7 @@ sub nvidia_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}->{_nvidia1} ($tf->{nwhen}$tf->{twhen})",
"--start=-$tf->{nwhen}$tf->{twhen}",
"--imgformat=PNG",
@@ -454,6 +466,7 @@ sub nvidia_cgi {
"--width=$width",
"--height=$height",
@riglim,
+ $zoom,
@{$cgi->{version12}},
@{$colors->{graph_colors}},
"DEF:temp0=$rrd:nvidia_temp0:AVERAGE",
@@ -477,7 +490,14 @@ sub nvidia_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");
@@ -531,7 +551,7 @@ sub nvidia_cgi {
@tmp = @tmpz;
push(@tmp, "COMMENT: \\n");
}
- RRDs::graph("$PNG_DIR" . "$PNG2",
+ $pic = $rrd{$version}->("$PNG_DIR" . "$PNG2",
"--title=$config->{graphs}->{_nvidia2} ($tf->{nwhen}$tf->{twhen})",
"--start=-$tf->{nwhen}$tf->{twhen}",
"--imgformat=PNG",
@@ -560,7 +580,7 @@ sub nvidia_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}->{_nvidia2} ($tf->{nwhen}$tf->{twhen})",
"--start=-$tf->{nwhen}$tf->{twhen}",
"--imgformat=PNG",
@@ -568,6 +588,7 @@ sub nvidia_cgi {
"--width=$width",
"--height=$height",
@riglim,
+ $zoom,
@{$cgi->{version12}},
@{$cgi->{version12_small}},
@{$colors->{graph_colors}},
@@ -592,7 +613,14 @@ sub nvidia_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");
@@ -642,7 +670,7 @@ sub nvidia_cgi {
@tmp = @tmpz;
push(@tmp, "COMMENT: \\n");
}
- RRDs::graph("$PNG_DIR" . "$PNG3",
+ $pic = $rrd{$version}->("$PNG_DIR" . "$PNG3",
"--title=$config->{graphs}->{_nvidia3} ($tf->{nwhen}$tf->{twhen})",
"--start=-$tf->{nwhen}$tf->{twhen}",
"--imgformat=PNG",
@@ -671,7 +699,7 @@ sub nvidia_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}->{_nvidia3} ($tf->{nwhen}$tf->{twhen})",
"--start=-$tf->{nwhen}$tf->{twhen}",
"--imgformat=PNG",
@@ -679,6 +707,7 @@ sub nvidia_cgi {
"--width=$width",
"--height=$height",
@riglim,
+ $zoom,
@{$cgi->{version12}},
@{$cgi->{version12_small}},
@{$colors->{graph_colors}},
@@ -703,7 +732,14 @@ sub nvidia_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");