From 2bd44519a44b9d8205dce444238cd9d5e17d965b Mon Sep 17 00:00:00 2001 From: Heuzef Date: Fri, 27 Sep 2019 13:13:58 +0200 Subject: [PATCH] Indent and comment code --- Check.pm | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/Check.pm b/Check.pm index a57b7b6..6271171 100644 --- a/Check.pm +++ b/Check.pm @@ -29,6 +29,7 @@ use Data::Dumper; sub action { + # Init my($fullTot, $fullSizeTot, $incrTot, $incrSizeTot, $str, $strNone, $strGood, $hostCntGood, $hostCntNone); @@ -36,6 +37,7 @@ sub action GetStatusInfo("hosts info"); my $Privileged = CheckPermission(); + # Start loop foreach my $host ( GetUserHosts(1) ) { my($fullDur, $incrCnt, $incrAge, $fullSize, $fullRate, $reasonHilite, $lastAge, $lastAgeColor, $tempState, $tempReason, $lastXferErrors, $lastXferErrorsColor); @@ -50,6 +52,7 @@ sub action next if ( $Conf{XferMethod} eq "archive" ); next if ( !$Privileged && !CheckPermission($host) ); + # Age for ( my $i = 0 ; $i < @Backups ; $i++ ) { if ( $Backups[$i]{type} eq "full" ) { $fullCnt++; @@ -77,6 +80,7 @@ sub action } else { $lastAge = sprintf("%.1f", (time - $lastAge) / (24 * 3600)); } + # Color for age if ( $lastAge < 1.1 ) { $lastAgeColor = "MediumSeaGreen"; } else { @@ -99,15 +103,18 @@ sub action $incrTot += $incrCnt; $fullSize = sprintf("%.2f", $fullSize / 1024); $incrAge = " " if ( $incrAge eq "" ); + # Color for errors $lastXferErrors = $Backups[@Backups-1]{xferErrs} if ( @Backups ); if ( $lastXferErrors == 0 ) { $lastXferErrorsColor = "MediumSeaGreen"; } else { $lastAgeColor = "Tomato"; } -$reasonHilite = $Conf{CgiStatusHilightColor}{$Status{$host}{reason}} - || $Conf{CgiStatusHilightColor}{$Status{$host}{state}}; - if ( $Conf{BackupsDisable} == 1 ) { + + $reasonHilite = $Conf{CgiStatusHilightColor}{$Status{$host}{reason}} || $Conf{CgiStatusHilightColor}{$Status{$host}{state}}; + +# If Backup is disable +if ( $Conf{BackupsDisable} == 1 ) { if ( $Status{$host}{state} ne "Status_backup_in_progress" && $Status{$host}{state} ne "Status_restore_in_progress" ) { $reasonHilite = $Conf{CgiStatusHilightColor}{Disabled_OnlyManualBackups}; @@ -134,6 +141,7 @@ $reasonHilite = $Conf{CgiStatusHilightColor}{$Status{$host}{reason}} $shortErr = " ($shortErr)"; } +# Show summary $str = <${HostLink($host)} $lastAge @@ -141,6 +149,8 @@ $reasonHilite = $Conf{CgiStatusHilightColor}{$Status{$host}{reason}} sizeConsistency random-file.txt EOF + +# Increment counter if ( @Backups == 0 ) { $hostCntNone++; $strNone .= $str; @@ -150,9 +160,10 @@ EOF } } - $fullSizeTot = sprintf("%.2f", $fullSizeTot / 1024); - $incrSizeTot = sprintf("%.2f", $incrSizeTot / 1024); - my $now = timeStamp2(time); +# Time set + $fullSizeTot = sprintf("%.2f", $fullSizeTot / 1024); + $incrSizeTot = sprintf("%.2f", $incrSizeTot / 1024); + my $now = timeStamp2(time); my $DUlastTime = timeStamp2($Info{DUlastValueTime}); my $DUmaxTime = timeStamp2($Info{DUDailyMaxTime}); my $DUInodemaxTime = timeStamp2($Info{DUInodeDailyMaxTime});