Indent and comment code

master
Heuzef 5 years ago
parent 7e8c097297
commit 2bd44519a4
  1. 17
      Check.pm

@ -29,6 +29,7 @@ use Data::Dumper;
sub action sub action
{ {
# Init
my($fullTot, $fullSizeTot, $incrTot, $incrSizeTot, $str, my($fullTot, $fullSizeTot, $incrTot, $incrSizeTot, $str,
$strNone, $strGood, $hostCntGood, $hostCntNone); $strNone, $strGood, $hostCntGood, $hostCntNone);
@ -36,6 +37,7 @@ sub action
GetStatusInfo("hosts info"); GetStatusInfo("hosts info");
my $Privileged = CheckPermission(); my $Privileged = CheckPermission();
# Start loop
foreach my $host ( GetUserHosts(1) ) { foreach my $host ( GetUserHosts(1) ) {
my($fullDur, $incrCnt, $incrAge, $fullSize, $fullRate, $reasonHilite, my($fullDur, $incrCnt, $incrAge, $fullSize, $fullRate, $reasonHilite,
$lastAge, $lastAgeColor, $tempState, $tempReason, $lastXferErrors, $lastXferErrorsColor); $lastAge, $lastAgeColor, $tempState, $tempReason, $lastXferErrors, $lastXferErrorsColor);
@ -50,6 +52,7 @@ sub action
next if ( $Conf{XferMethod} eq "archive" ); next if ( $Conf{XferMethod} eq "archive" );
next if ( !$Privileged && !CheckPermission($host) ); next if ( !$Privileged && !CheckPermission($host) );
# 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" ) {
$fullCnt++; $fullCnt++;
@ -77,6 +80,7 @@ sub action
} else { } else {
$lastAge = sprintf("%.1f", (time - $lastAge) / (24 * 3600)); $lastAge = sprintf("%.1f", (time - $lastAge) / (24 * 3600));
} }
# Color for age
if ( $lastAge < 1.1 ) { if ( $lastAge < 1.1 ) {
$lastAgeColor = "MediumSeaGreen"; $lastAgeColor = "MediumSeaGreen";
} else { } else {
@ -99,15 +103,18 @@ sub action
$incrTot += $incrCnt; $incrTot += $incrCnt;
$fullSize = sprintf("%.2f", $fullSize / 1024); $fullSize = sprintf("%.2f", $fullSize / 1024);
$incrAge = "&nbsp;" if ( $incrAge eq "" ); $incrAge = "&nbsp;" if ( $incrAge eq "" );
# Color for errors
$lastXferErrors = $Backups[@Backups-1]{xferErrs} if ( @Backups ); $lastXferErrors = $Backups[@Backups-1]{xferErrs} if ( @Backups );
if ( $lastXferErrors == 0 ) { if ( $lastXferErrors == 0 ) {
$lastXferErrorsColor = "MediumSeaGreen"; $lastXferErrorsColor = "MediumSeaGreen";
} else { } else {
$lastAgeColor = "Tomato"; $lastAgeColor = "Tomato";
} }
$reasonHilite = $Conf{CgiStatusHilightColor}{$Status{$host}{reason}}
|| $Conf{CgiStatusHilightColor}{$Status{$host}{state}}; $reasonHilite = $Conf{CgiStatusHilightColor}{$Status{$host}{reason}} || $Conf{CgiStatusHilightColor}{$Status{$host}{state}};
if ( $Conf{BackupsDisable} == 1 ) {
# If Backup is disable
if ( $Conf{BackupsDisable} == 1 ) {
if ( $Status{$host}{state} ne "Status_backup_in_progress" if ( $Status{$host}{state} ne "Status_backup_in_progress"
&& $Status{$host}{state} ne "Status_restore_in_progress" ) { && $Status{$host}{state} ne "Status_restore_in_progress" ) {
$reasonHilite = $Conf{CgiStatusHilightColor}{Disabled_OnlyManualBackups}; $reasonHilite = $Conf{CgiStatusHilightColor}{Disabled_OnlyManualBackups};
@ -134,6 +141,7 @@ $reasonHilite = $Conf{CgiStatusHilightColor}{$Status{$host}{reason}}
$shortErr = " ($shortErr)"; $shortErr = " ($shortErr)";
} }
# 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</td> <td align="center" class="border" style="color:$lastAgeColor;">$lastAge</td>
@ -141,6 +149,8 @@ $reasonHilite = $Conf{CgiStatusHilightColor}{$Status{$host}{reason}}
<td align="center" class="border">sizeConsistency</td> <td align="center" class="border">sizeConsistency</td>
<td align="center" class="border"><a href="#" target="_blank">random-file.txt</a></td> <td align="center" class="border"><a href="#" target="_blank">random-file.txt</a></td>
EOF EOF
# Increment counter
if ( @Backups == 0 ) { if ( @Backups == 0 ) {
$hostCntNone++; $hostCntNone++;
$strNone .= $str; $strNone .= $str;
@ -150,6 +160,7 @@ EOF
} }
} }
# Time set
$fullSizeTot = sprintf("%.2f", $fullSizeTot / 1024); $fullSizeTot = sprintf("%.2f", $fullSizeTot / 1024);
$incrSizeTot = sprintf("%.2f", $incrSizeTot / 1024); $incrSizeTot = sprintf("%.2f", $incrSizeTot / 1024);
my $now = timeStamp2(time); my $now = timeStamp2(time);

Loading…
Cancel
Save