Remove crazy and useless regex to exclude hosts from BackupPC

tags/zabbix-agent-addons-0.2.66-1
Daniel Berteaud 6 years ago
parent 36a0844194
commit b32897cc3a
  1. 30
      zabbix_scripts/disco_backuppc_sudo

@ -5,19 +5,6 @@ use BackupPC::Lib;
use BackupPC::CGI::Lib;
use POSIX;
use JSON;
use Getopt::Long;
use MIME::Base64 qw( decode_base64 );
my $regex = '.*';
my $base64 = 0;
GetOptions(
"regex=s" => \$regex,
"base64" => \$base64
);
$regex = decode_base64($regex) if ($base64);
$regex = qr($regex);
# We need to switch to backuppc UID/GID
my $uid = getuid();
@ -26,19 +13,20 @@ my (undef,undef,$bkpuid,$bkpgid) = getpwnam('backuppc');
setuid($bkpuid) if ($uid ne $bkpuid);
setgid($bkpgid) if ($gid ne $bkpgid);
my $bpc = BackupPC::Lib->new();
my $hosts = $bpc->HostInfoRead();
my $bpc = BackupPC::Lib->new();
my $hosts = $bpc->HostInfoRead();
my $mainConf = $bpc->ConfigDataRead();
my $json;
@{$json->{data}} = ();
foreach my $host (keys %$hosts){
next unless ($host =~ m!$regex!);
my $hostConf = $bpc->ConfigDataRead($host);
my $conf = { %$mainConf, %$hostConf };
my $warning = $conf->{EMailNotifyOldBackupDays};
my $errors = (defined $conf->{MaxXferError}) ? $conf->{MaxXferError}: '0';
my $status = ($conf->{BackupsDisable} eq '1') ? 'disabled':(($conf->{ZabbixMonitoring} eq '0') ? '0':'1');
my $hostConf = $bpc->ConfigDataRead($host);
my $conf = { %$mainConf, %$hostConf };
my $warning = $conf->{EMailNotifyOldBackupDays};
my $errors = (defined $conf->{MaxXferError}) ? $conf->{MaxXferError}: '0';
my $monitoring = $conf->{ZabbixMonitoring} || 1;
my $status = ($conf->{BackupsDisable} eq '1' or $monitoring eq '0') ? '0' : '1';
push @{$json->{data}},
{
"{#BPCHOST}" => $host,

Loading…
Cancel
Save