From cd8d15446e258e68f143795d318b79c562e7de37 Mon Sep 17 00:00:00 2001 From: Niko Tyni Date: Fri, 7 Oct 2005 10:57:27 +0000 Subject: * (trunk,2.0)/ lib/Smokeping.pm, lib/Smokeping/RRDtools.pm, CHANGES + only warn if RRA parameters other than CF are different config file and an RRD --- lib/Smokeping/RRDtools.pm | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) (limited to 'lib/Smokeping') diff --git a/lib/Smokeping/RRDtools.pm b/lib/Smokeping/RRDtools.pm index 2b7ad2b..6127d49 100644 --- a/lib/Smokeping/RRDtools.pm +++ b/lib/Smokeping/RRDtools.pm @@ -19,7 +19,8 @@ Smokeping::RRDtools - Tools for RRD file handling # or compare them against another create list my @create = ('--step', 60, 'DS:ds0:GAUGE:120:0:U', 'RRA:AVERAGE:0.5:1:1008'); - my $comparison = Smokeping::RRDtools::compare($file, \@create); + my ($fatal, $comparison) = Smokeping::RRDtools::compare($file, \@create); + print "Fatal: " if $fatal; print "Create arguments didn't match: $comparison\n" if $comparison; Smokeping::RRDtools::tuneds($file, \@create); @@ -41,9 +42,13 @@ but it B contain the C parameter. The function C must be called with two arguments: the path to the interesting RRD file, and a reference to an argument list that could be fed to C. The function will then simply compare the result of -C with this argument list. It will return C if the -arguments matched, and a string indicating the difference if a discrepancy -was found. Note that if there is a C parameter in the argument list, +C with this argument list. It will return an array of two values: +C<(fatal, text)> where C is 1 if it found a fatal difference, and 0 if not. +The C will contain an error message if C and a possible warning +message if C. If C and C is C, all the +arguments matched. + +Note that if there is a C parameter in the argument list, C disregards it. If C isn't specified, C will use the C default of 300 seconds. C ignores non-matching DS parameters since C will fix them. @@ -160,27 +165,34 @@ sub compare { } else { $step2 = 300; # default value } - return "Wrong value of step: $file has $step, create string has $step2" + return (1, "Wrong value of step: $file has $step, create string has $step2") unless $step == $step2; my $dscount = grep /^DS/, @create; my $dscount2 = grep /^DS/, @create2; - return "Different number of data sources: $file has $dscount2, create string has $dscount" + return (1, "Different number of data sources: $file has $dscount2, create string has $dscount") unless $dscount == $dscount2; my $rracount = grep /^RRA/, @create; my $rracount2 = grep /^RRA/, @create2; - return "Different number of RRAs: $file has $rracount2, create string has $rracount" + return (1, "Different number of RRAs: $file has $rracount2, create string has $rracount") unless $rracount == $rracount2; + my $warning; while (my $arg = shift @create) { my $arg2 = shift @create2; my @ds = split /:/, $arg; my @ds2 = split /:/, $arg2; next if $ds[0] eq 'DS' and $ds[0] eq $ds2[0] and $ds[1] eq $ds2[1] and $ds[2] eq $ds2[2]; - return "Different arguments: $file has $arg2, create string has $arg" - unless $arg eq $arg2; + if ($arg ne $arg2) { + if ($ds[0] eq 'RRA' and $ds[0] eq $ds2[0] and $ds[1] eq $ds2[1]) { + # non-fatal: CF is the same, but xff/steps/rows differ + $warning .= "Different RRA parameters: $file has $arg2, create string has $arg"; + } else { + return (1, "Different arguments: $file has $arg2, create string has $arg"); + } + } } - return undef; + return (0, $warning); } sub tuneds { -- cgit v1.2.3-24-g4f1b