diff --git a/Check.pm b/Check.pm index d43103a..3976c0f 100644 --- a/Check.pm +++ b/Check.pm @@ -112,21 +112,16 @@ sub action } # Check Size Consistency - my $mainConf = $bpc->ConfigDataRead(); - my $check = {}; - - my $hostConf = $bpc->ConfigDataRead($host); - my $conf = { %$mainConf, %$hostConf }; - my $age = -1; - $check = { - new_size => 0, - new_size_avg => 0, - new_size_median => 0, - new_size_q1 => 0, - new_size_q3 => 0 - }; - - my $sizes = new Statistics::Descriptive::Full; + my $mainConf = $bpc->ConfigDataRead(); + my $hostConf = $bpc->ConfigDataRead($host); + my $conf = { %$mainConf, %$hostConf }; + my $age = -1; + my $new_size = 0; + my $new_size_avg = 0; + my $new_size_median = 0; + my $new_size_q1 = 0; + my $new_size_q3 = 0; + my $sizes = new Statistics::Descriptive::Full; if ( scalar( @Backups ) ){ foreach my $backup ( @Backups ) { @@ -140,22 +135,22 @@ sub action # Ignore the last backup if it's not full or incr (which means it's either partial or active) my $i = ( $Backups[-1]->{type} =~ m/^full|incr$/ ) ? -1 : -2; - $check->{new_size} = $Backups[$i]->{sizeNew}; - $check->{new_size_avg} = int $sizes->mean; - $check->{new_size_median} = int $sizes->median; - $check->{new_size_q1} = eval { int $sizes->quantile(1) } || 0; - $check->{new_size_q3} = eval { int $sizes->quantile(3) } || 0; + $new_size = $Backups[$i]->{sizeNew}; + $new_size_avg = int $sizes->mean; + $new_size_median = int $sizes->median; + $new_size_q1 = eval { int $sizes->quantile(1) } || 0; + $new_size_q3 = eval { int $sizes->quantile(3) } || 0; } # TOO BIG ? my $toobig = 0; - if ( $check->{new_size} > ($check->{new_size_q3} + $check->{new_size_q3} - $check->{new_size_q1}) * 1.5 or $check->{new_size} > $check->{new_size_avg} * 6 ) { + if ( $new_size > ($new_size_q3 + $new_size_q3 - $new_size_q1) * 1.5 or $new_size > $new_size_avg * 6 ) { $toobig = 1; } # TOO SMALL ? my $toosmall = 0; - if ( $check->{new_size} < ($check->{new_size_q1} - $check->{new_size_q3} - $check->{new_size_q1}) * 1.5 or $check->{new_size} < $check->{new_size_avg} / 3 ) { + if ( $new_size < ($new_size_q1 - $new_size_q3 - $new_size_q1) * 1.5 or $new_size < $new_size_avg / 3 ) { $toosmall = 1; }