From 3b7d2dfbd02f1e5708e78b1f22e3d4b264a6de46 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Tue, 26 Mar 2019 16:28:40 +0100 Subject: [PATCH] cleaning code (storage) --- centreon-plugins/snmp_standard/mode/memory.pm | 25 +++------ .../avid/isis/snmp/mode/performance.pm | 19 ++----- .../storage/avid/isis/snmp/mode/usage.pm | 29 ++++------- .../dell/compellent/local/mode/volumeusage.pm | 52 +++++++++---------- .../dell/fluidfs/snmp/mode/volumeusage.pm | 30 ++++------- .../storage/hp/eva/cli/mode/storageusage.pm | 29 ++++------- .../netapp/restapi/mode/aggregateusage.pm | 42 ++++++--------- .../storage/netapp/restapi/mode/lunusage.pm | 26 +++------- .../netapp/restapi/mode/volumeusage.pm | 50 +++++++----------- .../storage/netapp/snmp/mode/filesys.pm | 33 +++++------- .../storage/netapp/snmp/mode/qtreeusage.pm | 38 +++++--------- .../storage/oracle/zs/snmp/mode/shareusage.pm | 34 +++++------- .../purestorage/restapi/mode/volumeusage.pm | 32 ++++-------- .../storage/quantum/dxi/ssh/mode/diskusage.pm | 47 ++++++++--------- .../storage/quantum/dxi/ssh/mode/memory.pm | 43 +++++++-------- .../storage/quantum/dxi/ssh/mode/reduction.pm | 31 +++++------ .../quantum/dxi/ssh/mode/throughput.pm | 29 +++++------ 17 files changed, 225 insertions(+), 364 deletions(-) diff --git a/centreon-plugins/snmp_standard/mode/memory.pm b/centreon-plugins/snmp_standard/mode/memory.pm index 0defe7513..9c19fadab 100644 --- a/centreon-plugins/snmp_standard/mode/memory.pm +++ b/centreon-plugins/snmp_standard/mode/memory.pm @@ -25,13 +25,11 @@ use base qw(centreon::plugins::templates::counter); use strict; use warnings; -my $instance_mode; - sub custom_usage_perfdata { my ($self, %options) = @_; my %total_options = (); - if ($instance_mode->{option_results}->{units} eq '%') { + if ($self->{instance_mode}->{option_results}->{units} eq '%') { $total_options{total} = $self->{result_values}->{total}; $total_options{cast_int} = 1; } @@ -49,10 +47,10 @@ sub custom_usage_threshold { my ($exit, $threshold_value); $threshold_value = $self->{result_values}->{used}; - $threshold_value = $self->{result_values}->{free} if (defined($instance_mode->{option_results}->{free})); - if ($instance_mode->{option_results}->{units} eq '%') { + $threshold_value = $self->{result_values}->{free} if (defined($self->{instance_mode}->{option_results}->{free})); + if ($self->{instance_mode}->{option_results}->{units} eq '%') { $threshold_value = $self->{result_values}->{prct_used}; - $threshold_value = $self->{result_values}->{prct_free} if (defined($instance_mode->{option_results}->{free})); + $threshold_value = $self->{result_values}->{prct_free} if (defined($self->{instance_mode}->{option_results}->{free})); } $exit = $self->{perfdata}->threshold_check(value => $threshold_value, threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, @@ -94,7 +92,7 @@ sub custom_swap_perfdata { my ($self, %options) = @_; my %total_options = (); - if ($instance_mode->{option_results}->{units} eq '%') { + if ($self->{instance_mode}->{option_results}->{units} eq '%') { $total_options{total} = $self->{result_values}->{total}; $total_options{cast_int} = 1; } @@ -112,10 +110,10 @@ sub custom_swap_threshold { my ($exit, $threshold_value); $threshold_value = $self->{result_values}->{used}; - $threshold_value = $self->{result_values}->{available} if (defined($instance_mode->{option_results}->{free})); - if ($instance_mode->{option_results}->{units} eq '%') { + $threshold_value = $self->{result_values}->{available} if (defined($self->{instance_mode}->{option_results}->{free})); + if ($self->{instance_mode}->{option_results}->{units} eq '%') { $threshold_value = $self->{result_values}->{prct_used}; - $threshold_value = $self->{result_values}->{prct_available} if (defined($instance_mode->{option_results}->{free})); + $threshold_value = $self->{result_values}->{prct_available} if (defined($self->{instance_mode}->{option_results}->{free})); } $exit = $self->{perfdata}->threshold_check(value => $threshold_value, threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, @@ -231,13 +229,6 @@ sub new { return $self; } -sub check_options { - my ($self, %options) = @_; - $self->SUPER::check_options(%options); - - $instance_mode = $self; -} - my $mapping = { memTotalSwap => { oid => '.1.3.6.1.4.1.2021.4.3' }, memAvailSwap => { oid => '.1.3.6.1.4.1.2021.4.4' }, diff --git a/centreon-plugins/storage/avid/isis/snmp/mode/performance.pm b/centreon-plugins/storage/avid/isis/snmp/mode/performance.pm index 8e94fc979..d99604970 100644 --- a/centreon-plugins/storage/avid/isis/snmp/mode/performance.pm +++ b/centreon-plugins/storage/avid/isis/snmp/mode/performance.pm @@ -25,8 +25,6 @@ use base qw(centreon::plugins::templates::counter); use strict; use warnings; -my $instance_mode; - sub custom_client_perfdata { my ($self, %options) = @_; @@ -41,7 +39,7 @@ sub custom_client_threshold { my ($self, %options) = @_; my ($exit, $threshold_value); - $threshold_value = defined($instance_mode->{option_results}->{percent}) ? $self->{result_values}->{prct_active} : $self->{result_values}->{active} ; + $threshold_value = defined($self->{instance_mode}->{option_results}->{percent}) ? $self->{result_values}->{prct_active} : $self->{result_values}->{active} ; $exit = $self->{perfdata}->threshold_check(value => $threshold_value, threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, { label => 'warning-' . $self->{label}, exit_litteral => 'warning' } ]); @@ -129,20 +127,13 @@ sub new { bless $self, $class; $self->{version} = '1.0'; - $options{options}->add_options(arguments => - { - "percent" => { name => 'percent' }, - }); + $options{options}->add_options(arguments => { + "percent" => { name => 'percent' }, + }); + return $self; } -sub check_options { - my ($self, %options) = @_; - $self->SUPER::check_options(%options); - - $instance_mode = $self; -} - my $oid_ReadMegabytesPerSecond = '.1.3.6.1.4.1.526.20.3.2.0'; my $oid_WriteMegabytesPerSecond = '.1.3.6.1.4.1.526.20.3.3.0'; my $oid_MessagesPerSecond = '.1.3.6.1.4.1.526.20.3.4.0'; diff --git a/centreon-plugins/storage/avid/isis/snmp/mode/usage.pm b/centreon-plugins/storage/avid/isis/snmp/mode/usage.pm index 480bd8370..2f43b5f67 100644 --- a/centreon-plugins/storage/avid/isis/snmp/mode/usage.pm +++ b/centreon-plugins/storage/avid/isis/snmp/mode/usage.pm @@ -25,19 +25,17 @@ use base qw(centreon::plugins::templates::counter); use strict; use warnings; -my $instance_mode; - sub custom_usage_perfdata { my ($self, %options) = @_; my $label = 'used'; my $value_perf = $self->{result_values}->{used}; - if (defined($instance_mode->{option_results}->{free})) { + if (defined($self->{instance_mode}->{option_results}->{free})) { $label = 'free'; $value_perf = $self->{result_values}->{free}; } my %total_options = (); - if ($instance_mode->{option_results}->{units} eq '%') { + if ($self->{instance_mode}->{option_results}->{units} eq '%') { $total_options{total} = $self->{result_values}->{allocated}; $total_options{cast_int} = 1; } @@ -58,10 +56,10 @@ sub custom_usage_threshold { my ($exit, $threshold_value); $threshold_value = $self->{result_values}->{used}; - $threshold_value = $self->{result_values}->{free} if (defined($instance_mode->{option_results}->{free})); - if ($instance_mode->{option_results}->{units} eq '%') { + $threshold_value = $self->{result_values}->{free} if (defined($self->{instance_mode}->{option_results}->{free})); + if ($self->{instance_mode}->{option_results}->{units} eq '%') { $threshold_value = $self->{result_values}->{prct_used}; - $threshold_value = $self->{result_values}->{prct_free} if (defined($instance_mode->{option_results}->{free})); + $threshold_value = $self->{result_values}->{prct_free} if (defined($self->{instance_mode}->{option_results}->{free})); } $exit = $self->{perfdata}->threshold_check(value => $threshold_value, threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, { label => 'warning-'. $self->{label}, exit_litteral => 'warning' } ]); @@ -152,21 +150,14 @@ sub new { bless $self, $class; $self->{version} = '1.0'; - $options{options}->add_options(arguments => - { - "units:s" => { name => 'units', default => '%' }, - "free" => { name => 'free' }, - }); + $options{options}->add_options(arguments => { + "units:s" => { name => 'units', default => '%' }, + "free" => { name => 'free' }, + }); + return $self; } -sub check_options { - my ($self, %options) = @_; - $self->SUPER::check_options(%options); - - $instance_mode = $self; -} - my $oid_TotalSystemMB = '.1.3.6.1.4.1.526.20.4.2.0'; my $oid_TotalAllocatedMB = '.1.3.6.1.4.1.526.20.4.3.0'; my $oid_TotalUsedMB = '.1.3.6.1.4.1.526.20.4.4.0'; diff --git a/centreon-plugins/storage/dell/compellent/local/mode/volumeusage.pm b/centreon-plugins/storage/dell/compellent/local/mode/volumeusage.pm index 67c7b072f..a73f050ce 100644 --- a/centreon-plugins/storage/dell/compellent/local/mode/volumeusage.pm +++ b/centreon-plugins/storage/dell/compellent/local/mode/volumeusage.pm @@ -98,21 +98,19 @@ sub sc_init { return 0; } -my $instance_mode; - sub custom_usage_perfdata { my ($self, %options) = @_; my $label = $self->{result_values}->{type} . '_used'; my $value_perf = $self->{result_values}->{used}; - if (defined($instance_mode->{option_results}->{free})) { + if (defined($self->{instance_mode}->{option_results}->{free})) { $label = $self->{result_values}->{type} . '_free'; $value_perf = $self->{result_values}->{free}; } my $extra_label = ''; $extra_label = '_' . $self->{result_values}->{display} if (!defined($options{extra_instance}) || $options{extra_instance} != 0); my %total_options = (); - if ($instance_mode->{option_results}->{units} eq '%') { + if ($self->{instance_mode}->{option_results}->{units} eq '%') { $total_options{total} = $self->{result_values}->{total}; $total_options{cast_int} = 1; } @@ -129,10 +127,10 @@ sub custom_usage_threshold { my ($exit, $threshold_value); $threshold_value = $self->{result_values}->{used}; - $threshold_value = $self->{result_values}->{free} if (defined($instance_mode->{option_results}->{free})); - if ($instance_mode->{option_results}->{units} eq '%') { + $threshold_value = $self->{result_values}->{free} if (defined($self->{instance_mode}->{option_results}->{free})); + if ($self->{instance_mode}->{option_results}->{units} eq '%') { $threshold_value = $self->{result_values}->{prct_used}; - $threshold_value = $self->{result_values}->{prct_free} if (defined($instance_mode->{option_results}->{free})); + $threshold_value = $self->{result_values}->{prct_free} if (defined($self->{instance_mode}->{option_results}->{free})); } $exit = $self->{perfdata}->threshold_check(value => $threshold_value, threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, { label => 'warning-'. $self->{label}, exit_litteral => 'warning' } ]); return $exit; @@ -177,24 +175,24 @@ sub new { bless $self, $class; $self->{version} = '1.0'; - $options{options}->add_options(arguments => - { - "cem-host:s" => { name => 'cem_host' }, - "cem-user:s" => { name => 'cem_user' }, - "cem-password:s" => { name => 'cem_password' }, - "cem-port:s" => { name => 'cem_port', default => 3033 }, - "sdk-path-dll:s" => { name => 'sdk_path_dll' }, - "timeout:s" => { name => 'timeout', default => 50 }, - "command:s" => { name => 'command', default => 'powershell.exe' }, - "command-path:s" => { name => 'command_path' }, - "command-options:s" => { name => 'command_options', default => '-InputFormat none -NoLogo -EncodedCommand' }, - "no-ps" => { name => 'no_ps' }, - "ps-exec-only" => { name => 'ps_exec_only' }, - "ps-sc-filter:s" => { name => 'ps_sc_filter' }, - "ps-sc-volume:s" => { name => 'ps_sc_volume' }, - "units:s" => { name => 'units', default => '%' }, - "free" => { name => 'free' }, - }); + $options{options}->add_options(arguments => { + "cem-host:s" => { name => 'cem_host' }, + "cem-user:s" => { name => 'cem_user' }, + "cem-password:s" => { name => 'cem_password' }, + "cem-port:s" => { name => 'cem_port', default => 3033 }, + "sdk-path-dll:s" => { name => 'sdk_path_dll' }, + "timeout:s" => { name => 'timeout', default => 50 }, + "command:s" => { name => 'command', default => 'powershell.exe' }, + "command-path:s" => { name => 'command_path' }, + "command-options:s" => { name => 'command_options', default => '-InputFormat none -NoLogo -EncodedCommand' }, + "no-ps" => { name => 'no_ps' }, + "ps-exec-only" => { name => 'ps_exec_only' }, + "ps-sc-filter:s" => { name => 'ps_sc_filter' }, + "ps-sc-volume:s" => { name => 'ps_sc_volume' }, + "units:s" => { name => 'units', default => '%' }, + "free" => { name => 'free' }, + }); + return $self; } @@ -209,9 +207,7 @@ sub check_options { $self->{output}->add_option_msg(short_msg => "Need to specify --" . $label_opt . " option."); $self->{output}->option_exit(); } - } - - $instance_mode = $self; + } } sub manage_selection { diff --git a/centreon-plugins/storage/dell/fluidfs/snmp/mode/volumeusage.pm b/centreon-plugins/storage/dell/fluidfs/snmp/mode/volumeusage.pm index 1ec933150..6486d5e53 100644 --- a/centreon-plugins/storage/dell/fluidfs/snmp/mode/volumeusage.pm +++ b/centreon-plugins/storage/dell/fluidfs/snmp/mode/volumeusage.pm @@ -25,21 +25,19 @@ use base qw(centreon::plugins::templates::counter); use strict; use warnings; -my $instance_mode; - sub custom_usage_perfdata { my ($self, %options) = @_; my $label = 'used'; my $value_perf = $self->{result_values}->{used}; - if (defined($instance_mode->{option_results}->{free})) { + if (defined($self->{instance_mode}->{option_results}->{free})) { $label = 'free'; $value_perf = $self->{result_values}->{free}; } my $extra_label = ''; $extra_label = '_' . $self->{result_values}->{display} if (!defined($options{extra_instance}) || $options{extra_instance} != 0); my %total_options = (); - if ($instance_mode->{option_results}->{units} eq '%') { + if ($self->{instance_mode}->{option_results}->{units} eq '%') { $total_options{total} = $self->{result_values}->{total}; $total_options{cast_int} = 1; } @@ -56,10 +54,10 @@ sub custom_usage_threshold { my ($exit, $threshold_value); $threshold_value = $self->{result_values}->{used}; - $threshold_value = $self->{result_values}->{free} if (defined($instance_mode->{option_results}->{free})); - if ($instance_mode->{option_results}->{units} eq '%') { + $threshold_value = $self->{result_values}->{free} if (defined($self->{instance_mode}->{option_results}->{free})); + if ($self->{instance_mode}->{option_results}->{units} eq '%') { $threshold_value = $self->{result_values}->{prct_used}; - $threshold_value = $self->{result_values}->{prct_free} if (defined($instance_mode->{option_results}->{free})); + $threshold_value = $self->{result_values}->{prct_free} if (defined($self->{instance_mode}->{option_results}->{free})); } $exit = $self->{perfdata}->threshold_check(value => $threshold_value, threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, { label => 'warning-'. $self->{label}, exit_litteral => 'warning' } ]); return $exit; @@ -117,23 +115,15 @@ sub new { bless $self, $class; $self->{version} = '1.0'; - $options{options}->add_options(arguments => - { - "filter-name:s" => { name => 'filter_name' }, - "units:s" => { name => 'units', default => '%' }, - "free" => { name => 'free' }, - }); + $options{options}->add_options(arguments => { + "filter-name:s" => { name => 'filter_name' }, + "units:s" => { name => 'units', default => '%' }, + "free" => { name => 'free' }, + }); return $self; } -sub check_options { - my ($self, %options) = @_; - $self->SUPER::check_options(%options); - - $instance_mode = $self; -} - sub prefix_volume_output { my ($self, %options) = @_; diff --git a/centreon-plugins/storage/hp/eva/cli/mode/storageusage.pm b/centreon-plugins/storage/hp/eva/cli/mode/storageusage.pm index 9c55b59f5..a30a974be 100644 --- a/centreon-plugins/storage/hp/eva/cli/mode/storageusage.pm +++ b/centreon-plugins/storage/hp/eva/cli/mode/storageusage.pm @@ -43,19 +43,17 @@ sub set_counters { ]; } -my $instance_mode; - sub custom_usage_perfdata { my ($self, %options) = @_; my $label = 'used'; my $value_perf = $self->{result_values}->{used}; - if (defined($instance_mode->{option_results}->{free})) { + if (defined($self->{instance_mode}->{option_results}->{free})) { $label = 'free'; $value_perf = $self->{result_values}->{free}; } my %total_options = (); - if ($instance_mode->{option_results}->{units} eq '%') { + if ($self->{instance_mode}->{option_results}->{units} eq '%') { $total_options{total} = $self->{result_values}->{total}; $total_options{cast_int} = 1; } @@ -72,10 +70,10 @@ sub custom_usage_threshold { my ($exit, $threshold_value); $threshold_value = $self->{result_values}->{used}; - $threshold_value = $self->{result_values}->{free} if (defined($instance_mode->{option_results}->{free})); - if ($instance_mode->{option_results}->{units} eq '%') { + $threshold_value = $self->{result_values}->{free} if (defined($self->{instance_mode}->{option_results}->{free})); + if ($self->{instance_mode}->{option_results}->{units} eq '%') { $threshold_value = $self->{result_values}->{prct_used}; - $threshold_value = $self->{result_values}->{prct_free} if (defined($instance_mode->{option_results}->{free})); + $threshold_value = $self->{result_values}->{prct_free} if (defined($self->{instance_mode}->{option_results}->{free})); } $exit = $self->{perfdata}->threshold_check(value => $threshold_value, threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, { label => 'warning-'. $self->{label}, exit_litteral => 'warning' } ]); return $exit; @@ -115,21 +113,14 @@ sub new { bless $self, $class; $self->{version} = '1.0'; - $options{options}->add_options(arguments => - { - "units:s" => { name => 'units', default => '%' }, - "free" => { name => 'free' }, - }); + $options{options}->add_options(arguments => { + "units:s" => { name => 'units', default => '%' }, + "free" => { name => 'free' }, + }); + return $self; } -sub check_options { - my ($self, %options) = @_; - $self->SUPER::check_options(%options); - - $instance_mode = $self; -} - sub manage_selection { my ($self, %options) = @_; diff --git a/centreon-plugins/storage/netapp/restapi/mode/aggregateusage.pm b/centreon-plugins/storage/netapp/restapi/mode/aggregateusage.pm index 099dff090..fbf6661b6 100644 --- a/centreon-plugins/storage/netapp/restapi/mode/aggregateusage.pm +++ b/centreon-plugins/storage/netapp/restapi/mode/aggregateusage.pm @@ -25,8 +25,6 @@ use base qw(centreon::plugins::templates::counter); use strict; use warnings; -my $instance_mode; - sub custom_usage_perfdata { my ($self, %options) = @_; @@ -46,10 +44,10 @@ sub custom_usage_threshold { my ($exit, $threshold_value); $threshold_value = $self->{result_values}->{used}; - $threshold_value = $self->{result_values}->{free} if (defined($instance_mode->{option_results}->{free})); - if ($instance_mode->{option_results}->{units} eq '%') { + $threshold_value = $self->{result_values}->{free} if (defined($self->{instance_mode}->{option_results}->{free})); + if ($self->{instance_mode}->{option_results}->{units} eq '%') { $threshold_value = $self->{result_values}->{prct_used}; - $threshold_value = $self->{result_values}->{prct_free} if (defined($instance_mode->{option_results}->{free})); + $threshold_value = $self->{result_values}->{prct_free} if (defined($self->{instance_mode}->{option_results}->{free})); } $exit = $self->{perfdata}->threshold_check(value => $threshold_value, threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, @@ -110,10 +108,10 @@ sub custom_snapshot_threshold { my ($exit, $threshold_value); $threshold_value = $self->{result_values}->{used}; - $threshold_value = $self->{result_values}->{free} if (defined($instance_mode->{option_results}->{free})); - if ($instance_mode->{option_results}->{units} eq '%') { + $threshold_value = $self->{result_values}->{free} if (defined($self->{instance_mode}->{option_results}->{free})); + if ($self->{instance_mode}->{option_results}->{units} eq '%') { $threshold_value = $self->{result_values}->{prct_used}; - $threshold_value = $self->{result_values}->{prct_free} if (defined($instance_mode->{option_results}->{free})); + $threshold_value = $self->{result_values}->{prct_free} if (defined($self->{instance_mode}->{option_results}->{free})); } $exit = $self->{perfdata}->threshold_check(value => $threshold_value, threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, @@ -194,25 +192,17 @@ sub new { bless $self, $class; $self->{version} = '1.0'; - $options{options}->add_options(arguments => - { - "filter-name:s" => { name => 'filter_name' }, - "filter-node:s" => { name => 'filter_node' }, - "filter-cluster:s" => { name => 'filter_cluster' }, - "filter-state:s" => { name => 'filter_state' }, - "filter-type:s" => { name => 'filter_type' }, - "units:s" => { name => 'units', default => '%' }, - "free" => { name => 'free' }, - }); - - return $self; -} + $options{options}->add_options(arguments => { + "filter-name:s" => { name => 'filter_name' }, + "filter-node:s" => { name => 'filter_node' }, + "filter-cluster:s" => { name => 'filter_cluster' }, + "filter-state:s" => { name => 'filter_state' }, + "filter-type:s" => { name => 'filter_type' }, + "units:s" => { name => 'units', default => '%' }, + "free" => { name => 'free' }, + }); -sub check_options { - my ($self, %options) = @_; - $self->SUPER::check_options(%options); - - $instance_mode = $self; + return $self; } sub manage_selection { diff --git a/centreon-plugins/storage/netapp/restapi/mode/lunusage.pm b/centreon-plugins/storage/netapp/restapi/mode/lunusage.pm index 94a7abd62..e068d17a0 100644 --- a/centreon-plugins/storage/netapp/restapi/mode/lunusage.pm +++ b/centreon-plugins/storage/netapp/restapi/mode/lunusage.pm @@ -25,8 +25,6 @@ use base qw(centreon::plugins::templates::counter); use strict; use warnings; -my $instance_mode; - sub custom_usage_perfdata { my ($self, %options) = @_; @@ -46,10 +44,10 @@ sub custom_usage_threshold { my ($exit, $threshold_value); $threshold_value = $self->{result_values}->{used}; - $threshold_value = $self->{result_values}->{free} if (defined($instance_mode->{option_results}->{free})); - if ($instance_mode->{option_results}->{units} eq '%') { + $threshold_value = $self->{result_values}->{free} if (defined($self->{instance_mode}->{option_results}->{free})); + if ($self->{instance_mode}->{option_results}->{units} eq '%') { $threshold_value = $self->{result_values}->{prct_used}; - $threshold_value = $self->{result_values}->{prct_free} if (defined($instance_mode->{option_results}->{free})); + $threshold_value = $self->{result_values}->{prct_free} if (defined($self->{instance_mode}->{option_results}->{free})); } $exit = $self->{perfdata}->threshold_check(value => $threshold_value, threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, @@ -122,23 +120,15 @@ sub new { bless $self, $class; $self->{version} = '1.0'; - $options{options}->add_options(arguments => - { - "filter-name:s" => { name => 'filter_name' }, - "units:s" => { name => 'units', default => '%' }, - "free" => { name => 'free' }, - }); + $options{options}->add_options(arguments => { + "filter-name:s" => { name => 'filter_name' }, + "units:s" => { name => 'units', default => '%' }, + "free" => { name => 'free' }, + }); return $self; } -sub check_options { - my ($self, %options) = @_; - $self->SUPER::check_options(%options); - - $instance_mode = $self; -} - sub manage_selection { my ($self, %options) = @_; diff --git a/centreon-plugins/storage/netapp/restapi/mode/volumeusage.pm b/centreon-plugins/storage/netapp/restapi/mode/volumeusage.pm index 6ec718b1c..c878c2561 100644 --- a/centreon-plugins/storage/netapp/restapi/mode/volumeusage.pm +++ b/centreon-plugins/storage/netapp/restapi/mode/volumeusage.pm @@ -25,8 +25,6 @@ use base qw(centreon::plugins::templates::counter); use strict; use warnings; -my $instance_mode; - sub custom_usage_perfdata { my ($self, %options) = @_; @@ -46,10 +44,10 @@ sub custom_usage_threshold { my ($exit, $threshold_value); $threshold_value = $self->{result_values}->{used}; - $threshold_value = $self->{result_values}->{free} if (defined($instance_mode->{option_results}->{free})); - if ($instance_mode->{option_results}->{units} eq '%') { + $threshold_value = $self->{result_values}->{free} if (defined($self->{instance_mode}->{option_results}->{free})); + if ($self->{instance_mode}->{option_results}->{units} eq '%') { $threshold_value = $self->{result_values}->{prct_used}; - $threshold_value = $self->{result_values}->{prct_free} if (defined($instance_mode->{option_results}->{free})); + $threshold_value = $self->{result_values}->{prct_free} if (defined($self->{instance_mode}->{option_results}->{free})); } $exit = $self->{perfdata}->threshold_check(value => $threshold_value, threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, @@ -156,10 +154,10 @@ sub custom_snapshot_threshold { my ($exit, $threshold_value); $threshold_value = $self->{result_values}->{used}; - $threshold_value = $self->{result_values}->{free} if (defined($instance_mode->{option_results}->{free})); - if ($instance_mode->{option_results}->{units} eq '%') { + $threshold_value = $self->{result_values}->{free} if (defined($self->{instance_mode}->{option_results}->{free})); + if ($self->{instance_mode}->{option_results}->{units} eq '%') { $threshold_value = $self->{result_values}->{prct_used}; - $threshold_value = $self->{result_values}->{prct_free} if (defined($instance_mode->{option_results}->{free})); + $threshold_value = $self->{result_values}->{prct_free} if (defined($self->{instance_mode}->{option_results}->{free})); } $exit = $self->{perfdata}->threshold_check(value => $threshold_value, threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, @@ -215,10 +213,10 @@ sub custom_compression_threshold { my ($exit, $threshold_value); $threshold_value = $self->{result_values}->{used}; - $threshold_value = $self->{result_values}->{free} if (defined($instance_mode->{option_results}->{free})); - if ($instance_mode->{option_results}->{units} eq '%') { + $threshold_value = $self->{result_values}->{free} if (defined($self->{instance_mode}->{option_results}->{free})); + if ($self->{instance_mode}->{option_results}->{units} eq '%') { $threshold_value = $self->{result_values}->{prct_used}; - $threshold_value = $self->{result_values}->{prct_free} if (defined($instance_mode->{option_results}->{free})); + $threshold_value = $self->{result_values}->{prct_free} if (defined($self->{instance_mode}->{option_results}->{free})); } $exit = $self->{perfdata}->threshold_check(value => $threshold_value, threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, @@ -275,10 +273,10 @@ sub custom_deduplication_threshold { my ($exit, $threshold_value); $threshold_value = $self->{result_values}->{used}; - $threshold_value = $self->{result_values}->{free} if (defined($instance_mode->{option_results}->{free})); - if ($instance_mode->{option_results}->{units} eq '%') { + $threshold_value = $self->{result_values}->{free} if (defined($self->{instance_mode}->{option_results}->{free})); + if ($self->{instance_mode}->{option_results}->{units} eq '%') { $threshold_value = $self->{result_values}->{prct_used}; - $threshold_value = $self->{result_values}->{prct_free} if (defined($instance_mode->{option_results}->{free})); + $threshold_value = $self->{result_values}->{prct_free} if (defined($self->{instance_mode}->{option_results}->{free})); } $exit = $self->{perfdata}->threshold_check(value => $threshold_value, threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, @@ -379,26 +377,18 @@ sub new { bless $self, $class; $self->{version} = '1.0'; - $options{options}->add_options(arguments => - { - "filter-name:s" => { name => 'filter_name' }, - "filter-state:s" => { name => 'filter_state' }, - "filter-style:s" => { name => 'filter_style' }, - "filter-type:s" => { name => 'filter_type' }, - "units:s" => { name => 'units', default => '%' }, - "free" => { name => 'free' }, - }); + $options{options}->add_options(arguments => { + "filter-name:s" => { name => 'filter_name' }, + "filter-state:s" => { name => 'filter_state' }, + "filter-style:s" => { name => 'filter_style' }, + "filter-type:s" => { name => 'filter_type' }, + "units:s" => { name => 'units', default => '%' }, + "free" => { name => 'free' }, + }); return $self; } -sub check_options { - my ($self, %options) = @_; - $self->SUPER::check_options(%options); - - $instance_mode = $self; -} - sub manage_selection { my ($self, %options) = @_; diff --git a/centreon-plugins/storage/netapp/snmp/mode/filesys.pm b/centreon-plugins/storage/netapp/snmp/mode/filesys.pm index bb86a9bd5..9caba33d7 100644 --- a/centreon-plugins/storage/netapp/snmp/mode/filesys.pm +++ b/centreon-plugins/storage/netapp/snmp/mode/filesys.pm @@ -71,22 +71,20 @@ sub set_counters { ]; } -my $instance_mode; - sub custom_usage_perfdata { my ($self, %options) = @_; return if ($self->{result_values}->{total} <= 0); my $label = 'used'; my $value_perf = $self->{result_values}->{used}; - if (defined($instance_mode->{option_results}->{free})) { + if (defined($self->{instance_mode}->{option_results}->{free})) { $label = 'free'; $value_perf = $self->{result_values}->{free}; } my $extra_label = ''; $extra_label = '_' . $self->{result_values}->{display} if (!defined($options{extra_instance}) || $options{extra_instance} != 0); my %total_options = (); - if ($instance_mode->{option_results}->{units} eq '%') { + if ($self->{instance_mode}->{option_results}->{units} eq '%') { $total_options{total} = $self->{result_values}->{total}; $total_options{cast_int} = 1; } @@ -104,10 +102,10 @@ sub custom_usage_threshold { return 'ok' if ($self->{result_values}->{total} <= 0); my ($exit, $threshold_value); $threshold_value = $self->{result_values}->{used}; - $threshold_value = $self->{result_values}->{free} if (defined($instance_mode->{option_results}->{free})); - if ($instance_mode->{option_results}->{units} eq '%') { + $threshold_value = $self->{result_values}->{free} if (defined($self->{instance_mode}->{option_results}->{free})); + if ($self->{instance_mode}->{option_results}->{units} eq '%') { $threshold_value = $self->{result_values}->{prct_used}; - $threshold_value = $self->{result_values}->{prct_free} if (defined($instance_mode->{option_results}->{free})); + $threshold_value = $self->{result_values}->{prct_free} if (defined($self->{instance_mode}->{option_results}->{free})); } $exit = $self->{perfdata}->threshold_check(value => $threshold_value, threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, { label => 'warning-'. $self->{label}, exit_litteral => 'warning' } ]); return $exit; @@ -166,21 +164,14 @@ sub new { bless $self, $class; $self->{version} = '1.0'; - $options{options}->add_options(arguments => - { - "units:s" => { name => 'units', default => '%' }, - "free" => { name => 'free' }, - "filter-name:s" => { name => 'filter_name' }, - "filter-type:s" => { name => 'filter_type' }, - }); - return $self; -} + $options{options}->add_options(arguments => { + "units:s" => { name => 'units', default => '%' }, + "free" => { name => 'free' }, + "filter-name:s" => { name => 'filter_name' }, + "filter-type:s" => { name => 'filter_type' }, + }); -sub check_options { - my ($self, %options) = @_; - $self->SUPER::check_options(%options); - - $instance_mode = $self; + return $self; } my %map_types = ( diff --git a/centreon-plugins/storage/netapp/snmp/mode/qtreeusage.pm b/centreon-plugins/storage/netapp/snmp/mode/qtreeusage.pm index 2a170cfa2..6d3d7b238 100644 --- a/centreon-plugins/storage/netapp/snmp/mode/qtreeusage.pm +++ b/centreon-plugins/storage/netapp/snmp/mode/qtreeusage.pm @@ -25,8 +25,6 @@ use base qw(centreon::plugins::templates::counter); use strict; use warnings; -my $instance_mode; - sub set_counters { my ($self, %options) = @_; @@ -51,14 +49,14 @@ sub custom_usage_perfdata { my $label = 'used'; my $value_perf = $self->{result_values}->{used}; - if ($self->{result_values}->{total} > 0 && defined($instance_mode->{option_results}->{free})) { + if ($self->{result_values}->{total} > 0 && defined($self->{instance_mode}->{option_results}->{free})) { $label = 'free'; $value_perf = $self->{result_values}->{free}; } my $extra_label = ''; $extra_label = '_' . $self->{result_values}->{name} if (!defined($options{extra_instance}) || $options{extra_instance} != 0); my %total_options = (); - if ($self->{result_values}->{total} > 0 && $instance_mode->{option_results}->{units} eq '%') { + if ($self->{result_values}->{total} > 0 && $self->{instance_mode}->{option_results}->{units} eq '%') { $total_options{total} = $self->{result_values}->{total}; $total_options{cast_int} = 1; } @@ -74,13 +72,13 @@ sub custom_usage_threshold { my ($self, %options) = @_; # cannot use '%' or free option with unlimited system - return 'ok' if ($self->{result_values}->{total} <= 0 && ($instance_mode->{option_results}->{units} eq '%' || $instance_mode->{option_results}->{free})); + return 'ok' if ($self->{result_values}->{total} <= 0 && ($self->{instance_mode}->{option_results}->{units} eq '%' || $self->{instance_mode}->{option_results}->{free})); my ($exit, $threshold_value); $threshold_value = $self->{result_values}->{used}; - $threshold_value = $self->{result_values}->{free} if (defined($instance_mode->{option_results}->{free})); - if ($instance_mode->{option_results}->{units} eq '%') { + $threshold_value = $self->{result_values}->{free} if (defined($self->{instance_mode}->{option_results}->{free})); + if ($self->{instance_mode}->{option_results}->{units} eq '%') { $threshold_value = $self->{result_values}->{prct_used}; - $threshold_value = $self->{result_values}->{prct_free} if (defined($instance_mode->{option_results}->{free})); + $threshold_value = $self->{result_values}->{prct_free} if (defined($self->{instance_mode}->{option_results}->{free})); } $exit = $self->{perfdata}->threshold_check(value => $threshold_value, threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, { label => 'warning-'. $self->{label}, exit_litteral => 'warning' } ]); return $exit; @@ -136,26 +134,18 @@ sub new { bless $self, $class; $self->{version} = '1.0'; - $options{options}->add_options(arguments => - { - "units:s" => { name => 'units', default => '%' }, - "free" => { name => 'free' }, - "filter-vserver:s" => { name => 'filter_vserver' }, - "filter-volume:s" => { name => 'filter_volume' }, - "filter-qtree:s" => { name => 'filter_qtree' }, - "not-kbytes" => { name => 'not_kbytes' }, - }); + $options{options}->add_options(arguments => { + "units:s" => { name => 'units', default => '%' }, + "free" => { name => 'free' }, + "filter-vserver:s" => { name => 'filter_vserver' }, + "filter-volume:s" => { name => 'filter_volume' }, + "filter-qtree:s" => { name => 'filter_qtree' }, + "not-kbytes" => { name => 'not_kbytes' }, + }); return $self; } -sub check_options { - my ($self, %options) = @_; - $self->SUPER::check_options(%options); - - $instance_mode = $self; -} - my $mapping = { qrV2Tree => { oid => '.1.3.6.1.4.1.789.1.4.6.1.14' }, qrV264KBytesUsed => { oid => '.1.3.6.1.4.1.789.1.4.6.1.25' }, diff --git a/centreon-plugins/storage/oracle/zs/snmp/mode/shareusage.pm b/centreon-plugins/storage/oracle/zs/snmp/mode/shareusage.pm index 38c7adf47..62fcd4248 100644 --- a/centreon-plugins/storage/oracle/zs/snmp/mode/shareusage.pm +++ b/centreon-plugins/storage/oracle/zs/snmp/mode/shareusage.pm @@ -25,21 +25,19 @@ use base qw(centreon::plugins::templates::counter); use strict; use warnings; -my $instance_mode; - sub custom_usage_perfdata { my ($self, %options) = @_; my $label = $self->{result_values}->{label} . '_used'; my $value_perf = $self->{result_values}->{used}; - if (defined($instance_mode->{option_results}->{free})) { + if (defined($self->{instance_mode}->{option_results}->{free})) { $label = $self->{result_values}->{label} . '_free'; $value_perf = $self->{result_values}->{free}; } my $extra_label = ''; $extra_label = '_' . $self->{result_values}->{display} if (!defined($options{extra_instance}) || $options{extra_instance} != 0); my %total_options = (); - if ($instance_mode->{option_results}->{units} eq '%') { + if ($self->{instance_mode}->{option_results}->{units} eq '%') { $total_options{total} = $self->{result_values}->{total}; $total_options{cast_int} = 1; } @@ -56,10 +54,10 @@ sub custom_usage_threshold { my ($exit, $threshold_value); $threshold_value = $self->{result_values}->{used}; - $threshold_value = $self->{result_values}->{free} if (defined($instance_mode->{option_results}->{free})); - if ($instance_mode->{option_results}->{units} eq '%') { + $threshold_value = $self->{result_values}->{free} if (defined($self->{instance_mode}->{option_results}->{free})); + if ($self->{instance_mode}->{option_results}->{units} eq '%') { $threshold_value = $self->{result_values}->{prct_used}; - $threshold_value = $self->{result_values}->{prct_free} if (defined($instance_mode->{option_results}->{free})); + $threshold_value = $self->{result_values}->{prct_free} if (defined($self->{instance_mode}->{option_results}->{free})); } $exit = $self->{perfdata}->threshold_check(value => $threshold_value, threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, { label => 'warning-'. $self->{label}, exit_litteral => 'warning' } ]); return $exit; @@ -128,24 +126,16 @@ sub new { bless $self, $class; $self->{version} = '1.0'; - $options{options}->add_options(arguments => - { - "filter-name:s" => { name => 'filter_name' }, - "filter-project:s" => { name => 'filter_project' }, - "units:s" => { name => 'units', default => '%' }, - "free" => { name => 'free' }, - }); - + $options{options}->add_options(arguments => { + "filter-name:s" => { name => 'filter_name' }, + "filter-project:s" => { name => 'filter_project' }, + "units:s" => { name => 'units', default => '%' }, + "free" => { name => 'free' }, + }); + return $self; } -sub check_options { - my ($self, %options) = @_; - $self->SUPER::check_options(%options); - - $instance_mode = $self; -} - sub prefix_share_output { my ($self, %options) = @_; diff --git a/centreon-plugins/storage/purestorage/restapi/mode/volumeusage.pm b/centreon-plugins/storage/purestorage/restapi/mode/volumeusage.pm index 29ac22217..17566b219 100644 --- a/centreon-plugins/storage/purestorage/restapi/mode/volumeusage.pm +++ b/centreon-plugins/storage/purestorage/restapi/mode/volumeusage.pm @@ -25,21 +25,19 @@ use base qw(centreon::plugins::templates::counter); use strict; use warnings; -my $instance_mode; - sub custom_usage_perfdata { my ($self, %options) = @_; my $label = 'used'; my $value_perf = $self->{result_values}->{used}; - if (defined($instance_mode->{option_results}->{free})) { + if (defined($self->{instance_mode}->{option_results}->{free})) { $label = 'free'; $value_perf = $self->{result_values}->{free}; } my $extra_label = ''; $extra_label = '_' . $self->{result_values}->{display} if (!defined($options{extra_instance}) || $options{extra_instance} != 0); my %total_options = (); - if ($instance_mode->{option_results}->{units} eq '%') { + if ($self->{instance_mode}->{option_results}->{units} eq '%') { $total_options{total} = $self->{result_values}->{total}; $total_options{cast_int} = 1; } @@ -56,10 +54,10 @@ sub custom_usage_threshold { my ($exit, $threshold_value); $threshold_value = $self->{result_values}->{used}; - $threshold_value = $self->{result_values}->{free} if (defined($instance_mode->{option_results}->{free})); - if ($instance_mode->{option_results}->{units} eq '%') { + $threshold_value = $self->{result_values}->{free} if (defined($self->{instance_mode}->{option_results}->{free})); + if ($self->{instance_mode}->{option_results}->{units} eq '%') { $threshold_value = $self->{result_values}->{prct_used}; - $threshold_value = $self->{result_values}->{prct_free} if (defined($instance_mode->{option_results}->{free})); + $threshold_value = $self->{result_values}->{prct_free} if (defined($self->{instance_mode}->{option_results}->{free})); } $exit = $self->{perfdata}->threshold_check(value => $threshold_value, threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, { label => 'warning-'. $self->{label}, exit_litteral => 'warning' } ]); return $exit; @@ -144,23 +142,15 @@ sub new { bless $self, $class; $self->{version} = '1.0'; - $options{options}->add_options(arguments => - { - "filter-name:s" => { name => 'filter_name' }, - "units:s" => { name => 'units', default => '%' }, - "free" => { name => 'free' }, - }); - + $options{options}->add_options(arguments => { + "filter-name:s" => { name => 'filter_name' }, + "units:s" => { name => 'units', default => '%' }, + "free" => { name => 'free' }, + }); + return $self; } -sub check_options { - my ($self, %options) = @_; - $self->SUPER::check_options(%options); - - $instance_mode = $self; -} - sub prefix_volume_output { my ($self, %options) = @_; diff --git a/centreon-plugins/storage/quantum/dxi/ssh/mode/diskusage.pm b/centreon-plugins/storage/quantum/dxi/ssh/mode/diskusage.pm index 664d61816..6693b70c4 100644 --- a/centreon-plugins/storage/quantum/dxi/ssh/mode/diskusage.pm +++ b/centreon-plugins/storage/quantum/dxi/ssh/mode/diskusage.pm @@ -25,8 +25,6 @@ use base qw(centreon::plugins::templates::counter); use strict; use warnings; -my $instance_mode; - sub custom_usage_perfdata { my ($self, %options) = @_; @@ -43,10 +41,10 @@ sub custom_usage_threshold { my ($exit, $threshold_value); $threshold_value = $self->{result_values}->{used}; - $threshold_value = $self->{result_values}->{free} if (defined($instance_mode->{option_results}->{free})); - if ($instance_mode->{option_results}->{units} eq '%') { + $threshold_value = $self->{result_values}->{free} if (defined($self->{instance_mode}->{option_results}->{free})); + if ($self->{instance_mode}->{option_results}->{units} eq '%') { $threshold_value = $self->{result_values}->{prct_used}; - $threshold_value = $self->{result_values}->{prct_free} if (defined($instance_mode->{option_results}->{free})); + $threshold_value = $self->{result_values}->{prct_free} if (defined($self->{instance_mode}->{option_results}->{free})); } $exit = $self->{perfdata}->threshold_check(value => $threshold_value, threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, @@ -71,8 +69,8 @@ sub custom_usage_output { sub custom_usage_calc { my ($self, %options) = @_; - $self->{result_values}->{total} = $instance_mode->convert_to_bytes(raw_value => $options{new_datas}->{$self->{instance} . '_disk_capacity'}); - $self->{result_values}->{used} = $instance_mode->convert_to_bytes(raw_value => $options{new_datas}->{$self->{instance} . '_used_disk_space'}); + $self->{result_values}->{total} = $self->{instance_mode}->convert_to_bytes(raw_value => $options{new_datas}->{$self->{instance} . '_disk_capacity'}); + $self->{result_values}->{used} = $self->{instance_mode}->convert_to_bytes(raw_value => $options{new_datas}->{$self->{instance} . '_used_disk_space'}); if ($self->{result_values}->{total} != 0) { $self->{result_values}->{free} = $self->{result_values}->{total} - $self->{result_values}->{used}; @@ -116,8 +114,8 @@ sub custom_volume_output { sub custom_volume_calc { my ($self, %options) = @_; - $self->{result_values}->{volume} = $instance_mode->convert_to_bytes(raw_value => $options{new_datas}->{$self->{instance} . '_' . $options{extra_options}->{label_ref}}); - $self->{result_values}->{total} = $instance_mode->convert_to_bytes(raw_value => $options{new_datas}->{$self->{instance} . '_disk_capacity'}); + $self->{result_values}->{volume} = $self->{instance_mode}->convert_to_bytes(raw_value => $options{new_datas}->{$self->{instance} . '_' . $options{extra_options}->{label_ref}}); + $self->{result_values}->{total} = $self->{instance_mode}->convert_to_bytes(raw_value => $options{new_datas}->{$self->{instance} . '_disk_capacity'}); $self->{result_values}->{display} = $options{extra_options}->{display_ref}; $self->{result_values}->{label} = $options{extra_options}->{label_ref}; @@ -219,20 +217,19 @@ sub new { bless $self, $class; $self->{version} = '1.0'; - $options{options}->add_options(arguments => - { - "hostname:s" => { name => 'hostname' }, - "ssh-option:s@" => { name => 'ssh_option' }, - "ssh-path:s" => { name => 'ssh_path' }, - "ssh-command:s" => { name => 'ssh_command', default => 'ssh' }, - "timeout:s" => { name => 'timeout', default => 30 }, - "sudo" => { name => 'sudo' }, - "command:s" => { name => 'command', default => 'syscli' }, - "command-path:s" => { name => 'command_path' }, - "command-options:s" => { name => 'command_options', default => '--get diskusage' }, - "units:s" => { name => 'units', default => '%' }, - "free" => { name => 'free' }, - }); + $options{options}->add_options(arguments => { + "hostname:s" => { name => 'hostname' }, + "ssh-option:s@" => { name => 'ssh_option' }, + "ssh-path:s" => { name => 'ssh_path' }, + "ssh-command:s" => { name => 'ssh_command', default => 'ssh' }, + "timeout:s" => { name => 'timeout', default => 30 }, + "sudo" => { name => 'sudo' }, + "command:s" => { name => 'command', default => 'syscli' }, + "command-path:s" => { name => 'command_path' }, + "command-options:s" => { name => 'command_options', default => '--get diskusage' }, + "units:s" => { name => 'units', default => '%' }, + "free" => { name => 'free' }, + }); return $self; } @@ -243,9 +240,7 @@ sub check_options { if (defined($self->{option_results}->{hostname}) && $self->{option_results}->{hostname} ne '') { $self->{option_results}->{remote} = 1; - } - - $instance_mode = $self; + } } sub manage_selection { diff --git a/centreon-plugins/storage/quantum/dxi/ssh/mode/memory.pm b/centreon-plugins/storage/quantum/dxi/ssh/mode/memory.pm index 4b41ea623..e2108c692 100644 --- a/centreon-plugins/storage/quantum/dxi/ssh/mode/memory.pm +++ b/centreon-plugins/storage/quantum/dxi/ssh/mode/memory.pm @@ -25,8 +25,6 @@ use base qw(centreon::plugins::templates::counter); use strict; use warnings; -my $instance_mode; - sub custom_usage_perfdata { my ($self, %options) = @_; @@ -43,10 +41,10 @@ sub custom_usage_threshold { my ($exit, $threshold_value); $threshold_value = $self->{result_values}->{used}; - $threshold_value = $self->{result_values}->{free} if (defined($instance_mode->{option_results}->{free})); - if ($instance_mode->{option_results}->{units} eq '%') { + $threshold_value = $self->{result_values}->{free} if (defined($self->{instance_mode}->{option_results}->{free})); + if ($self->{instance_mode}->{option_results}->{units} eq '%') { $threshold_value = $self->{result_values}->{prct_used}; - $threshold_value = $self->{result_values}->{prct_free} if (defined($instance_mode->{option_results}->{free})); + $threshold_value = $self->{result_values}->{prct_free} if (defined($self->{instance_mode}->{option_results}->{free})); } $exit = $self->{perfdata}->threshold_check(value => $threshold_value, threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, @@ -71,8 +69,8 @@ sub custom_usage_output { sub custom_usage_calc { my ($self, %options) = @_; - $self->{result_values}->{total} = $instance_mode->convert_to_bytes(raw_value => $options{new_datas}->{$self->{instance} . '_total'}); - $self->{result_values}->{free} = $instance_mode->convert_to_bytes(raw_value => $options{new_datas}->{$self->{instance} . '_free'}); + $self->{result_values}->{total} = $self->{instance_mode}->convert_to_bytes(raw_value => $options{new_datas}->{$self->{instance} . '_total'}); + $self->{result_values}->{free} = $self->{instance_mode}->convert_to_bytes(raw_value => $options{new_datas}->{$self->{instance} . '_free'}); if ($self->{result_values}->{total} != 0) { $self->{result_values}->{used} = $self->{result_values}->{total} - $self->{result_values}->{free}; @@ -129,20 +127,19 @@ sub new { bless $self, $class; $self->{version} = '1.0'; - $options{options}->add_options(arguments => - { - "hostname:s" => { name => 'hostname' }, - "ssh-option:s@" => { name => 'ssh_option' }, - "ssh-path:s" => { name => 'ssh_path' }, - "ssh-command:s" => { name => 'ssh_command', default => 'ssh' }, - "timeout:s" => { name => 'timeout', default => 30 }, - "sudo" => { name => 'sudo' }, - "command:s" => { name => 'command', default => 'syscli' }, - "command-path:s" => { name => 'command_path' }, - "command-options:s" => { name => 'command_options', default => '--getstatus systemmemory' }, - "units:s" => { name => 'units', default => '%' }, - "free" => { name => 'free' }, - }); + $options{options}->add_options(arguments => { + "hostname:s" => { name => 'hostname' }, + "ssh-option:s@" => { name => 'ssh_option' }, + "ssh-path:s" => { name => 'ssh_path' }, + "ssh-command:s" => { name => 'ssh_command', default => 'ssh' }, + "timeout:s" => { name => 'timeout', default => 30 }, + "sudo" => { name => 'sudo' }, + "command:s" => { name => 'command', default => 'syscli' }, + "command-path:s" => { name => 'command_path' }, + "command-options:s" => { name => 'command_options', default => '--getstatus systemmemory' }, + "units:s" => { name => 'units', default => '%' }, + "free" => { name => 'free' }, + }); return $self; } @@ -153,9 +150,7 @@ sub check_options { if (defined($self->{option_results}->{hostname}) && $self->{option_results}->{hostname} ne '') { $self->{option_results}->{remote} = 1; - } - - $instance_mode = $self; + } } sub manage_selection { diff --git a/centreon-plugins/storage/quantum/dxi/ssh/mode/reduction.pm b/centreon-plugins/storage/quantum/dxi/ssh/mode/reduction.pm index f9308de93..aeb2ab7a8 100644 --- a/centreon-plugins/storage/quantum/dxi/ssh/mode/reduction.pm +++ b/centreon-plugins/storage/quantum/dxi/ssh/mode/reduction.pm @@ -25,8 +25,6 @@ use base qw(centreon::plugins::templates::counter); use strict; use warnings; -my $instance_mode; - sub custom_volume_perfdata { my ($self, %options) = @_; @@ -56,7 +54,7 @@ sub custom_volume_output { sub custom_volume_calc { my ($self, %options) = @_; - $self->{result_values}->{volume} = $instance_mode->convert_to_bytes(raw_value => $options{new_datas}->{$self->{instance} . '_' . $options{extra_options}->{label_ref}}); + $self->{result_values}->{volume} = $self->{instance_mode}->convert_to_bytes(raw_value => $options{new_datas}->{$self->{instance} . '_' . $options{extra_options}->{label_ref}}); $self->{result_values}->{display} = $options{extra_options}->{display_ref}; $self->{result_values}->{label} = $options{extra_options}->{label_ref}; @@ -196,18 +194,17 @@ sub new { bless $self, $class; $self->{version} = '1.0'; - $options{options}->add_options(arguments => - { - "hostname:s" => { name => 'hostname' }, - "ssh-option:s@" => { name => 'ssh_option' }, - "ssh-path:s" => { name => 'ssh_path' }, - "ssh-command:s" => { name => 'ssh_command', default => 'ssh' }, - "timeout:s" => { name => 'timeout', default => 30 }, - "sudo" => { name => 'sudo' }, - "command:s" => { name => 'command', default => 'syscli' }, - "command-path:s" => { name => 'command_path' }, - "command-options:s" => { name => 'command_options', default => '--get datareductionstat' }, - }); + $options{options}->add_options(arguments => { + "hostname:s" => { name => 'hostname' }, + "ssh-option:s@" => { name => 'ssh_option' }, + "ssh-path:s" => { name => 'ssh_path' }, + "ssh-command:s" => { name => 'ssh_command', default => 'ssh' }, + "timeout:s" => { name => 'timeout', default => 30 }, + "sudo" => { name => 'sudo' }, + "command:s" => { name => 'command', default => 'syscli' }, + "command-path:s" => { name => 'command_path' }, + "command-options:s" => { name => 'command_options', default => '--get datareductionstat' }, + }); return $self; } @@ -218,9 +215,7 @@ sub check_options { if (defined($self->{option_results}->{hostname}) && $self->{option_results}->{hostname} ne '') { $self->{option_results}->{remote} = 1; - } - - $instance_mode = $self; + } } sub manage_selection { diff --git a/centreon-plugins/storage/quantum/dxi/ssh/mode/throughput.pm b/centreon-plugins/storage/quantum/dxi/ssh/mode/throughput.pm index 220ffd571..50d96c596 100644 --- a/centreon-plugins/storage/quantum/dxi/ssh/mode/throughput.pm +++ b/centreon-plugins/storage/quantum/dxi/ssh/mode/throughput.pm @@ -25,8 +25,6 @@ use base qw(centreon::plugins::templates::counter); use strict; use warnings; -my $instance_mode; - sub custom_volume_perfdata { my ($self, %options) = @_; @@ -56,7 +54,7 @@ sub custom_volume_output { sub custom_volume_calc { my ($self, %options) = @_; - $self->{result_values}->{volume} = $instance_mode->convert_to_bytes(raw_value => $options{new_datas}->{$self->{instance} . '_' . $options{extra_options}->{label_ref}}); + $self->{result_values}->{volume} = $self->{instance_mode}->convert_to_bytes(raw_value => $options{new_datas}->{$self->{instance} . '_' . $options{extra_options}->{label_ref}}); $self->{result_values}->{display} = $options{extra_options}->{display_ref}; $self->{result_values}->{label} = $options{extra_options}->{label_ref}; @@ -115,18 +113,17 @@ sub new { bless $self, $class; $self->{version} = '1.0'; - $options{options}->add_options(arguments => - { - "hostname:s" => { name => 'hostname' }, - "ssh-option:s@" => { name => 'ssh_option' }, - "ssh-path:s" => { name => 'ssh_path' }, - "ssh-command:s" => { name => 'ssh_command', default => 'ssh' }, - "timeout:s" => { name => 'timeout', default => 30 }, - "sudo" => { name => 'sudo' }, - "command:s" => { name => 'command', default => 'syscli' }, - "command-path:s" => { name => 'command_path' }, - "command-options:s" => { name => 'command_options', default => '--get ingestrate' }, - }); + $options{options}->add_options(arguments => { + "hostname:s" => { name => 'hostname' }, + "ssh-option:s@" => { name => 'ssh_option' }, + "ssh-path:s" => { name => 'ssh_path' }, + "ssh-command:s" => { name => 'ssh_command', default => 'ssh' }, + "timeout:s" => { name => 'timeout', default => 30 }, + "sudo" => { name => 'sudo' }, + "command:s" => { name => 'command', default => 'syscli' }, + "command-path:s" => { name => 'command_path' }, + "command-options:s" => { name => 'command_options', default => '--get ingestrate' }, + }); return $self; } @@ -138,8 +135,6 @@ sub check_options { if (defined($self->{option_results}->{hostname}) && $self->{option_results}->{hostname} ne '') { $self->{option_results}->{remote} = 1; } - - $instance_mode = $self; } sub manage_selection {