diff --git a/apps/backup/netbackup/local/mode/tapeusage.pm b/apps/backup/netbackup/local/mode/tapeusage.pm index f2a40f600..fe881099d 100644 --- a/apps/backup/netbackup/local/mode/tapeusage.pm +++ b/apps/backup/netbackup/local/mode/tapeusage.pm @@ -26,20 +26,18 @@ use strict; use warnings; use centreon::plugins::misc; -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; } @@ -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; @@ -113,33 +111,25 @@ sub new { bless $self, $class; $self->{version} = '1.0'; - $options{options}->add_options(arguments => - { - "hostname:s" => { name => 'hostname' }, - "remote" => { name => 'remote' }, - "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 => 'vmquery' }, - "command-path:s" => { name => 'command_path' }, - "command-options:s" => { name => 'command_options', default => '-a -w' }, - "filter-scratch:s" => { name => 'filter_scratch', default => 'scratch' }, - "units:s" => { name => 'units', default => '%' }, - "free" => { name => 'free' }, - }); + $options{options}->add_options(arguments => { + "hostname:s" => { name => 'hostname' }, + "remote" => { name => 'remote' }, + "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 => 'vmquery' }, + "command-path:s" => { name => 'command_path' }, + "command-options:s" => { name => 'command_options', default => '-a -w' }, + "filter-scratch:s" => { name => 'filter_scratch', default => 'scratch' }, + "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/apps/inin/mediaserver/snmp/mode/diskusage.pm b/apps/inin/mediaserver/snmp/mode/diskusage.pm index b923b5152..645dd44e6 100644 --- a/apps/inin/mediaserver/snmp/mode/diskusage.pm +++ b/apps/inin/mediaserver/snmp/mode/diskusage.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) = @_; @@ -62,12 +60,12 @@ sub custom_usage_perfdata { my $label = 'used_' . $self->{result_values}->{display}; my $value_perf = $self->{result_values}->{used}; - if (defined($instance_mode->{option_results}->{free})) { + if (defined($self->{instance_mode}->{option_results}->{free})) { $label = 'free_' . $self->{result_values}->{display}; $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; } @@ -84,10 +82,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; @@ -127,21 +125,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/apps/redis/cli/mode/memory.pm b/apps/redis/cli/mode/memory.pm index eb434294e..5c7f2a472 100644 --- a/apps/redis/cli/mode/memory.pm +++ b/apps/redis/cli/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) = @_; @@ -42,10 +40,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->{result_values}->{label}, exit_litteral => 'critical' }, { label => 'warning-' . $self->{result_values}->{label}, exit_litteral => 'warning' } ]); return $exit; @@ -200,7 +198,6 @@ sub prefix_stats_output { return "Statistics: "; } - sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); @@ -208,22 +205,14 @@ sub new { $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 $metrics = { used_memory => { label => 'used', display => 'Used' }, used_memory_rss => { label => 'rss', display => 'Rss' }, diff --git a/apps/redis/restapi/mode/clusterstats.pm b/apps/redis/restapi/mode/clusterstats.pm index d5635534e..e1eb4be5c 100644 --- a/apps/redis/restapi/mode/clusterstats.pm +++ b/apps/redis/restapi/mode/clusterstats.pm @@ -26,8 +26,6 @@ use strict; use warnings; use Digest::MD5 qw(md5_hex); -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->{result_values}->{label}, exit_litteral => 'critical' }, { label => 'warning-' . $self->{result_values}->{label}, exit_litteral => 'warning' } ]); return $exit; @@ -224,26 +222,18 @@ sub new { bless $self, $class; $self->{version} = '1.0'; - $options{options}->add_options(arguments => - { - "units:s" => { name => 'units', default => '%' }, - "free" => { name => 'free' }, - }); - - return $self; -} + $options{options}->add_options(arguments => { + "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 { my ($self, %options) = @_; - my $result = $options{custom}->get(path => '/v1/cluster/stats/last?interval='.$options{custom}->get_interval()); + my $result = $options{custom}->get(path => '/v1/cluster/stats/last?interval=' . $options{custom}->get_interval()); my $result2 = $options{custom}->get(path => '/v1/cluster'); my $result3 = $options{custom}->get(path => '/v1/nodes'); diff --git a/apps/tomcat/jmx/mode/connectorusage.pm b/apps/tomcat/jmx/mode/connectorusage.pm index 086cee978..2068994af 100644 --- a/apps/tomcat/jmx/mode/connectorusage.pm +++ b/apps/tomcat/jmx/mode/connectorusage.pm @@ -26,8 +26,6 @@ use strict; use warnings; use Digest::MD5 qw(md5_hex); -my $instance_mode; - sub set_counters { my ($self, %options) = @_; @@ -91,14 +89,14 @@ sub custom_usage_perfdata { my ($self, %options) = @_; my $use_th = 1; - $use_th = 0 if ($instance_mode->{option_results}->{units} eq '%' && $self->{result_values}->{max} <= 0); + $use_th = 0 if ($self->{instance_mode}->{option_results}->{units} eq '%' && $self->{result_values}->{max} <= 0); my $extra_label = ''; $extra_label = '_' . $self->{result_values}->{display} if (!defined($options{extra_instance}) || $options{extra_instance} != 0); my $value_perf = $self->{result_values}->{used}; my %total_options = (); - if ($instance_mode->{option_results}->{units} eq '%' && $self->{result_values}->{max} > 0) { + if ($self->{instance_mode}->{option_results}->{units} eq '%' && $self->{result_values}->{max} > 0) { $total_options{total} = $self->{result_values}->{max}; $total_options{cast_int} = 1; } @@ -116,10 +114,10 @@ sub custom_usage_threshold { my ($self, %options) = @_; # Cannot use percent without total - return 'ok' if ($self->{result_values}->{max} <= 0 && $instance_mode->{option_results}->{units} eq '%'); + return 'ok' if ($self->{result_values}->{max} <= 0 && $self->{instance_mode}->{option_results}->{units} eq '%'); my ($exit, $threshold_value); $threshold_value = $self->{result_values}->{used}; - if ($instance_mode->{option_results}->{units} eq '%') { + if ($self->{instance_mode}->{option_results}->{units} eq '%') { $threshold_value = $self->{result_values}->{prct_used}; } $exit = $self->{perfdata}->threshold_check(value => $threshold_value, threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, { label => 'warning-'. $self->{label}, exit_litteral => 'warning' } ]); @@ -167,19 +165,12 @@ 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 => '%' }, - }); - return $self; -} + $options{options}->add_options(arguments => { + "filter-name:s" => { name => 'filter_name' }, + "units:s" => { name => 'units', default => '%' }, + }); -sub check_options { - my ($self, %options) = @_; - $self->SUPER::check_options(%options); - - $instance_mode = $self; + return $self; } sub manage_selection { diff --git a/apps/tomcat/jmx/mode/datasourceusage.pm b/apps/tomcat/jmx/mode/datasourceusage.pm index 12b62c9b2..515c0b845 100644 --- a/apps/tomcat/jmx/mode/datasourceusage.pm +++ b/apps/tomcat/jmx/mode/datasourceusage.pm @@ -26,8 +26,6 @@ use strict; use warnings; use Digest::MD5 qw(md5_hex); -my $instance_mode; - sub set_counters { my ($self, %options) = @_; @@ -61,14 +59,14 @@ sub custom_usage_perfdata { my ($self, %options) = @_; my $use_th = 1; - $use_th = 0 if ($instance_mode->{option_results}->{units} eq '%' && $self->{result_values}->{max} <= 0); + $use_th = 0 if ($self->{instance_mode}->{option_results}->{units} eq '%' && $self->{result_values}->{max} <= 0); my $extra_label = ''; $extra_label = '_' . $self->{result_values}->{display} if (!defined($options{extra_instance}) || $options{extra_instance} != 0); my $value_perf = $self->{result_values}->{used}; my %total_options = (); - if ($instance_mode->{option_results}->{units} eq '%' && $self->{result_values}->{max} > 0) { + if ($self->{instance_mode}->{option_results}->{units} eq '%' && $self->{result_values}->{max} > 0) { $total_options{total} = $self->{result_values}->{max}; $total_options{cast_int} = 1; } @@ -86,10 +84,10 @@ sub custom_usage_threshold { my ($self, %options) = @_; # Cannot use percent without total - return 'ok' if ($self->{result_values}->{max} <= 0 && $instance_mode->{option_results}->{units} eq '%'); + return 'ok' if ($self->{result_values}->{max} <= 0 && $self->{instance_mode}->{option_results}->{units} eq '%'); my ($exit, $threshold_value); $threshold_value = $self->{result_values}->{used}; - if ($instance_mode->{option_results}->{units} eq '%') { + if ($self->{instance_mode}->{option_results}->{units} eq '%') { $threshold_value = $self->{result_values}->{prct_used}; } $exit = $self->{perfdata}->threshold_check(value => $threshold_value, threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, { label => 'warning-'. $self->{label}, exit_litteral => 'warning' } ]); @@ -137,19 +135,12 @@ 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 => '%' }, - }); - return $self; -} - -sub check_options { - my ($self, %options) = @_; - $self->SUPER::check_options(%options); + $options{options}->add_options(arguments => { + "filter-name:s" => { name => 'filter_name' }, + "units:s" => { name => 'units', default => '%' }, + }); - $instance_mode = $self; + return $self; } sub manage_selection { diff --git a/apps/tomcat/jmx/mode/webappssessions.pm b/apps/tomcat/jmx/mode/webappssessions.pm index 27ee8f9f9..ee540650f 100644 --- a/apps/tomcat/jmx/mode/webappssessions.pm +++ b/apps/tomcat/jmx/mode/webappssessions.pm @@ -26,8 +26,6 @@ use strict; use warnings; use Digest::MD5 qw(md5_hex); -my $instance_mode; - sub set_counters { my ($self, %options) = @_; @@ -61,14 +59,14 @@ sub custom_usage_perfdata { my ($self, %options) = @_; my $use_th = 1; - $use_th = 0 if ($instance_mode->{option_results}->{units} eq '%' && $self->{result_values}->{max} <= 0); + $use_th = 0 if ($self->{instance_mode}->{option_results}->{units} eq '%' && $self->{result_values}->{max} <= 0); my $extra_label = ''; $extra_label = '_' . $self->{result_values}->{display} if (!defined($options{extra_instance}) || $options{extra_instance} != 0); my $value_perf = $self->{result_values}->{used}; my %total_options = (); - if ($instance_mode->{option_results}->{units} eq '%' && $self->{result_values}->{max} > 0) { + if ($self->{instance_mode}->{option_results}->{units} eq '%' && $self->{result_values}->{max} > 0) { $total_options{total} = $self->{result_values}->{max}; $total_options{cast_int} = 1; } @@ -86,10 +84,10 @@ sub custom_usage_threshold { my ($self, %options) = @_; # Cannot use percent without total - return 'ok' if ($self->{result_values}->{max} <= 0 && $instance_mode->{option_results}->{units} eq '%'); + return 'ok' if ($self->{result_values}->{max} <= 0 && $self->{instance_mode}->{option_results}->{units} eq '%'); my ($exit, $threshold_value); $threshold_value = $self->{result_values}->{used}; - if ($instance_mode->{option_results}->{units} eq '%') { + if ($self->{instance_mode}->{option_results}->{units} eq '%') { $threshold_value = $self->{result_values}->{prct_used}; } $exit = $self->{perfdata}->threshold_check(value => $threshold_value, threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, { label => 'warning-'. $self->{label}, exit_litteral => 'warning' } ]); @@ -136,19 +134,12 @@ 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 => '%' }, - }); - return $self; -} + $options{options}->add_options(arguments => { + "filter-name:s" => { name => 'filter_name' }, + "units:s" => { name => 'units', default => '%' }, + }); -sub check_options { - my ($self, %options) = @_; - $self->SUPER::check_options(%options); - - $instance_mode = $self; + return $self; } sub manage_selection { diff --git a/apps/tomcat/web/mode/traffic.pm b/apps/tomcat/web/mode/traffic.pm index 8841fef4d..b64b78e95 100644 --- a/apps/tomcat/web/mode/traffic.pm +++ b/apps/tomcat/web/mode/traffic.pm @@ -29,8 +29,6 @@ use Digest::MD5 qw(md5_hex); use XML::XPath; use URI::Escape; -my $instance_mode; - sub set_counters { my ($self, %options) = @_; @@ -69,10 +67,10 @@ sub custom_traffic_perfdata { } my ($warning, $critical); - if ($instance_mode->{option_results}->{units_traffic} eq '%' && defined($self->{result_values}->{speed})) { + if ($self->{instance_mode}->{option_results}->{units_traffic} eq '%' && defined($self->{result_values}->{speed})) { $warning = $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{label}, total => $self->{result_values}->{speed}, cast_int => 1); $critical = $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{label}, total => $self->{result_values}->{speed}, cast_int => 1); - } elsif ($instance_mode->{option_results}->{units_traffic} eq 'b/s') { + } elsif ($self->{instance_mode}->{option_results}->{units_traffic} eq 'b/s') { $warning = $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{label}); $critical = $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{label}); } @@ -88,9 +86,9 @@ sub custom_traffic_threshold { my ($self, %options) = @_; my $exit = 'ok'; - if ($instance_mode->{option_results}->{units_traffic} eq '%' && defined($self->{result_values}->{speed})) { + if ($self->{instance_mode}->{option_results}->{units_traffic} eq '%' && defined($self->{result_values}->{speed})) { $exit = $self->{perfdata}->threshold_check(value => $self->{result_values}->{traffic_prct}, threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, { label => 'warning-' . $self->{label}, exit_litteral => 'warning' } ]); - } elsif ($instance_mode->{option_results}->{units_traffic} eq 'b/s') { + } elsif ($self->{instance_mode}->{option_results}->{units_traffic} eq 'b/s') { $exit = $self->{perfdata}->threshold_check(value => $self->{result_values}->{traffic}, threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, { label => 'warning-' . $self->{label}, exit_litteral => 'warning' } ]); } return $exit; @@ -119,9 +117,9 @@ sub custom_traffic_calc { $self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'}; my $diff_traffic = $options{new_datas}->{$self->{instance} . '_' . $self->{result_values}->{label}} - $options{old_datas}->{$self->{instance} . '_' . $self->{result_values}->{label}}; $self->{result_values}->{traffic} = $diff_traffic / $options{delta_time}; - if (defined($instance_mode->{option_results}->{'speed_' . $self->{result_values}->{label}}) && $instance_mode->{option_results}->{'speed_' . $self->{result_values}->{label}} =~ /[0-9]/) { - $self->{result_values}->{traffic_prct} = $self->{result_values}->{traffic} * 100 / ($instance_mode->{option_results}->{'speed_' . $self->{result_values}->{label}} * 1000 * 1000); - $self->{result_values}->{speed} = $instance_mode->{option_results}->{'speed_' . $self->{result_values}->{label}} * 1000 * 1000; + if (defined($self->{instance_mode}->{option_results}->{'speed_' . $self->{result_values}->{label}}) && $self->{instance_mode}->{option_results}->{'speed_' . $self->{result_values}->{label}} =~ /[0-9]/) { + $self->{result_values}->{traffic_prct} = $self->{result_values}->{traffic} * 100 / ($self->{instance_mode}->{option_results}->{'speed_' . $self->{result_values}->{label}} * 1000 * 1000); + $self->{result_values}->{speed} = $self->{instance_mode}->{option_results}->{'speed_' . $self->{result_values}->{label}} * 1000 * 1000; } return 0; } @@ -168,7 +166,6 @@ sub check_options { } $self->{http}->set_options(%{$self->{option_results}}); - $instance_mode = $self; } my %xpath_to_check = ( diff --git a/centreon/common/cisco/standard/snmp/mode/ipsectunnel.pm b/centreon/common/cisco/standard/snmp/mode/ipsectunnel.pm index 97f76ebbe..e6ca92194 100644 --- a/centreon/common/cisco/standard/snmp/mode/ipsectunnel.pm +++ b/centreon/common/cisco/standard/snmp/mode/ipsectunnel.pm @@ -27,8 +27,6 @@ use warnings; use Digest::MD5 qw(md5_hex); use Socket; -my $instance_mode; - sub set_counters { my ($self, %options) = @_; @@ -229,12 +227,11 @@ sub new { bless $self, $class; $self->{version} = '1.0'; - $options{options}->add_options(arguments => - { - "filter-name:s" => { name => 'filter_name' }, - "filter-sa:s" => { name => 'filter_sa' }, - }); - + $options{options}->add_options(arguments => { + "filter-name:s" => { name => 'filter_name' }, + "filter-sa:s" => { name => 'filter_sa' }, + }); + return $self; } diff --git a/centreon/common/cisco/standard/snmp/mode/qosusage.pm b/centreon/common/cisco/standard/snmp/mode/qosusage.pm index fdc026d2f..599c5dd9d 100644 --- a/centreon/common/cisco/standard/snmp/mode/qosusage.pm +++ b/centreon/common/cisco/standard/snmp/mode/qosusage.pm @@ -26,8 +26,6 @@ use strict; use warnings; use Digest::MD5 qw(md5_hex); -my $instance_mode; - sub set_counters { my ($self, %options) = @_; @@ -113,10 +111,10 @@ sub custom_traffic_perfdata { } my ($warning, $critical); - if ($instance_mode->{option_results}->{units_traffic} eq '%' && defined($self->{result_values}->{total})) { + if ($self->{instance_mode}->{option_results}->{units_traffic} eq '%' && defined($self->{result_values}->{total})) { $warning = $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{label}, total => $self->{result_values}->{total}, cast_int => 1); $critical = $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{label}, total => $self->{result_values}->{total}, cast_int => 1); - } elsif ($instance_mode->{option_results}->{units_traffic} eq 'b/s') { + } elsif ($self->{instance_mode}->{option_results}->{units_traffic} eq 'b/s') { $warning = $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{label}); $critical = $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{label}); } @@ -132,9 +130,9 @@ sub custom_traffic_threshold { my ($self, %options) = @_; my $exit = 'ok'; - if ($instance_mode->{option_results}->{units_traffic} eq '%' && defined($self->{result_values}->{total})) { + if ($self->{instance_mode}->{option_results}->{units_traffic} eq '%' && defined($self->{result_values}->{total})) { $exit = $self->{perfdata}->threshold_check(value => $self->{result_values}->{traffic_prct}, threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, { label => 'warning-' . $self->{label}, exit_litteral => 'warning' } ]); - } elsif ($instance_mode->{option_results}->{units_traffic} eq 'b/s') { + } elsif ($self->{instance_mode}->{option_results}->{units_traffic} eq 'b/s') { $exit = $self->{perfdata}->threshold_check(value => $self->{result_values}->{traffic_per_seconds}, threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, { label => 'warning-' . $self->{label}, exit_litteral => 'warning' } ]); } return $exit; @@ -184,14 +182,13 @@ sub new { bless $self, $class; $self->{version} = '1.0'; - $options{options}->add_options(arguments => - { - "filter-source:s" => { name => 'filter_source' }, - "oid-filter:s" => { name => 'oid_filter', default => 'ifname' }, - "oid-display:s" => { name => 'oid_display', default => 'ifname' }, - "units-traffic:s" => { name => 'units_traffic', default => '%' }, - }); - + $options{options}->add_options(arguments => { + "filter-source:s" => { name => 'filter_source' }, + "oid-filter:s" => { name => 'oid_filter', default => 'ifname' }, + "oid-display:s" => { name => 'oid_display', default => 'ifname' }, + "units-traffic:s" => { name => 'units_traffic', default => '%' }, + }); + return $self; } @@ -205,7 +202,6 @@ sub check_options { 'ifname' => '.1.3.6.1.2.1.31.1.1.1.1', }; $self->check_oids_label(); - $instance_mode = $self; } sub check_oids_label { diff --git a/centreon/common/emc/navisphere/mode/disk.pm b/centreon/common/emc/navisphere/mode/disk.pm index ac0530ba7..074a448c8 100644 --- a/centreon/common/emc/navisphere/mode/disk.pm +++ b/centreon/common/emc/navisphere/mode/disk.pm @@ -27,8 +27,6 @@ use warnings; use centreon::plugins::misc; use Digest::MD5 qw(md5_hex); -my $instance_mode; - my @states = ( ['^enabled$' , 'OK'], ['^binding$' , 'OK'], @@ -170,22 +168,14 @@ sub new { bless $self, $class; $self->{version} = '1.0'; - $options{options}->add_options(arguments => - { - "filter-raidgroupid:s" => { name => 'filter_raidgroupid', }, - "filter-disk:s" => { name => 'filter_disk', }, - }); + $options{options}->add_options(arguments => { + "filter-raidgroupid:s" => { name => 'filter_raidgroupid', }, + "filter-disk:s" => { name => 'filter_disk', }, + }); 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/common/jvm/mode/memory.pm b/centreon/common/jvm/mode/memory.pm index f2343a518..5b5591cce 100644 --- a/centreon/common/jvm/mode/memory.pm +++ b/centreon/common/jvm/mode/memory.pm @@ -55,17 +55,15 @@ sub set_counters { ]; } -my $instance_mode; - sub custom_usage_perfdata { my ($self, %options) = @_; my $use_th = 1; - $use_th = 0 if ($instance_mode->{option_results}->{units} eq '%' && $self->{result_values}->{max} <= 0); + $use_th = 0 if ($self->{instance_mode}->{option_results}->{units} eq '%' && $self->{result_values}->{max} <= 0); my $value_perf = $self->{result_values}->{used}; my %total_options = (); - if ($instance_mode->{option_results}->{units} eq '%' && $self->{result_values}->{max} > 0) { + if ($self->{instance_mode}->{option_results}->{units} eq '%' && $self->{result_values}->{max} > 0) { $total_options{total} = $self->{result_values}->{max}; $total_options{cast_int} = 1; } @@ -81,10 +79,10 @@ sub custom_usage_threshold { my ($self, %options) = @_; # Cannot use percent without total - return 'ok' if ($self->{result_values}->{max} <= 0 && $instance_mode->{option_results}->{units} eq '%'); + return 'ok' if ($self->{result_values}->{max} <= 0 && $self->{instance_mode}->{option_results}->{units} eq '%'); my ($exit, $threshold_value); $threshold_value = $self->{result_values}->{used}; - if ($instance_mode->{option_results}->{units} eq '%') { + if ($self->{instance_mode}->{option_results}->{units} eq '%') { $threshold_value = $self->{result_values}->{prct_used}; } $exit = $self->{perfdata}->threshold_check(value => $threshold_value, threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, { label => 'warning-'. $self->{label}, exit_litteral => 'warning' } ]); @@ -130,18 +128,11 @@ sub new { bless $self, $class; $self->{version} = '1.0'; - $options{options}->add_options(arguments => - { - "units:s" => { name => 'units', default => '%' }, - }); - return $self; -} + $options{options}->add_options(arguments => { + "units:s" => { name => 'units', default => '%' }, + }); -sub check_options { - my ($self, %options) = @_; - $self->SUPER::check_options(%options); - - $instance_mode = $self; + return $self; } sub manage_selection { diff --git a/centreon/common/jvm/mode/memorydetailed.pm b/centreon/common/jvm/mode/memorydetailed.pm index 3581ce832..a97977c25 100644 --- a/centreon/common/jvm/mode/memorydetailed.pm +++ b/centreon/common/jvm/mode/memorydetailed.pm @@ -44,8 +44,6 @@ my %mapping_memory = ( 'Tenured Gen' => 'tenured', ); -my $instance_mode; - sub set_counters { my ($self, %options) = @_; @@ -101,11 +99,11 @@ sub custom_usage_perfdata { my ($self, %options) = @_; my $use_th = 1; - $use_th = 0 if ($instance_mode->{option_results}->{units} eq '%' && $self->{result_values}->{max} <= 0); + $use_th = 0 if ($self->{instance_mode}->{option_results}->{units} eq '%' && $self->{result_values}->{max} <= 0); my $value_perf = $self->{result_values}->{used}; my %total_options = (); - if ($instance_mode->{option_results}->{units} eq '%' && $self->{result_values}->{max} > 0) { + if ($self->{instance_mode}->{option_results}->{units} eq '%' && $self->{result_values}->{max} > 0) { $total_options{total} = $self->{result_values}->{max}; $total_options{cast_int} = 1; } @@ -121,10 +119,10 @@ sub custom_usage_threshold { my ($self, %options) = @_; # Cannot use percent without total - return 'ok' if ($self->{result_values}->{max} <= 0 && $instance_mode->{option_results}->{units} eq '%'); + return 'ok' if ($self->{result_values}->{max} <= 0 && $self->{instance_mode}->{option_results}->{units} eq '%'); my ($exit, $threshold_value); $threshold_value = $self->{result_values}->{used}; - if ($instance_mode->{option_results}->{units} eq '%') { + if ($self->{instance_mode}->{option_results}->{units} eq '%') { $threshold_value = $self->{result_values}->{prct_used}; } $exit = $self->{perfdata}->threshold_check(value => $threshold_value, threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, { label => 'warning-'. $self->{label}, exit_litteral => 'warning' } ]); @@ -177,18 +175,11 @@ sub new { bless $self, $class; $self->{version} = '1.0'; - $options{options}->add_options(arguments => - { - "units:s" => { name => 'units', default => '%' }, - }); - return $self; -} + $options{options}->add_options(arguments => { + "units:s" => { name => 'units', default => '%' }, + }); -sub check_options { - my ($self, %options) = @_; - $self->SUPER::check_options(%options); - - $instance_mode = $self; + return $self; } sub manage_selection { diff --git a/cloud/cadvisor/restapi/mode/containerusage.pm b/cloud/cadvisor/restapi/mode/containerusage.pm index 8882cc8d2..b6dd83bbe 100644 --- a/cloud/cadvisor/restapi/mode/containerusage.pm +++ b/cloud/cadvisor/restapi/mode/containerusage.pm @@ -27,8 +27,6 @@ use warnings; use Digest::MD5 qw(md5_hex); use DateTime; -my $instance_mode; - sub custom_memory_output { my ($self, %options) = @_; my ($total_size_value, $total_size_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{memory_total_absolute}); @@ -136,15 +134,14 @@ sub new { bless $self, $class; $self->{version} = '1.0'; - $options{options}->add_options(arguments => - { - "container-id:s" => { name => 'container_id' }, - "container-name:s" => { name => 'container_name' }, - "filter-name:s" => { name => 'filter_name' }, - "use-name" => { name => 'use_name' }, - "warning-container-status:s" => { name => 'warning_container_status', default => '' }, - "critical-container-status:s" => { name => 'critical_container_status', default => '' }, - }); + $options{options}->add_options(arguments => { + "container-id:s" => { name => 'container_id' }, + "container-name:s" => { name => 'container_name' }, + "filter-name:s" => { name => 'filter_name' }, + "use-name" => { name => 'use_name' }, + "warning-container-status:s" => { name => 'warning_container_status', default => '' }, + "critical-container-status:s" => { name => 'critical_container_status', default => '' }, + }); return $self; } @@ -153,8 +150,7 @@ sub check_options { my ($self, %options) = @_; $self->SUPER::check_options(%options); - $instance_mode = $self; - $self->change_macros(); + $self->change_macros(macros => ['warning_container_status', 'critical_container_status']); } sub prefix_containers_output { @@ -162,16 +158,6 @@ sub prefix_containers_output { return "Container '" . $options{instance_value}->{display} . "' "; } -sub change_macros { - my ($self, %options) = @_; - - foreach (('warning_container_status', 'critical_container_status')) { - if (defined($self->{option_results}->{$_})) { - $self->{option_results}->{$_} =~ s/%\{(.*?)\}/\$self->{result_values}->{$1}/g; - } - } -} - sub manage_selection { my ($self, %options) = @_; diff --git a/cloud/cadvisor/restapi/mode/traffic.pm b/cloud/cadvisor/restapi/mode/traffic.pm index f05b3c9c4..3682cfd35 100644 --- a/cloud/cadvisor/restapi/mode/traffic.pm +++ b/cloud/cadvisor/restapi/mode/traffic.pm @@ -27,8 +27,6 @@ use warnings; use Digest::MD5 qw(md5_hex); use DateTime; -my $instance_mode; - sub set_counters { my ($self, %options) = @_; @@ -66,13 +64,12 @@ sub new { bless $self, $class; $self->{version} = '1.0'; - $options{options}->add_options(arguments => - { - "container-id:s" => { name => 'container_id' }, - "container-name:s" => { name => 'container_name' }, - "filter-name:s" => { name => 'filter_name' }, - "use-name" => { name => 'use_name' }, - }); + $options{options}->add_options(arguments => { + "container-id:s" => { name => 'container_id' }, + "container-name:s" => { name => 'container_name' }, + "filter-name:s" => { name => 'filter_name' }, + "use-name" => { name => 'use_name' }, + }); return $self; } diff --git a/cloud/nutanix/snmp/mode/containerusage.pm b/cloud/nutanix/snmp/mode/containerusage.pm index a1dff4208..891819d53 100644 --- a/cloud/nutanix/snmp/mode/containerusage.pm +++ b/cloud/nutanix/snmp/mode/containerusage.pm @@ -26,21 +26,19 @@ use strict; use warnings; use centreon::plugins::misc; -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; } @@ -57,10 +55,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; @@ -135,23 +133,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_container_output { my ($self, %options) = @_; diff --git a/cloud/nutanix/snmp/mode/hypervisorusage.pm b/cloud/nutanix/snmp/mode/hypervisorusage.pm index 48c4d3f5a..6098d99cd 100644 --- a/cloud/nutanix/snmp/mode/hypervisorusage.pm +++ b/cloud/nutanix/snmp/mode/hypervisorusage.pm @@ -26,8 +26,6 @@ use strict; use warnings; use centreon::plugins::misc; -my $instance_mode; - sub custom_usage_perfdata { my ($self, %options) = @_; @@ -140,21 +138,13 @@ sub new { bless $self, $class; $self->{version} = '1.0'; - $options{options}->add_options(arguments => - { - "filter-name:s" => { name => 'filter_name' }, - }); - + $options{options}->add_options(arguments => { + "filter-name:s" => { name => 'filter_name' }, + }); + return $self; } -sub check_options { - my ($self, %options) = @_; - $self->SUPER::check_options(%options); - - $instance_mode = $self; -} - sub prefix_hypervisor_output { my ($self, %options) = @_; diff --git a/cloud/nutanix/snmp/mode/storagepoolusage.pm b/cloud/nutanix/snmp/mode/storagepoolusage.pm index 0ae95ff76..67fd531d1 100644 --- a/cloud/nutanix/snmp/mode/storagepoolusage.pm +++ b/cloud/nutanix/snmp/mode/storagepoolusage.pm @@ -26,21 +26,19 @@ use strict; use warnings; use centreon::plugins::misc; -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; } @@ -57,10 +55,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; @@ -135,23 +133,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_sp_output { my ($self, %options) = @_; diff --git a/cloud/nutanix/snmp/mode/vmusage.pm b/cloud/nutanix/snmp/mode/vmusage.pm index 10216e024..76ca43f3b 100644 --- a/cloud/nutanix/snmp/mode/vmusage.pm +++ b/cloud/nutanix/snmp/mode/vmusage.pm @@ -27,8 +27,6 @@ use warnings; use centreon::plugins::misc; use Digest::MD5 qw(md5_hex); -my $instance_mode; - sub set_counters { my ($self, %options) = @_; @@ -102,21 +100,13 @@ sub new { bless $self, $class; $self->{version} = '1.0'; - $options{options}->add_options(arguments => - { - "filter-name:s" => { name => 'filter_name' }, - }); + $options{options}->add_options(arguments => { + "filter-name:s" => { name => 'filter_name' }, + }); return $self; } -sub check_options { - my ($self, %options) = @_; - $self->SUPER::check_options(%options); - - $instance_mode = $self; -} - sub prefix_vm_output { my ($self, %options) = @_; diff --git a/database/mssql/mode/databasessize.pm b/database/mssql/mode/databasessize.pm index f2250b17b..dcf860456 100644 --- a/database/mssql/mode/databasessize.pm +++ b/database/mssql/mode/databasessize.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 (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 = '_' . lc($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; } @@ -75,10 +73,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' }, @@ -118,12 +116,12 @@ sub new { bless $self, $class; $self->{version} = '1.0'; - $options{options}->add_options(arguments => - { - "filter-database:s" => { name => 'filter_database' }, - "units:s" => { name => 'units', default => '%' }, - "free" => { name => 'free' }, - }); + $options{options}->add_options(arguments => { + "filter-database:s" => { name => 'filter_database' }, + "units:s" => { name => 'units', default => '%' }, + "free" => { name => 'free' }, + }); + return $self; } @@ -133,13 +131,6 @@ sub prefix_database_output { return "Database '" . $options{instance_value}->{display} . "' "; } -sub check_options { - my ($self, %options) = @_; - $self->SUPER::check_options(%options); - - $instance_mode = $self; -} - sub manage_selection { my ($self, %options) = @_; diff --git a/database/mssql/mode/logssize.pm b/database/mssql/mode/logssize.pm index 458fe8ae5..74bd21466 100644 --- a/database/mssql/mode/logssize.pm +++ b/database/mssql/mode/logssize.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,12 +49,12 @@ sub custom_usage_perfdata { my $label = 'log_' . lc($self->{result_values}->{display}) . '_used'; my $value_perf = $self->{result_values}->{used}; - if (defined($instance_mode->{option_results}->{free})) { + if (defined($self->{instance_mode}->{option_results}->{free})) { $label = 'log_' . lc($self->{result_values}->{display}) . '_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; } @@ -73,10 +71,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' }, @@ -116,12 +114,12 @@ sub new { bless $self, $class; $self->{version} = '1.0'; - $options{options}->add_options(arguments => - { - "filter-log:s" => { name => 'filter_log' }, - "units:s" => { name => 'units', default => '%' }, - "free" => { name => 'free' }, - }); + $options{options}->add_options(arguments => { + "filter-log:s" => { name => 'filter_log' }, + "units:s" => { name => 'units', default => '%' }, + "free" => { name => 'free' }, + }); + return $self; } @@ -131,13 +129,6 @@ sub prefix_log_output { return "Log '" . $options{instance_value}->{display} . "' "; } -sub check_options { - my ($self, %options) = @_; - $self->SUPER::check_options(%options); - - $instance_mode = $self; -} - sub manage_selection { my ($self, %options) = @_; diff --git a/database/oracle/mode/tablespaceusage.pm b/database/oracle/mode/tablespaceusage.pm index e4985ec84..bcbb79b1e 100644 --- a/database/oracle/mode/tablespaceusage.pm +++ b/database/oracle/mode/tablespaceusage.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 = 'tbs_' . $self->{result_values}->{display} . '_usage'; my $value_perf = $self->{result_values}->{used}; - if (defined($instance_mode->{option_results}->{free})) { + if (defined($self->{instance_mode}->{option_results}->{free})) { $label = 'tbs_' . $self->{result_values}->{display} . '_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; } @@ -75,10 +73,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,13 +115,13 @@ sub new { bless $self, $class; $self->{version} = '1.0'; - $options{options}->add_options(arguments => - { - "filter-tablespace:s" => { name => 'filter_tablespace' }, - "units:s" => { name => 'units', default => '%' }, - "free" => { name => 'free' }, - "skip" => { name => 'skip' }, - }); + $options{options}->add_options(arguments => { + "filter-tablespace:s" => { name => 'filter_tablespace' }, + "units:s" => { name => 'units', default => '%' }, + "free" => { name => 'free' }, + "skip" => { name => 'skip' }, + }); + return $self; } @@ -133,13 +131,6 @@ sub prefix_tablespace_output { return "Tablespace '" . $options{instance_value}->{display} . "' "; } -sub check_options { - my ($self, %options) = @_; - $self->SUPER::check_options(%options); - - $instance_mode = $self; -} - sub manage_selection { my ($self, %options) = @_; # $options{sql} = sqlmode object diff --git a/database/oracle/mode/temptablespace.pm b/database/oracle/mode/temptablespace.pm index a755b7808..2f85ec104 100644 --- a/database/oracle/mode/temptablespace.pm +++ b/database/oracle/mode/temptablespace.pm @@ -26,20 +26,18 @@ use strict; use warnings; use Digest::MD5 qw(md5_hex); -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; } @@ -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; @@ -114,26 +112,18 @@ sub prefix_tablespace_output { sub new { my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 0); + my $self = $class->SUPER::new(package => __PACKAGE__, %options); 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) = @_; $self->{sql} = $options{sql}; diff --git a/database/oracle/mode/undotablespace.pm b/database/oracle/mode/undotablespace.pm index dde50d160..8c543d096 100644 --- a/database/oracle/mode/undotablespace.pm +++ b/database/oracle/mode/undotablespace.pm @@ -26,20 +26,18 @@ use strict; use warnings; use Digest::MD5 qw(md5_hex); -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; } @@ -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; @@ -114,26 +112,18 @@ sub prefix_tablespace_output { sub new { my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 0); + my $self = $class->SUPER::new(package => __PACKAGE__, %options); 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) = @_; $self->{sql} = $options{sql}; diff --git a/database/sap/hana/mode/diskusage.pm b/database/sap/hana/mode/diskusage.pm index 62b21f1d7..e8c039815 100644 --- a/database/sap/hana/mode/diskusage.pm +++ b/database/sap/hana/mode/diskusage.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_' . $self->{result_values}->{display}; my $value_perf = $self->{result_values}->{used}; - if (defined($instance_mode->{option_results}->{free})) { + if (defined($self->{instance_mode}->{option_results}->{free})) { $label = 'free_' . $self->{result_values}->{display}; $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; } @@ -75,10 +73,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,12 +115,12 @@ 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; } @@ -132,13 +130,6 @@ sub prefix_disk_output { return "Disk '" . $options{instance_value}->{display} . "' "; } -sub check_options { - my ($self, %options) = @_; - $self->SUPER::check_options(%options); - - $instance_mode = $self; -} - sub manage_selection { my ($self, %options) = @_; $options{sql}->connect(); diff --git a/database/sap/hana/mode/volumeusage.pm b/database/sap/hana/mode/volumeusage.pm index 8e9e2f1ce..446e76afc 100644 --- a/database/sap/hana/mode/volumeusage.pm +++ b/database/sap/hana/mode/volumeusage.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_' . $self->{result_values}->{display}; my $value_perf = $self->{result_values}->{used}; - if (defined($instance_mode->{option_results}->{free})) { + if (defined($self->{instance_mode}->{option_results}->{free})) { $label = 'free_' . $self->{result_values}->{display}; $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; } @@ -75,10 +73,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,12 +115,12 @@ 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; } @@ -132,13 +130,6 @@ sub prefix_volume_output { return "Volume '" . $options{instance_value}->{display} . "' "; } -sub check_options { - my ($self, %options) = @_; - $self->SUPER::check_options(%options); - - $instance_mode = $self; -} - sub manage_selection { my ($self, %options) = @_; $options{sql}->connect(); diff --git a/database/sybase/mode/databasessize.pm b/database/sybase/mode/databasessize.pm index fa2bfb43d..83a8a243c 100644 --- a/database/sybase/mode/databasessize.pm +++ b/database/sybase/mode/databasessize.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) = @_; @@ -59,14 +57,14 @@ sub custom_usage_perfdata { 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; } @@ -83,10 +81,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; @@ -127,12 +125,12 @@ sub new { bless $self, $class; $self->{version} = '1.0'; - $options{options}->add_options(arguments => - { - "filter-database:s" => { name => 'filter_database' }, - "units:s" => { name => 'units', default => '%' }, - "free" => { name => 'free' }, - }); + $options{options}->add_options(arguments => { + "filter-database:s" => { name => 'filter_database' }, + "units:s" => { name => 'units', default => '%' }, + "free" => { name => 'free' }, + }); + return $self; } @@ -142,13 +140,6 @@ sub prefix_database_output { return "Database '" . $options{instance_value}->{display} . "' "; } -sub check_options { - my ($self, %options) = @_; - $self->SUPER::check_options(%options); - - $instance_mode = $self; -} - sub manage_selection { my ($self, %options) = @_; diff --git a/hardware/sensors/comet/p8000/snmp/mode/sensors.pm b/hardware/sensors/comet/p8000/snmp/mode/sensors.pm index 7b107b0cf..9035bc1f0 100644 --- a/hardware/sensors/comet/p8000/snmp/mode/sensors.pm +++ b/hardware/sensors/comet/p8000/snmp/mode/sensors.pm @@ -25,8 +25,6 @@ use base qw(centreon::plugins::templates::counter); use strict; use warnings; -my $instance_mode; - sub custom_temperature_perfdata { my ($self, %options) = @_; @@ -62,14 +60,14 @@ sub custom_sensor_threshold { my ($self, %options) = @_; my $warn_limit; - if (defined($instance_mode->{option_results}->{'warning-' . $self->{label}}) && $instance_mode->{option_results}->{'warning-' . $self->{label}} ne '') { - $warn_limit = $instance_mode->{option_results}->{'warning-' . $self->{label}}; + if (defined($self->{instance_mode}->{option_results}->{'warning-' . $self->{label}}) && $self->{instance_mode}->{option_results}->{'warning-' . $self->{label}} ne '') { + $warn_limit = $self->{instance_mode}->{option_results}->{'warning-' . $self->{label}}; } $self->{perfdata}->threshold_validate(label => 'warning-' . $self->{label} . '_' . $self->{result_values}->{display_absolute}, value => $warn_limit); my $crit_limit = $self->{result_values}->{limit_lo_absolute} . ':' . $self->{result_values}->{limit_hi_absolute}; - if (defined($instance_mode->{option_results}->{'critical-' . $self->{label}}) && $instance_mode->{option_results}->{'critical-' . $self->{label}} ne '') { - $crit_limit = $instance_mode->{option_results}->{'critical-' . $self->{label}}; + if (defined($self->{instance_mode}->{option_results}->{'critical-' . $self->{label}}) && $self->{instance_mode}->{option_results}->{'critical-' . $self->{label}} ne '') { + $crit_limit = $self->{instance_mode}->{option_results}->{'critical-' . $self->{label}}; } $self->{perfdata}->threshold_validate(label => 'critical-' . $self->{label} . '_' . $self->{result_values}->{display_absolute}, value => $crit_limit); @@ -110,20 +108,12 @@ sub new { bless $self, $class; $self->{version} = '1.0'; - $options{options}->add_options(arguments => - { - }); + $options{options}->add_options(arguments => { + }); return $self; } -sub check_options { - my ($self, %options) = @_; - $self->SUPER::check_options(%options); - - $instance_mode = $self; -} - sub prefix_channel_output { my ($self, %options) = @_; diff --git a/network/alcatel/isam/snmp/mode/memory.pm b/network/alcatel/isam/snmp/mode/memory.pm index 97246f349..30fe5e08c 100644 --- a/network/alcatel/isam/snmp/mode/memory.pm +++ b/network/alcatel/isam/snmp/mode/memory.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; @@ -116,23 +114,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_memory_output { my ($self, %options) = @_; diff --git a/network/citrix/netscaler/snmp/mode/storage.pm b/network/citrix/netscaler/snmp/mode/storage.pm index b6922db36..b3c06bd04 100644 --- a/network/citrix/netscaler/snmp/mode/storage.pm +++ b/network/citrix/netscaler/snmp/mode/storage.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 (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; } @@ -75,10 +73,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; @@ -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; -} - my $mapping = { sysHealthDiskName => { oid => '.1.3.6.1.4.1.5951.4.1.1.41.8.1.1' }, sysHealthDiskSize => { oid => '.1.3.6.1.4.1.5951.4.1.1.41.8.1.2' }, # in MB diff --git a/network/citrix/netscaler/snmp/mode/vserverstatus.pm b/network/citrix/netscaler/snmp/mode/vserverstatus.pm index 732a217d9..ea69818ce 100644 --- a/network/citrix/netscaler/snmp/mode/vserverstatus.pm +++ b/network/citrix/netscaler/snmp/mode/vserverstatus.pm @@ -26,8 +26,6 @@ use strict; use warnings; use Digest::MD5 qw(md5_hex); -my $instance_mode; - sub set_counters { my ($self, %options) = @_; @@ -158,13 +156,12 @@ sub new { bless $self, $class; $self->{version} = '1.0'; - $options{options}->add_options(arguments => - { - "filter-name:s" => { name => 'filter_name' }, - "filter-type:s" => { name => 'filter_type' }, - "threshold-overload:s@" => { name => 'threshold_overload' }, - }); - + $options{options}->add_options(arguments => { + "filter-name:s" => { name => 'filter_name' }, + "filter-type:s" => { name => 'filter_type' }, + "threshold-overload:s@" => { name => 'threshold_overload' }, + }); + return $self; } diff --git a/network/citrix/sdx/snmp/mode/diskusage.pm b/network/citrix/sdx/snmp/mode/diskusage.pm index d60f14ee8..2670bca0e 100644 --- a/network/citrix/sdx/snmp/mode/diskusage.pm +++ b/network/citrix/sdx/snmp/mode/diskusage.pm @@ -26,21 +26,19 @@ use strict; use warnings; use Digest::MD5 qw(md5_hex); -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; } @@ -57,10 +55,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; @@ -137,23 +135,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_disk_output { my ($self, %options) = @_; diff --git a/network/citrix/sdx/snmp/mode/xenusage.pm b/network/citrix/sdx/snmp/mode/xenusage.pm index 386bf507c..13560dcbe 100644 --- a/network/citrix/sdx/snmp/mode/xenusage.pm +++ b/network/citrix/sdx/snmp/mode/xenusage.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 = 'memory_used'; my $value_perf = $self->{result_values}->{used}; - if (defined($instance_mode->{option_results}->{free})) { + if (defined($self->{instance_mode}->{option_results}->{free})) { $label = 'memory_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; @@ -125,23 +123,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_disk_output { my ($self, %options) = @_; diff --git a/network/f5/bigip/snmp/mode/nodestatus.pm b/network/f5/bigip/snmp/mode/nodestatus.pm index 07fad2826..7179e9506 100644 --- a/network/f5/bigip/snmp/mode/nodestatus.pm +++ b/network/f5/bigip/snmp/mode/nodestatus.pm @@ -35,12 +35,11 @@ my $thresholds = { ['gray', 'UNKNOWN'], ], }; -my $instance_mode; sub custom_threshold_output { my ($self, %options) = @_; - return $instance_mode->get_severity(section => 'node', value => $self->{result_values}->{AvailState}); + return $self->{instance_mode}->get_severity(section => 'node', value => $self->{result_values}->{AvailState}); } sub custom_status_calc { @@ -90,11 +89,10 @@ sub new { bless $self, $class; $self->{version} = '1.0'; - $options{options}->add_options(arguments => - { - "filter-name:s" => { name => 'filter_name' }, - "threshold-overload:s@" => { name => 'threshold_overload' }, - }); + $options{options}->add_options(arguments => { + "filter-name:s" => { name => 'filter_name' }, + "threshold-overload:s@" => { name => 'threshold_overload' }, + }); return $self; } @@ -102,9 +100,7 @@ sub new { sub check_options { my ($self, %options) = @_; $self->SUPER::check_options(%options); - - $instance_mode = $self; - + $self->{overload_th} = {}; foreach my $val (@{$self->{option_results}->{threshold_overload}}) { if ($val !~ /^(.*?),(.*?),(.*)$/) { diff --git a/network/f5/bigip/snmp/mode/poolstatus.pm b/network/f5/bigip/snmp/mode/poolstatus.pm index a14277b3a..a1a7548d6 100644 --- a/network/f5/bigip/snmp/mode/poolstatus.pm +++ b/network/f5/bigip/snmp/mode/poolstatus.pm @@ -35,12 +35,11 @@ my $thresholds = { ['gray', 'UNKNOWN'], ], }; -my $instance_mode; sub custom_threshold_output { my ($self, %options) = @_; - return $instance_mode->get_severity(section => 'pool', value => $self->{result_values}->{AvailState}); + return $self->{instance_mode}->get_severity(section => 'pool', value => $self->{result_values}->{AvailState}); } sub custom_status_calc { @@ -90,11 +89,10 @@ sub new { bless $self, $class; $self->{version} = '1.0'; - $options{options}->add_options(arguments => - { - "filter-name:s" => { name => 'filter_name' }, - "threshold-overload:s@" => { name => 'threshold_overload' }, - }); + $options{options}->add_options(arguments => { + "filter-name:s" => { name => 'filter_name' }, + "threshold-overload:s@" => { name => 'threshold_overload' }, + }); return $self; } @@ -102,9 +100,7 @@ sub new { sub check_options { my ($self, %options) = @_; $self->SUPER::check_options(%options); - - $instance_mode = $self; - + $self->{overload_th} = {}; foreach my $val (@{$self->{option_results}->{threshold_overload}}) { if ($val !~ /^(.*?),(.*?),(.*)$/) { diff --git a/network/f5/bigip/snmp/mode/trunks.pm b/network/f5/bigip/snmp/mode/trunks.pm index e0fd422d4..c566af058 100644 --- a/network/f5/bigip/snmp/mode/trunks.pm +++ b/network/f5/bigip/snmp/mode/trunks.pm @@ -26,8 +26,6 @@ use strict; use warnings; use Digest::MD5 qw(md5_hex); -my $instance_mode; - my $thresholds = { trunk => [ ['up', 'OK'], @@ -42,7 +40,7 @@ my $thresholds = { sub custom_threshold_output { my ($self, %options) = @_; - return $instance_mode->get_severity(section => 'trunk', value => $self->{result_values}->{sysTrunkStatus}); + return $self->{instance_mode}->get_severity(section => 'trunk', value => $self->{result_values}->{sysTrunkStatus}); } sub custom_status_calc { @@ -61,10 +59,10 @@ sub custom_traffic_perfdata { } my ($warning, $critical); - if ($instance_mode->{option_results}->{units_traffic} eq '%' && defined($self->{result_values}->{speed}) && $self->{result_values}->{speed} > 0) { + if ($self->{instance_mode}->{option_results}->{units_traffic} eq '%' && defined($self->{result_values}->{speed}) && $self->{result_values}->{speed} > 0) { $warning = $self->{perfdata}->get_perfdata_for_output(label => 'warning-traffic-' . $self->{result_values}->{label}, total => $self->{result_values}->{speed}, cast_int => 1); $critical = $self->{perfdata}->get_perfdata_for_output(label => 'critical-traffic-' . $self->{result_values}->{label}, total => $self->{result_values}->{speed}, cast_int => 1); - } elsif ($instance_mode->{option_results}->{units_traffic} eq 'b/s') { + } elsif ($self->{instance_mode}->{option_results}->{units_traffic} eq 'b/s') { $warning = $self->{perfdata}->get_perfdata_for_output(label => 'warning-traffic-' . $self->{result_values}->{label}); $critical = $self->{perfdata}->get_perfdata_for_output(label => 'critical-traffic-' . $self->{result_values}->{label}); } @@ -82,9 +80,9 @@ sub custom_traffic_threshold { my ($self, %options) = @_; my $exit = 'ok'; - if ($instance_mode->{option_results}->{units_traffic} eq '%' && defined($self->{result_values}->{speed}) && $self->{result_values}->{speed} > 0) { + if ($self->{instance_mode}->{option_results}->{units_traffic} eq '%' && defined($self->{result_values}->{speed}) && $self->{result_values}->{speed} > 0) { $exit = $self->{perfdata}->threshold_check(value => $self->{result_values}->{traffic_prct}, threshold => [ { label => 'critical-traffic-' . $self->{result_values}->{label}, exit_litteral => 'critical' }, { label => 'warning-traffic-' . $self->{result_values}->{label}, exit_litteral => 'warning' } ]); - } elsif ($instance_mode->{option_results}->{units_traffic} eq 'b/s') { + } elsif ($self->{instance_mode}->{option_results}->{units_traffic} eq 'b/s') { $exit = $self->{perfdata}->threshold_check(value => $self->{result_values}->{traffic_per_seconds}, threshold => [ { label => 'critical-traffic-' . $self->{result_values}->{label}, exit_litteral => 'critical' }, { label => 'warning-traffic-' . $self->{result_values}->{label}, exit_litteral => 'warning' } ]); } return $exit; @@ -110,7 +108,7 @@ sub custom_traffic_calc { my $diff_traffic = ($options{new_datas}->{$self->{instance} . '_' . $options{extra_options}->{label_ref}} - $options{old_datas}->{$self->{instance} . '_' . $options{extra_options}->{label_ref}}); - $self->{result_values}->{speed} = defined($instance_mode->{option_results}->{speed}) && $instance_mode->{option_results}->{speed} ne '' ? $instance_mode->{option_results}->{speed} : $options{new_datas}->{$self->{instance} . '_' . $options{extra_options}->{speed}}; + $self->{result_values}->{speed} = defined($self->{instance_mode}->{option_results}->{speed}) && $self->{instance_mode}->{option_results}->{speed} ne '' ? $self->{instance_mode}->{option_results}->{speed} : $options{new_datas}->{$self->{instance} . '_' . $options{extra_options}->{speed}}; $self->{result_values}->{speed} = $self->{result_values}->{speed} * 1000 * 1000; # bits $self->{result_values}->{traffic_per_seconds} = $diff_traffic * 8 / $options{delta_time}; $self->{result_values}->{traffic_prct} = $self->{result_values}->{traffic_per_seconds} * 100 / $self->{result_values}->{speed} if ($self->{result_values}->{speed} > 0); @@ -309,22 +307,19 @@ sub new { bless $self, $class; $self->{version} = '1.0'; - $options{options}->add_options(arguments => - { - "filter-name:s" => { name => 'filter_name' }, - "threshold-overload:s@" => { name => 'threshold_overload' }, - "units-traffic:s" => { name => 'units_traffic', default => '%' }, - "speed:s" => { name => 'speed' }, - }); - + $options{options}->add_options(arguments => { + "filter-name:s" => { name => 'filter_name' }, + "threshold-overload:s@" => { name => 'threshold_overload' }, + "units-traffic:s" => { name => 'units_traffic', default => '%' }, + "speed:s" => { name => 'speed' }, + }); + return $self; } sub check_options { my ($self, %options) = @_; $self->SUPER::check_options(%options); - - $instance_mode = $self; $self->{overload_th} = {}; foreach my $val (@{$self->{option_results}->{threshold_overload}}) { diff --git a/network/f5/bigip/snmp/mode/virtualserverstatus.pm b/network/f5/bigip/snmp/mode/virtualserverstatus.pm index eedd04c0a..e25c7def7 100644 --- a/network/f5/bigip/snmp/mode/virtualserverstatus.pm +++ b/network/f5/bigip/snmp/mode/virtualserverstatus.pm @@ -35,12 +35,11 @@ my $thresholds = { ['gray', 'UNKNOWN'], ], }; -my $instance_mode; sub custom_threshold_output { my ($self, %options) = @_; - return $instance_mode->get_severity(section => 'vs', value => $self->{result_values}->{AvailState}); + return $self->{instance_mode}->get_severity(section => 'vs', value => $self->{result_values}->{AvailState}); } sub custom_status_calc { @@ -81,11 +80,10 @@ sub new { bless $self, $class; $self->{version} = '1.0'; - $options{options}->add_options(arguments => - { - "filter-name:s" => { name => 'filter_name' }, - "threshold-overload:s@" => { name => 'threshold_overload' }, - }); + $options{options}->add_options(arguments => { + "filter-name:s" => { name => 'filter_name' }, + "threshold-overload:s@" => { name => 'threshold_overload' }, + }); return $self; } @@ -93,9 +91,7 @@ sub new { sub check_options { my ($self, %options) = @_; $self->SUPER::check_options(%options); - - $instance_mode = $self; - + $self->{overload_th} = {}; foreach my $val (@{$self->{option_results}->{threshold_overload}}) { if ($val !~ /^(.*?),(.*?),(.*)$/) { diff --git a/network/stormshield/local/mode/qosusage.pm b/network/stormshield/local/mode/qosusage.pm index eb2b8d768..b0795b449 100644 --- a/network/stormshield/local/mode/qosusage.pm +++ b/network/stormshield/local/mode/qosusage.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) = @_; @@ -83,10 +81,10 @@ sub custom_qos_perfdata { } my ($warning, $critical); - if ($instance_mode->{option_results}->{units_traffic} eq '%' && defined($self->{result_values}->{speed})) { + if ($self->{instance_mode}->{option_results}->{units_traffic} eq '%' && defined($self->{result_values}->{speed})) { $warning = $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{label}, total => $self->{result_values}->{speed}, cast_int => 1); $critical = $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{label}, total => $self->{result_values}->{speed}, cast_int => 1); - } elsif ($instance_mode->{option_results}->{units_traffic} eq 'b/s') { + } elsif ($self->{instance_mode}->{option_results}->{units_traffic} eq 'b/s') { $warning = $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{label}); $critical = $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{label}); } @@ -102,9 +100,9 @@ sub custom_qos_threshold { my ($self, %options) = @_; my $exit = 'ok'; - if ($instance_mode->{option_results}->{units_traffic} eq '%' && defined($self->{result_values}->{speed})) { + if ($self->{instance_mode}->{option_results}->{units_traffic} eq '%' && defined($self->{result_values}->{speed})) { $exit = $self->{perfdata}->threshold_check(value => $self->{result_values}->{traffic_prct}, threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, { label => 'warning-' . $self->{label}, exit_litteral => 'warning' } ]); - } elsif ($instance_mode->{option_results}->{units_traffic} eq 'b/s') { + } elsif ($self->{instance_mode}->{option_results}->{units_traffic} eq 'b/s') { $exit = $self->{perfdata}->threshold_check(value => $self->{result_values}->{traffic}, threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, { label => 'warning-' . $self->{label}, exit_litteral => 'warning' } ]); } return $exit; @@ -135,9 +133,9 @@ sub custom_qos_calc { if ($options{new_datas}->{$self->{instance} . '_speed_' . $self->{result_values}->{label}} > 0) { $self->{result_values}->{speed} = $options{new_datas}->{$self->{instance} . '_speed_' . $self->{result_values}->{label}} * 1000 * 1000; $self->{result_values}->{traffic_prct} = $self->{result_values}->{traffic} * 100 / $self->{result_values}->{speed}; - } elsif (defined($instance_mode->{option_results}->{'speed_' . $self->{result_values}->{label}}) && $instance_mode->{option_results}->{'speed_' . $self->{result_values}->{label}} =~ /[0-9]/) { - $self->{result_values}->{traffic_prct} = $self->{result_values}->{traffic} * 100 / ($instance_mode->{option_results}->{'speed_' . $self->{result_values}->{label}} * 1000 * 1000); - $self->{result_values}->{speed} = $instance_mode->{option_results}->{'speed_' . $self->{result_values}->{label}} * 1000 * 1000; + } elsif (defined($self->{instance_mode}->{option_results}->{'speed_' . $self->{result_values}->{label}}) && $self->{instance_mode}->{option_results}->{'speed_' . $self->{result_values}->{label}} =~ /[0-9]/) { + $self->{result_values}->{traffic_prct} = $self->{result_values}->{traffic} * 100 / ($self->{instance_mode}->{option_results}->{'speed_' . $self->{result_values}->{label}} * 1000 * 1000); + $self->{result_values}->{speed} = $self->{instance_mode}->{option_results}->{'speed_' . $self->{result_values}->{label}} * 1000 * 1000; } return 0; } @@ -148,25 +146,24 @@ sub new { bless $self, $class; $self->{version} = '1.0'; - $options{options}->add_options(arguments => - { - "filter-name:s" => { name => 'filter_name' }, - "filter-vlan:s" => { name => 'filter_vlan' }, - "speed-in:s" => { name => 'speed_in' }, - "speed-out:s" => { name => 'speed_out' }, - "units-traffic:s" => { name => 'units_traffic', default => '%' }, - "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 => 'tail' }, - "command-path:s" => { name => 'command_path' }, - "command-options:s" => { name => 'command_options', default => '-1 /log/l_monitor' }, - "config-speed-file:s" => { name => 'config_speed_file' }, - }); - + $options{options}->add_options(arguments => { + "filter-name:s" => { name => 'filter_name' }, + "filter-vlan:s" => { name => 'filter_vlan' }, + "speed-in:s" => { name => 'speed_in' }, + "speed-out:s" => { name => 'speed_out' }, + "units-traffic:s" => { name => 'units_traffic', default => '%' }, + "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 => 'tail' }, + "command-path:s" => { name => 'command_path' }, + "command-options:s" => { name => 'command_options', default => '-1 /log/l_monitor' }, + "config-speed-file:s" => { name => 'config_speed_file' }, + }); + return $self; } @@ -180,9 +177,7 @@ sub check_options { $self->{hostname} = $self->{option_results}->{hostname}; if (!defined($self->{hostname})) { $self->{hostname} = 'me'; - } - - $instance_mode = $self; + } } sub prefix_qos_output {