From 628f2a5e2e9174a7ee7c3e38ebf0240f7f4270d2 Mon Sep 17 00:00:00 2001 From: Daniel Berteaud Date: Mon, 11 Jan 2021 22:53:49 +0100 Subject: [PATCH] Add general stats to BackupPC monitoring script --- zabbix_conf/backuppc.conf | 7 +++++++ zabbix_scripts/check_backuppc_sudo | 13 +++++++------ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/zabbix_conf/backuppc.conf b/zabbix_conf/backuppc.conf index 94d157b..43249a7 100644 --- a/zabbix_conf/backuppc.conf +++ b/zabbix_conf/backuppc.conf @@ -15,3 +15,10 @@ UserParameter=backuppc.entity.discovery[*],/usr/bin/sudo /var/lib/zabbix/bin/dis # Returns a JSON object, use dependent item to split it UserParameter=backuppc.host[*],/usr/bin/sudo /var/lib/zabbix/bin/check_backuppc_sudo --host=$1 UserParameter=backuppc.entity[*],/usr/bin/sudo /var/lib/zabbix/bin/check_backuppc_sudo --entity=$1 + +# key: backuppc.host[{#BPCHOST}] +# or +# key: backuppc.general +# Same as entity checks for will process every hosts +# Returns a JSON object, use dependent item to split it +UserParameter=backuppc.general,/usr/bin/sudo /var/lib/zabbix/bin/check_backuppc_sudo --general diff --git a/zabbix_scripts/check_backuppc_sudo b/zabbix_scripts/check_backuppc_sudo index 6f98d47..3022d3a 100644 --- a/zabbix_scripts/check_backuppc_sudo +++ b/zabbix_scripts/check_backuppc_sudo @@ -10,11 +10,13 @@ use Getopt::Long; use Statistics::Descriptive; use Data::Dumper; -my $host = undef; -my $entity = undef; -my $pretty = 0; +my $general = 0; +my $host = undef; +my $entity = undef; +my $pretty = 0; GetOptions( + "general" => \$general, "host=s" => \$host, "entity=s" => \$entity, "pretty" => \$pretty @@ -103,7 +105,7 @@ if ( $host ) { $json->{max_errors} = $conf->{MaxXferError} || 0; } -} elsif ( $entity ) { +} elsif ( $entity or $general) { $json = { perf => 0, @@ -120,7 +122,7 @@ if ( $host ) { my $entity_total_comp = 0; foreach my $host ( keys %{ $bpc->HostInfoRead } ) { - next unless $host =~ m/^(vm_)?\Q$entity\E_.*/; + next unless ($host =~ m/^(vm_)?\Q$entity\E_.*/ or $general); my $full_size; $json->{hosts}++; @@ -171,7 +173,6 @@ if ( $host ) { foreach my $key ( qw(ratio perf) ) { $json->{$key} = sprintf( "%.2f", $json->{$key} ); } - } else { print<<"EOF";