From 0d91f2f350b8f37216570fb4bf0d9d56b4c4bedd Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Fri, 5 Jul 2019 14:08:22 +0200 Subject: [PATCH] enhance barracuda cloudgen --- .../cloudgen/snmp/mode/boxservice.pm | 18 ++++-------- .../barracuda/cloudgen/snmp/mode/hardware.pm | 5 ++-- .../barracuda/cloudgen/snmp/mode/listvpns.pm | 7 ++--- .../cloudgen/snmp/mode/serverservice.pm | 18 ++++-------- .../barracuda/cloudgen/snmp/mode/vpnstatus.pm | 20 +++++-------- network/barracuda/cloudgen/snmp/plugin.pm | 28 +++++++++---------- 6 files changed, 38 insertions(+), 58 deletions(-) diff --git a/network/barracuda/cloudgen/snmp/mode/boxservice.pm b/network/barracuda/cloudgen/snmp/mode/boxservice.pm index 8def7ab86..c074f629b 100644 --- a/network/barracuda/cloudgen/snmp/mode/boxservice.pm +++ b/network/barracuda/cloudgen/snmp/mode/boxservice.pm @@ -24,7 +24,6 @@ use base qw(centreon::plugins::templates::counter); use strict; use warnings; -use Digest::MD5 qw(md5_hex); use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold); sub custom_status_output { @@ -69,15 +68,14 @@ sub prefix_services_output { sub new { my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1); + my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - $options{options}->add_options(arguments => - { - "filter-name:s" => { name => 'filter_name' }, - "warning-status:s" => { name => 'warning_status', default => '' }, - "critical-status:s" => { name => 'critical_status', default => '%{status} !~ /^started$/i' }, - }); + $options{options}->add_options(arguments => { + 'filter-name:s' => { name => 'filter_name' }, + 'warning-status:s' => { name => 'warning_status', default => '' }, + 'critical-status:s' => { name => 'critical_status', default => '%{status} !~ /^started$/i' }, + }); return $self; } @@ -140,10 +138,6 @@ sub manage_selection { $self->{output}->add_option_msg(short_msg => "No services found."); $self->{output}->option_exit(); } - - $self->{cache_name} = "barracuda_cloudgen_" . $self->{mode} . '_' . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . - (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')) . '_' . - (defined($self->{option_results}->{filter_name}) ? md5_hex($self->{option_results}->{filter_name}) : md5_hex('all')); } 1; diff --git a/network/barracuda/cloudgen/snmp/mode/hardware.pm b/network/barracuda/cloudgen/snmp/mode/hardware.pm index 9c830379b..9f69eeb34 100644 --- a/network/barracuda/cloudgen/snmp/mode/hardware.pm +++ b/network/barracuda/cloudgen/snmp/mode/hardware.pm @@ -57,9 +57,8 @@ sub new { my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - $options{options}->add_options(arguments => - { - }); + $options{options}->add_options(arguments => { + }); return $self; } diff --git a/network/barracuda/cloudgen/snmp/mode/listvpns.pm b/network/barracuda/cloudgen/snmp/mode/listvpns.pm index 4189236cd..a31dc0a5f 100644 --- a/network/barracuda/cloudgen/snmp/mode/listvpns.pm +++ b/network/barracuda/cloudgen/snmp/mode/listvpns.pm @@ -30,10 +30,9 @@ sub new { my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - $options{options}->add_options(arguments => - { - "filter-name:s" => { name => 'filter_name' }, - }); + $options{options}->add_options(arguments => { + 'filter-name:s' => { name => 'filter_name' }, + }); $self->{vpn} = {}; return $self; diff --git a/network/barracuda/cloudgen/snmp/mode/serverservice.pm b/network/barracuda/cloudgen/snmp/mode/serverservice.pm index 5e38a20ec..e43b8ec75 100644 --- a/network/barracuda/cloudgen/snmp/mode/serverservice.pm +++ b/network/barracuda/cloudgen/snmp/mode/serverservice.pm @@ -24,7 +24,6 @@ use base qw(centreon::plugins::templates::counter); use strict; use warnings; -use Digest::MD5 qw(md5_hex); use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold); sub custom_status_output { @@ -69,15 +68,14 @@ sub prefix_services_output { sub new { my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1); + my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - $options{options}->add_options(arguments => - { - "filter-name:s" => { name => 'filter_name' }, - "warning-status:s" => { name => 'warning_status', default => '' }, - "critical-status:s" => { name => 'critical_status', default => '%{status} !~ /^started$/i' }, - }); + $options{options}->add_options(arguments => { + 'filter-name:s' => { name => 'filter_name' }, + 'warning-status:s' => { name => 'warning_status', default => '' }, + 'critical-status:s' => { name => 'critical_status', default => '%{status} !~ /^started$/i' }, + }); return $self; } @@ -140,10 +138,6 @@ sub manage_selection { $self->{output}->add_option_msg(short_msg => "No services found."); $self->{output}->option_exit(); } - - $self->{cache_name} = "barracuda_cloudgen_" . $self->{mode} . '_' . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . - (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')) . '_' . - (defined($self->{option_results}->{filter_name}) ? md5_hex($self->{option_results}->{filter_name}) : md5_hex('all')); } 1; diff --git a/network/barracuda/cloudgen/snmp/mode/vpnstatus.pm b/network/barracuda/cloudgen/snmp/mode/vpnstatus.pm index 4fcd9de0d..c127e941d 100644 --- a/network/barracuda/cloudgen/snmp/mode/vpnstatus.pm +++ b/network/barracuda/cloudgen/snmp/mode/vpnstatus.pm @@ -24,7 +24,6 @@ use base qw(centreon::plugins::templates::counter); use strict; use warnings; -use Digest::MD5 qw(md5_hex); use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold); sub custom_status_output { @@ -69,16 +68,15 @@ sub prefix_vpns_output { sub new { my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1); + my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - $options{options}->add_options(arguments => - { - "filter-name:s" => { name => 'filter_name' }, - "warning-status:s" => { name => 'warning_status', default => '' }, - "critical-status:s" => { name => 'critical_status', default => '%{status} =~ /^down$/i' }, - }); - + $options{options}->add_options(arguments => { + 'filter-name:s' => { name => 'filter_name' }, + 'warning-status:s' => { name => 'warning_status', default => '' }, + 'critical-status:s' => { name => 'critical_status', default => '%{status} =~ /^down$/i' }, + }); + return $self; } @@ -138,10 +136,6 @@ sub manage_selection { $self->{output}->add_option_msg(short_msg => "No VPNs found."); $self->{output}->option_exit(); } - - $self->{cache_name} = "barracuda_cloudgen_" . $self->{mode} . '_' . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . - (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')) . '_' . - (defined($self->{option_results}->{filter_name}) ? md5_hex($self->{option_results}->{filter_name}) : md5_hex('all')); } 1; diff --git a/network/barracuda/cloudgen/snmp/plugin.pm b/network/barracuda/cloudgen/snmp/plugin.pm index e67fdb753..ba703ddb2 100644 --- a/network/barracuda/cloudgen/snmp/plugin.pm +++ b/network/barracuda/cloudgen/snmp/plugin.pm @@ -31,20 +31,20 @@ sub new { $self->{version} = '1.0'; %{$self->{modes}} = ( - 'cpu' => 'snmp_standard::mode::cpu', - 'cpu-detailed' => 'snmp_standard::mode::cpudetailed', - 'box-service' => 'network::barracuda::cloudgen::snmp::mode::boxservice', - 'hardware' => 'network::barracuda::cloudgen::snmp::mode::hardware', - 'interfaces' => 'snmp_standard::mode::interfaces', - 'list-interfaces' => 'snmp_standard::mode::listinterfaces', - 'list-vpns' => 'network::barracuda::cloudgen::snmp::mode::listvpns', - 'load' => 'snmp_standard::mode::loadaverage', - 'memory' => 'snmp_standard::mode::memory', - 'server-service' => 'network::barracuda::cloudgen::snmp::mode::serverservice', - 'storage' => 'snmp_standard::mode::storage', - 'uptime' => 'snmp_standard::mode::uptime', - 'vpn-status' => 'network::barracuda::cloudgen::snmp::mode::vpnstatus', - ); + 'cpu' => 'snmp_standard::mode::cpu', + 'cpu-detailed' => 'snmp_standard::mode::cpudetailed', + 'box-service' => 'network::barracuda::cloudgen::snmp::mode::boxservice', + 'hardware' => 'network::barracuda::cloudgen::snmp::mode::hardware', + 'interfaces' => 'snmp_standard::mode::interfaces', + 'list-interfaces' => 'snmp_standard::mode::listinterfaces', + 'list-vpns' => 'network::barracuda::cloudgen::snmp::mode::listvpns', + 'load' => 'snmp_standard::mode::loadaverage', + 'memory' => 'snmp_standard::mode::memory', + 'server-service' => 'network::barracuda::cloudgen::snmp::mode::serverservice', + 'storage' => 'snmp_standard::mode::storage', + 'uptime' => 'snmp_standard::mode::uptime', + 'vpn-status' => 'network::barracuda::cloudgen::snmp::mode::vpnstatus', + ); return $self; }