check_backuppc: force check on disabled host if host is specified

This commit is contained in:
Emmanuel Lacour 2024-10-07 11:24:33 +02:00 committed by Benjamin Renard
parent 9bed5546ee
commit 7fdfa4d41e
Signed by: bn8
GPG key ID: 3E2E1CE1907115BC

View file

@ -78,6 +78,9 @@ $goodOpt = GetOptions(
@hostsDesired = () if $#hostsDesired < 0;
@hostsExcluded = () if $#hostsExcluded < 0;
# Always check disabled host if a named host is provided (when backup is trigerred by cron)
$forceCheckOnDisabledHosts = 1 if ( @hostsDesired && scalar(@hostsDesired) );
if ($opt_V)
{
print "check_backuppc - " . $version . "\n";
@ -151,7 +154,7 @@ foreach my $host (sort(keys(%Status)))
next if (@ownerOnly and not grep {/$owner/} @ownerOnly);
my %host_conf = %{$server->ConfigDataRead($host)};
$Status{$host}{BackupsDisable} = $host_conf{BackupsDisable};
next if ( $Status{$host}{BackupsDisable} eq 2 and not $forceCheckOnDisabledHosts);
next if ( $Status{$host}{BackupsDisable} && $Status{$host}{BackupsDisable} == 2 and not $forceCheckOnDisabledHosts );
next if (@hostsDesired and not grep {/^$host$/} @hostsDesired);
next if (@hostsExcluded and grep {/^$host$/} @hostsExcluded);
next if ($Status{$host}{'type'} eq 'archive');
@ -222,7 +225,7 @@ if ( $statusCode eq 'OK' ) {
foreach my $host ( keys %Status ) {
next if (@hostsDesired and not grep {/^$host$/} @hostsDesired);
next if (@hostsExcluded and grep {/^$host$/} @hostsExcluded);
next if ( $Status{$host}{BackupsDisable} );
next if ( $Status{$host}{BackupsDisable} && $Status{$host}{BackupsDisable} == 2 and not $forceCheckOnDisabledHosts );
next if ($Status{$host}{'type'} eq 'archive');
if ( $Status{$host}{statusCode} && $Status{$host}{statusCode} ne 'OK' ) {
$statusMsg .= ", " unless ( $first_host );