From e0714b51dc8b76c0c95a327a02b58b117210c488 Mon Sep 17 00:00:00 2001 From: Emmanuel Lacour Date: Mon, 7 Oct 2024 11:24:33 +0200 Subject: [PATCH] check_backuppc: force check on disabled host if host is specified --- check_backuppc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/check_backuppc b/check_backuppc index 8ee4731..f09f996 100755 --- a/check_backuppc +++ b/check_backuppc @@ -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 );