From b2446abfd0b6178156c6d572b9063b92159be005 Mon Sep 17 00:00:00 2001 From: Benjamin Renard Date: Thu, 5 Apr 2018 19:21:33 +0200 Subject: [PATCH] Add -f parameter to force check on disabled hosts --- check_backuppc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/check_backuppc b/check_backuppc index da7cc17..ccc1d22 100755 --- a/check_backuppc +++ b/check_backuppc @@ -44,7 +44,7 @@ Getopt::Long::Configure('bundling'); use lib "/usr/share/backuppc/lib"; use BackupPC::Lib; -my $version = '1.1.2'; +my $version = '1.1.3'; my $warnDaysOld = 2; my $critDaysOld = 7; my $verbose = 0; @@ -54,6 +54,7 @@ my $goodOpt = 0; my @ownerOnly; my @hostsDesired; my @hostsExcluded; +my $forceCheckOnDisabledHosts; my %Status; my $statusCode = 'OK'; my $ok_count = 0; @@ -71,7 +72,8 @@ $goodOpt = GetOptions( 'V' => \$opt_V, 'version' => \$opt_V, 'h' => \$opt_h, 'help' => \$opt_h, 'H=s' => \@hostsDesired, 'hostname=s' => \@hostsDesired, - 'x=s' => \@hostsExcluded, 'exclude=s' => \@hostsExcluded); + 'x=s' => \@hostsExcluded, 'exclude=s' => \@hostsExcluded, + 'f' => \$forceCheckOnDisabledHosts, 'force=s' => \$forceCheckOnDisabledHosts); @hostsDesired = () if $#hostsDesired < 0; @hostsExcluded = () if $#hostsExcluded < 0; @@ -89,6 +91,7 @@ if ($opt_h or not $goodOpt) print " --hostname,-H only check the specified host\n"; print " --exclude,-x do not check the specified host\n"; print " --owner,-o do only hosts of specified user\n"; + print " --force,-f force check even if host is disabled\n"; print " --warning,-w days old of last good backup to cause a warning\n"; print " --critical,-c days old of last good backup to be critical\n"; print " --verbose,-v increase verbosity\n"; @@ -148,7 +151,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} ); + next if ( $Status{$host}{BackupsDisable} 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');