Simplify lastAge

master
Heuzef 5 years ago
parent 9354f3c9ac
commit 1b262cbf7c
  1. 25
      Check.pm

@ -33,11 +33,10 @@ sub action
# Start loop # Start loop
foreach my $host ( GetUserHosts(1) ) { foreach my $host ( GetUserHosts(1) ) {
my($incrCnt, $incrAge, $reasonHilite, $frequency, $lastAge, $lastAgeColor, $tempState, $tempReason, $lastXferErrors, $lastXferErrorsColor); my($incrAge, $reasonHilite, $frequency, $lastAge, $lastAgeColor, $tempState, $tempReason, $lastXferErrors, $lastXferErrorsColor);
my($shortErr); my($shortErr);
my $bpc = BackupPC::Lib->new(); my $bpc = BackupPC::Lib->new();
my @Backups = $bpc->BackupInfoRead($host); my @Backups = $bpc->BackupInfoRead($host);
my $fullCnt = $incrCnt = 0;
my $fullAge = $incrAge = $lastAge = -1; my $fullAge = $incrAge = $lastAge = -1;
$bpc->ConfigRead($host); $bpc->ConfigRead($host);
@ -55,28 +54,10 @@ sub action
# Age # Age
for ( my $i = 0 ; $i < @Backups ; $i++ ) { for ( my $i = 0 ; $i < @Backups ; $i++ ) {
if ( $Backups[$i]{type} eq "full" ) { if ( $Backups[$i]{type} eq "full" or eq "incr" ) {
$fullCnt++; $lastAge = $Backups[-1]{startTime};
if ( $fullAge < 0 || $Backups[$i]{startTime} > $fullAge ) {
$fullAge = $Backups[$i]{startTime};
}
} elsif ( $Backups[$i]{type} eq "incr" ) {
$incrCnt++;
if ( $incrAge < 0 || $Backups[$i]{startTime} > $incrAge ) {
$incrAge = $Backups[$i]{startTime};
}
} }
} }
if ( $fullAge > $incrAge && $fullAge >= 0 ) {
$lastAge = $fullAge;
} else {
$lastAge = $incrAge;
}
if ( $lastAge < 0 ) {
$lastAge = 0;
} else {
$lastAge = sprintf("%.1f", (time - $lastAge) / (24 * 3600));
}
# Color for age # Color for age
if ( $lastAge < $frequency ) { if ( $lastAge < $frequency ) {

Loading…
Cancel
Save