From 34ef6daf64a4940a91e05e16b1450aa724974874 Mon Sep 17 00:00:00 2001 From: Daniel Berteaud Date: Thu, 18 Apr 2013 13:36:07 +0200 Subject: [PATCH] Pass a regex to backuppc discovery. Default is .*, so every hosts are returned. You can use this to selectively ignore hosts --- zabbix_conf/backuppc.conf | 2 +- zabbix_scripts/disco_backuppc_sudo | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/zabbix_conf/backuppc.conf b/zabbix_conf/backuppc.conf index 46388d5..a5d12ac 100644 --- a/zabbix_conf/backuppc.conf +++ b/zabbix_conf/backuppc.conf @@ -5,7 +5,7 @@ # Other available macros: # {#BPCPERIOD}: Max age (in day) the oldest backup should be # {#BPCHOST}: name of the backup host -UserParameter=backuppc.host.discovery,/usr/bin/sudo /var/lib/zabbix/bin/disco_backuppc_sudo +UserParameter=backuppc.host.discovery[*],/usr/bin/sudo /var/lib/zabbix/bin/disco_backuppc_sudo --regex=$1 # Item prototypes # key: backuppc.host.info[{#BPCHOST},item] diff --git a/zabbix_scripts/disco_backuppc_sudo b/zabbix_scripts/disco_backuppc_sudo index bce56d5..86b15dc 100644 --- a/zabbix_scripts/disco_backuppc_sudo +++ b/zabbix_scripts/disco_backuppc_sudo @@ -5,6 +5,13 @@ use BackupPC::Lib; use BackupPC::CGI::Lib; use POSIX; use JSON; +use Getopt::Long; + +my $regex = '.*'; + +GetOptions( + "regex=s" => \$regex +); # We need to switch to backuppc UID/GID my $uid = getuid(); @@ -19,6 +26,7 @@ my $mainConf = $bpc->ConfigDataRead(); my $json; foreach my $host (keys %$hosts){ + next unless ($host =~ m!$regex!); my $hostConf = $bpc->ConfigDataRead($host); my $conf = { %$mainConf, %$hostConf }; my $period = ($conf->{FullPeriod} >= $conf->{IncrPeriod}) ? $conf->{IncrPeriod} : $conf->{FullPeriod};