From 1b262cbf7ce34c65d3f8f7a71b5fe66401545d4e Mon Sep 17 00:00:00 2001 From: Heuzef Date: Fri, 11 Oct 2019 14:40:47 +0200 Subject: [PATCH] Simplify lastAge --- Check.pm | 25 +++---------------------- 1 file changed, 3 insertions(+), 22 deletions(-) diff --git a/Check.pm b/Check.pm index 98e31d7..4a9a106 100644 --- a/Check.pm +++ b/Check.pm @@ -33,11 +33,10 @@ sub action # Start loop 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 $bpc = BackupPC::Lib->new(); my @Backups = $bpc->BackupInfoRead($host); - my $fullCnt = $incrCnt = 0; my $fullAge = $incrAge = $lastAge = -1; $bpc->ConfigRead($host); @@ -55,28 +54,10 @@ sub action # Age for ( my $i = 0 ; $i < @Backups ; $i++ ) { - if ( $Backups[$i]{type} eq "full" ) { - $fullCnt++; - 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 ( $Backups[$i]{type} eq "full" or eq "incr" ) { + $lastAge = $Backups[-1]{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 if ( $lastAge < $frequency ) {