allow adjusting graph limits
[upsgraph] / upsgraph.pl
index 24d196afde99a9886e4b7434c86840a0e2015642..91ae5adb99c055bf04f5e0b8e0ca4a876240e8a4 100755 (executable)
@@ -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";
Impressum, Datenschutz