From 99c552bff6f4dddd9bbbb3806dcca44ea845f5cc Mon Sep 17 00:00:00 2001 From: Benjamin Oechslein Date: Mon, 12 Jan 2015 21:10:04 +0100 Subject: [PATCH 1/1] Trigger data migration if limits of a data source are changed in config file --- upsgraph.pl | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/upsgraph.pl b/upsgraph.pl index 4f66090..ce19500 100755 --- a/upsgraph.pl +++ b/upsgraph.pl @@ -324,12 +324,15 @@ foreach my $host (@$hosts) { exit 1; } + my $limitsChanged = 0; if (defined($rrdinfo->{"ds[${field}].min"})) { if ($rrdinfo->{"ds[${field}].min"} ne $host->{'vars'}->{$field}->{'min'}) { + $limitsChanged = 1; RRDs::tune("${rrdfile}.${field}","-i",$field.":".$host->{'vars'}->{$field}->{'min'}); } } else { if ($host->{'vars'}->{$field}->{'min'} ne 'U') { + $limitsChanged = 1; RRDs::tune("${rrdfile}.${field}","-i",$field.":".$host->{'vars'}->{$field}->{'min'}); } } @@ -341,10 +344,12 @@ foreach my $host (@$hosts) { if (defined($rrdinfo->{"ds[${field}].max"})) { if ($rrdinfo->{"ds[${field}].max"} ne $host->{'vars'}->{$field}->{'max'}) { + $limitsChanged = 1; RRDs::tune("${rrdfile}.${field}","-a",$field.":".$host->{'vars'}->{$field}->{'max'}); } } else { if ($host->{'vars'}->{$field}->{'max'} ne 'U') { + $limitsChanged = 1; RRDs::tune("${rrdfile}.${field}","-a",$field.":".$host->{'vars'}->{$field}->{'max'}); } } @@ -355,7 +360,8 @@ foreach my $host (@$hosts) { } if ($rrdinfo->{'rra[0].rows'} != $keep || - !defined($rrdinfo->{'rra[1].rows'}) || $rrdinfo->{'rra[1].rows'} != $keepHours) { + !defined($rrdinfo->{'rra[1].rows'}) || $rrdinfo->{'rra[1].rows'} != $keepHours || + $limitsChanged == 1) { print "Resizing ${rrdfile}.${field} from " . $rrdinfo->{'rra[0].rows'} . " to ${keep} samples.\n"; -- 2.39.5