Don't count vm as an entity in BackupPC's entities discovery

tags/zabbix-agent-addons-0.2.69-1
Daniel Berteaud 6 years ago
parent ce3946344f
commit e51f0065a0
  1. 16
      zabbix_scripts/disco_backuppc_sudo

@ -31,26 +31,26 @@ my $json;
if ($entities) { if ($entities) {
my %entities = (); my %entities = ();
foreach my $host (keys %$hosts){ foreach my $host ( keys %$hosts ){
if ($host =~ m/^(?:vm_)?([^_]+)_.*/) { if ( $host =~ m/^(?:vm_)?([^_]+)_.*/ and $1 ne 'vm' ) {
$entities{$1}= 1; $entities{$1}= 1;
} }
} }
push @{$json->{data}}, { '{#BPC_ENTITY}' => $_ } foreach ( keys %entities ); push @{$json->{data}}, { '{#BPC_ENTITY}' => $_ } foreach ( keys %entities );
} elsif ($hosts){ } elsif ($hosts){
foreach my $host (keys %$hosts){ foreach my $host ( keys %$hosts ){
my $hostConf = $bpc->ConfigDataRead($host); my $hostConf = $bpc->ConfigDataRead($host);
my $conf = { %$mainConf, %$hostConf }; my $conf = { %$mainConf, %$hostConf };
my $warning = $conf->{EMailNotifyOldBackupDays}; my $warning = $conf->{EMailNotifyOldBackupDays};
my $errors = (defined $conf->{MaxXferError}) ? $conf->{MaxXferError}: '0'; my $errors = ( defined $conf->{MaxXferError} ) ? $conf->{MaxXferError}: '0';
my $monitoring = $conf->{ZabbixMonitoring} || 1; my $monitoring = $conf->{ZabbixMonitoring} || 1;
my $status = ($conf->{BackupsDisable} gt 0 or $monitoring eq '0') ? '0' : '1'; my $status = ( $conf->{BackupsDisable} gt 0 or $monitoring eq '0' ) ? '0' : '1';
push @{$json->{data}}, push @{$json->{data}},
{ {
"{#BPCHOST}" => $host, "{#BPCHOST}" => $host,
"{#BPCNOBACKUPWARNING}" => $warning, "{#BPCNOBACKUPWARNING}" => $warning,
"{#BPCMAXERROR}" => $errors, "{#BPCMAXERROR}" => $errors,
"{#BPCSTATUS}" => $status, "{#BPCSTATUS}" => $status,
}; };
} }
} }

Loading…
Cancel
Save