master
Heuzef 5 years ago
parent d45e06fa7c
commit 572928e85e
  1. 68
      Check.pm

@ -134,15 +134,15 @@ sub action
$shortErr = " ($shortErr)"; $shortErr = " ($shortErr)";
} }
# Check Size Consistency # Check Size Consistency
my $bpc = BackupPC::Lib->new(); my $bpc = BackupPC::Lib->new();
my $mainConf = $bpc->ConfigDataRead(); my $mainConf = $bpc->ConfigDataRead();
my $check = {}; my $check = {};
my $hostConf = $bpc->ConfigDataRead($host); my $hostConf = $bpc->ConfigDataRead($host);
my $conf = { %$mainConf, %$hostConf }; my $conf = { %$mainConf, %$hostConf };
my $age = -1; my $age = -1;
$check = { $check = {
bkp => 0, bkp => 0,
last_age => 0, last_age => 0,
errors => 0, errors => 0,
@ -151,12 +151,12 @@ $check = {
new_size_median => 0, new_size_median => 0,
new_size_q1 => 0, new_size_q1 => 0,
new_size_q3 => 0 new_size_q3 => 0
}; };
my @bpc_info = $bpc->BackupInfoRead($host); my @bpc_info = $bpc->BackupInfoRead($host);
my $sizes = new Statistics::Descriptive::Full; my $sizes = new Statistics::Descriptive::Full;
if ( scalar( @bpc_info ) ){ if ( scalar( @bpc_info ) ){
foreach my $backup ( @bpc_info ) { foreach my $backup ( @bpc_info ) {
# Skip partial or active backups # Skip partial or active backups
next if ( $backup->{type} !~ m/^full|incr$/ ); next if ( $backup->{type} !~ m/^full|incr$/ );
@ -177,45 +177,45 @@ if ( scalar( @bpc_info ) ){
$check->{new_size_q3} = eval { int $sizes->quantile(3) } || 0; $check->{new_size_q3} = eval { int $sizes->quantile(3) } || 0;
$check->{age} = time - $bpc_info[$i]->{startTime}; $check->{age} = time - $bpc_info[$i]->{startTime};
$check->{last_age} = sprintf("%.1f", ($check->{age}) / 84600); $check->{last_age} = sprintf("%.1f", ($check->{age}) / 84600);
} }
# TOO BIG ? # TOO BIG ?
my $toobig = "1"; my $toobig = "1";
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 ( $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 ) {
$toobig = "1"; $toobig = "1";
} }
else { else {
$toobig = "0"; $toobig = "0";
} }
# TOO SMALL ? # TOO SMALL ?
my $toosmall = "1"; my $toosmall = "1";
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 ( $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 ) {
$toosmall = "1"; $toosmall = "1";
} }
else { else {
$toosmall = "0"; $toosmall = "0";
} }
my $sizeConsistency = "<strong>ANOMALOUS</strong>"; my $sizeConsistency = "<strong>ANOMALOUS</strong>";
my $sizeConsistencyColor = "Tomato"; my $sizeConsistencyColor = "Tomato";
# Get result # Get result
if ( $toobig or $toosmall ) { if ( $toobig or $toosmall ) {
$sizeConsistency = "<strong>ANOMALOUS</strong>"; $sizeConsistency = "<strong>ANOMALOUS</strong>";
$sizeConsistencyColor = "Tomato"; $sizeConsistencyColor = "Tomato";
} }
else { else {
$sizeConsistency = "Normal"; $sizeConsistency = "Normal";
$sizeConsistencyColor = "MediumSeaGreen"; $sizeConsistencyColor = "MediumSeaGreen";
} }
# Get URL for explore file # Get URL for explore file
my $browseFile = "?action=browse&host=$host"; my $browseFile = "?action=browse&host=$host";
# Show summary # Show summary
$str = <<EOF; $str = <<EOF;
<tr$reasonHilite><td class="border">${HostLink($host)}</td> <tr$reasonHilite><td class="border">${HostLink($host)}</td>
<td align="center" class="border" style="color:$lastAgeColor;">$lastAge <em>(Freq: $frequency)</em></td> <td align="center" class="border" style="color:$lastAgeColor;">$lastAge <em>(Freq: $frequency)</em></td>
<td align="center" class="border" style="color:$lastXferErrorsColor;">$lastXferErrors</td> <td align="center" class="border" style="color:$lastXferErrorsColor;">$lastXferErrors</td>
<td align="center" class="border" style="color:$sizeConsistencyColor;">$sizeConsistency</td> <td align="center" class="border" style="color:$sizeConsistencyColor;">$sizeConsistency</td>

Loading…
Cancel
Save