From 178e4778b096a75cb2c9b00f7908959c3d633d1c Mon Sep 17 00:00:00 2001 From: Michael Gernoth Date: Tue, 9 Feb 2010 23:13:35 +0100 Subject: [PATCH] allow adjusting graph limits --- upsgraph.pl | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/upsgraph.pl b/upsgraph.pl index 24d196a..91ae5ad 100755 --- a/upsgraph.pl +++ b/upsgraph.pl @@ -173,6 +173,37 @@ foreach my $host (@$hosts) { exit 1; } + if (defined($rrdinfo->{"ds[${field}].min"})) { + if ($rrdinfo->{"ds[${field}].min"} ne $host->{'vars'}->{$field}->{'min'}) { + RRDs::tune("${rrdfile}.${field}","-i",$field.":".$host->{'vars'}->{$field}->{'min'}); + } + } else { + if ($host->{'vars'}->{$field}->{'min'} ne 'U') { + RRDs::tune("${rrdfile}.${field}","-i",$field.":".$host->{'vars'}->{$field}->{'min'}); + } + } + + if (RRDs::error) { + print "Error while setting min: " . RRDs::error . "\n"; + exit 1; + } + + if (defined($rrdinfo->{"ds[${field}].max"})) { + if ($rrdinfo->{"ds[${field}].max"} ne $host->{'vars'}->{$field}->{'max'}) { + print "Max differs\n"; + RRDs::tune("${rrdfile}.${field}","-a",$field.":".$host->{'vars'}->{$field}->{'max'}); + } + } else { + if ($host->{'vars'}->{$field}->{'max'} ne 'U') { + RRDs::tune("${rrdfile}.${field}","-a",$field.":".$host->{'vars'}->{$field}->{'max'}); + } + } + + if (RRDs::error) { + print "Error while setting max: " . RRDs::error . "\n"; + exit 1; + } + if ($rrdinfo->{'rra[0].rows'} != $keep) { print "Resizing ${rrdfile}.${field} from " . $rrdinfo->{'rra[0].rows'} . " to ${keep} samples.\n"; -- 2.39.5