cleaning code (storage)

This commit is contained in:
garnier-quentin 2019-03-26 16:28:40 +01:00
parent d716a11b4c
commit 3b7d2dfbd0
17 changed files with 225 additions and 364 deletions

View File

@ -25,13 +25,11 @@ use base qw(centreon::plugins::templates::counter);
use strict; use strict;
use warnings; use warnings;
my $instance_mode;
sub custom_usage_perfdata { sub custom_usage_perfdata {
my ($self, %options) = @_; my ($self, %options) = @_;
my %total_options = (); my %total_options = ();
if ($instance_mode->{option_results}->{units} eq '%') { if ($self->{instance_mode}->{option_results}->{units} eq '%') {
$total_options{total} = $self->{result_values}->{total}; $total_options{total} = $self->{result_values}->{total};
$total_options{cast_int} = 1; $total_options{cast_int} = 1;
} }
@ -49,10 +47,10 @@ sub custom_usage_threshold {
my ($exit, $threshold_value); my ($exit, $threshold_value);
$threshold_value = $self->{result_values}->{used}; $threshold_value = $self->{result_values}->{used};
$threshold_value = $self->{result_values}->{free} if (defined($instance_mode->{option_results}->{free})); $threshold_value = $self->{result_values}->{free} if (defined($self->{instance_mode}->{option_results}->{free}));
if ($instance_mode->{option_results}->{units} eq '%') { if ($self->{instance_mode}->{option_results}->{units} eq '%') {
$threshold_value = $self->{result_values}->{prct_used}; $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, $exit = $self->{perfdata}->threshold_check(value => $threshold_value,
threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' },
@ -94,7 +92,7 @@ sub custom_swap_perfdata {
my ($self, %options) = @_; my ($self, %options) = @_;
my %total_options = (); my %total_options = ();
if ($instance_mode->{option_results}->{units} eq '%') { if ($self->{instance_mode}->{option_results}->{units} eq '%') {
$total_options{total} = $self->{result_values}->{total}; $total_options{total} = $self->{result_values}->{total};
$total_options{cast_int} = 1; $total_options{cast_int} = 1;
} }
@ -112,10 +110,10 @@ sub custom_swap_threshold {
my ($exit, $threshold_value); my ($exit, $threshold_value);
$threshold_value = $self->{result_values}->{used}; $threshold_value = $self->{result_values}->{used};
$threshold_value = $self->{result_values}->{available} if (defined($instance_mode->{option_results}->{free})); $threshold_value = $self->{result_values}->{available} if (defined($self->{instance_mode}->{option_results}->{free}));
if ($instance_mode->{option_results}->{units} eq '%') { if ($self->{instance_mode}->{option_results}->{units} eq '%') {
$threshold_value = $self->{result_values}->{prct_used}; $threshold_value = $self->{result_values}->{prct_used};
$threshold_value = $self->{result_values}->{prct_available} if (defined($instance_mode->{option_results}->{free})); $threshold_value = $self->{result_values}->{prct_available} if (defined($self->{instance_mode}->{option_results}->{free}));
} }
$exit = $self->{perfdata}->threshold_check(value => $threshold_value, $exit = $self->{perfdata}->threshold_check(value => $threshold_value,
threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' },
@ -231,13 +229,6 @@ sub new {
return $self; return $self;
} }
sub check_options {
my ($self, %options) = @_;
$self->SUPER::check_options(%options);
$instance_mode = $self;
}
my $mapping = { my $mapping = {
memTotalSwap => { oid => '.1.3.6.1.4.1.2021.4.3' }, memTotalSwap => { oid => '.1.3.6.1.4.1.2021.4.3' },
memAvailSwap => { oid => '.1.3.6.1.4.1.2021.4.4' }, memAvailSwap => { oid => '.1.3.6.1.4.1.2021.4.4' },

View File

@ -25,8 +25,6 @@ use base qw(centreon::plugins::templates::counter);
use strict; use strict;
use warnings; use warnings;
my $instance_mode;
sub custom_client_perfdata { sub custom_client_perfdata {
my ($self, %options) = @_; my ($self, %options) = @_;
@ -41,7 +39,7 @@ sub custom_client_threshold {
my ($self, %options) = @_; my ($self, %options) = @_;
my ($exit, $threshold_value); my ($exit, $threshold_value);
$threshold_value = defined($instance_mode->{option_results}->{percent}) ? $self->{result_values}->{prct_active} : $self->{result_values}->{active} ; $threshold_value = defined($self->{instance_mode}->{option_results}->{percent}) ? $self->{result_values}->{prct_active} : $self->{result_values}->{active} ;
$exit = $self->{perfdata}->threshold_check(value => $threshold_value, $exit = $self->{perfdata}->threshold_check(value => $threshold_value,
threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' },
{ label => 'warning-' . $self->{label}, exit_litteral => 'warning' } ]); { label => 'warning-' . $self->{label}, exit_litteral => 'warning' } ]);
@ -129,20 +127,13 @@ sub new {
bless $self, $class; bless $self, $class;
$self->{version} = '1.0'; $self->{version} = '1.0';
$options{options}->add_options(arguments => $options{options}->add_options(arguments => {
{ "percent" => { name => 'percent' },
"percent" => { name => 'percent' }, });
});
return $self; return $self;
} }
sub check_options {
my ($self, %options) = @_;
$self->SUPER::check_options(%options);
$instance_mode = $self;
}
my $oid_ReadMegabytesPerSecond = '.1.3.6.1.4.1.526.20.3.2.0'; my $oid_ReadMegabytesPerSecond = '.1.3.6.1.4.1.526.20.3.2.0';
my $oid_WriteMegabytesPerSecond = '.1.3.6.1.4.1.526.20.3.3.0'; my $oid_WriteMegabytesPerSecond = '.1.3.6.1.4.1.526.20.3.3.0';
my $oid_MessagesPerSecond = '.1.3.6.1.4.1.526.20.3.4.0'; my $oid_MessagesPerSecond = '.1.3.6.1.4.1.526.20.3.4.0';

View File

@ -25,19 +25,17 @@ use base qw(centreon::plugins::templates::counter);
use strict; use strict;
use warnings; use warnings;
my $instance_mode;
sub custom_usage_perfdata { sub custom_usage_perfdata {
my ($self, %options) = @_; my ($self, %options) = @_;
my $label = 'used'; my $label = 'used';
my $value_perf = $self->{result_values}->{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'; $label = 'free';
$value_perf = $self->{result_values}->{free}; $value_perf = $self->{result_values}->{free};
} }
my %total_options = (); my %total_options = ();
if ($instance_mode->{option_results}->{units} eq '%') { if ($self->{instance_mode}->{option_results}->{units} eq '%') {
$total_options{total} = $self->{result_values}->{allocated}; $total_options{total} = $self->{result_values}->{allocated};
$total_options{cast_int} = 1; $total_options{cast_int} = 1;
} }
@ -58,10 +56,10 @@ sub custom_usage_threshold {
my ($exit, $threshold_value); my ($exit, $threshold_value);
$threshold_value = $self->{result_values}->{used}; $threshold_value = $self->{result_values}->{used};
$threshold_value = $self->{result_values}->{free} if (defined($instance_mode->{option_results}->{free})); $threshold_value = $self->{result_values}->{free} if (defined($self->{instance_mode}->{option_results}->{free}));
if ($instance_mode->{option_results}->{units} eq '%') { if ($self->{instance_mode}->{option_results}->{units} eq '%') {
$threshold_value = $self->{result_values}->{prct_used}; $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' }, $exit = $self->{perfdata}->threshold_check(value => $threshold_value, threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' },
{ label => 'warning-'. $self->{label}, exit_litteral => 'warning' } ]); { label => 'warning-'. $self->{label}, exit_litteral => 'warning' } ]);
@ -152,21 +150,14 @@ sub new {
bless $self, $class; bless $self, $class;
$self->{version} = '1.0'; $self->{version} = '1.0';
$options{options}->add_options(arguments => $options{options}->add_options(arguments => {
{ "units:s" => { name => 'units', default => '%' },
"units:s" => { name => 'units', default => '%' }, "free" => { name => 'free' },
"free" => { name => 'free' }, });
});
return $self; return $self;
} }
sub check_options {
my ($self, %options) = @_;
$self->SUPER::check_options(%options);
$instance_mode = $self;
}
my $oid_TotalSystemMB = '.1.3.6.1.4.1.526.20.4.2.0'; my $oid_TotalSystemMB = '.1.3.6.1.4.1.526.20.4.2.0';
my $oid_TotalAllocatedMB = '.1.3.6.1.4.1.526.20.4.3.0'; my $oid_TotalAllocatedMB = '.1.3.6.1.4.1.526.20.4.3.0';
my $oid_TotalUsedMB = '.1.3.6.1.4.1.526.20.4.4.0'; my $oid_TotalUsedMB = '.1.3.6.1.4.1.526.20.4.4.0';

View File

@ -98,21 +98,19 @@ sub sc_init {
return 0; return 0;
} }
my $instance_mode;
sub custom_usage_perfdata { sub custom_usage_perfdata {
my ($self, %options) = @_; my ($self, %options) = @_;
my $label = $self->{result_values}->{type} . '_used'; my $label = $self->{result_values}->{type} . '_used';
my $value_perf = $self->{result_values}->{used}; my $value_perf = $self->{result_values}->{used};
if (defined($instance_mode->{option_results}->{free})) { if (defined($self->{instance_mode}->{option_results}->{free})) {
$label = $self->{result_values}->{type} . '_free'; $label = $self->{result_values}->{type} . '_free';
$value_perf = $self->{result_values}->{free}; $value_perf = $self->{result_values}->{free};
} }
my $extra_label = ''; my $extra_label = '';
$extra_label = '_' . $self->{result_values}->{display} if (!defined($options{extra_instance}) || $options{extra_instance} != 0); $extra_label = '_' . $self->{result_values}->{display} if (!defined($options{extra_instance}) || $options{extra_instance} != 0);
my %total_options = (); my %total_options = ();
if ($instance_mode->{option_results}->{units} eq '%') { if ($self->{instance_mode}->{option_results}->{units} eq '%') {
$total_options{total} = $self->{result_values}->{total}; $total_options{total} = $self->{result_values}->{total};
$total_options{cast_int} = 1; $total_options{cast_int} = 1;
} }
@ -129,10 +127,10 @@ sub custom_usage_threshold {
my ($exit, $threshold_value); my ($exit, $threshold_value);
$threshold_value = $self->{result_values}->{used}; $threshold_value = $self->{result_values}->{used};
$threshold_value = $self->{result_values}->{free} if (defined($instance_mode->{option_results}->{free})); $threshold_value = $self->{result_values}->{free} if (defined($self->{instance_mode}->{option_results}->{free}));
if ($instance_mode->{option_results}->{units} eq '%') { if ($self->{instance_mode}->{option_results}->{units} eq '%') {
$threshold_value = $self->{result_values}->{prct_used}; $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' } ]); $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; return $exit;
@ -177,24 +175,24 @@ sub new {
bless $self, $class; bless $self, $class;
$self->{version} = '1.0'; $self->{version} = '1.0';
$options{options}->add_options(arguments => $options{options}->add_options(arguments => {
{ "cem-host:s" => { name => 'cem_host' },
"cem-host:s" => { name => 'cem_host' }, "cem-user:s" => { name => 'cem_user' },
"cem-user:s" => { name => 'cem_user' }, "cem-password:s" => { name => 'cem_password' },
"cem-password:s" => { name => 'cem_password' }, "cem-port:s" => { name => 'cem_port', default => 3033 },
"cem-port:s" => { name => 'cem_port', default => 3033 }, "sdk-path-dll:s" => { name => 'sdk_path_dll' },
"sdk-path-dll:s" => { name => 'sdk_path_dll' }, "timeout:s" => { name => 'timeout', default => 50 },
"timeout:s" => { name => 'timeout', default => 50 }, "command:s" => { name => 'command', default => 'powershell.exe' },
"command:s" => { name => 'command', default => 'powershell.exe' }, "command-path:s" => { name => 'command_path' },
"command-path:s" => { name => 'command_path' }, "command-options:s" => { name => 'command_options', default => '-InputFormat none -NoLogo -EncodedCommand' },
"command-options:s" => { name => 'command_options', default => '-InputFormat none -NoLogo -EncodedCommand' }, "no-ps" => { name => 'no_ps' },
"no-ps" => { name => 'no_ps' }, "ps-exec-only" => { name => 'ps_exec_only' },
"ps-exec-only" => { name => 'ps_exec_only' }, "ps-sc-filter:s" => { name => 'ps_sc_filter' },
"ps-sc-filter:s" => { name => 'ps_sc_filter' }, "ps-sc-volume:s" => { name => 'ps_sc_volume' },
"ps-sc-volume:s" => { name => 'ps_sc_volume' }, "units:s" => { name => 'units', default => '%' },
"units:s" => { name => 'units', default => '%' }, "free" => { name => 'free' },
"free" => { name => 'free' }, });
});
return $self; return $self;
} }
@ -209,9 +207,7 @@ sub check_options {
$self->{output}->add_option_msg(short_msg => "Need to specify --" . $label_opt . " option."); $self->{output}->add_option_msg(short_msg => "Need to specify --" . $label_opt . " option.");
$self->{output}->option_exit(); $self->{output}->option_exit();
} }
} }
$instance_mode = $self;
} }
sub manage_selection { sub manage_selection {

View File

@ -25,21 +25,19 @@ use base qw(centreon::plugins::templates::counter);
use strict; use strict;
use warnings; use warnings;
my $instance_mode;
sub custom_usage_perfdata { sub custom_usage_perfdata {
my ($self, %options) = @_; my ($self, %options) = @_;
my $label = 'used'; my $label = 'used';
my $value_perf = $self->{result_values}->{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'; $label = 'free';
$value_perf = $self->{result_values}->{free}; $value_perf = $self->{result_values}->{free};
} }
my $extra_label = ''; my $extra_label = '';
$extra_label = '_' . $self->{result_values}->{display} if (!defined($options{extra_instance}) || $options{extra_instance} != 0); $extra_label = '_' . $self->{result_values}->{display} if (!defined($options{extra_instance}) || $options{extra_instance} != 0);
my %total_options = (); my %total_options = ();
if ($instance_mode->{option_results}->{units} eq '%') { if ($self->{instance_mode}->{option_results}->{units} eq '%') {
$total_options{total} = $self->{result_values}->{total}; $total_options{total} = $self->{result_values}->{total};
$total_options{cast_int} = 1; $total_options{cast_int} = 1;
} }
@ -56,10 +54,10 @@ sub custom_usage_threshold {
my ($exit, $threshold_value); my ($exit, $threshold_value);
$threshold_value = $self->{result_values}->{used}; $threshold_value = $self->{result_values}->{used};
$threshold_value = $self->{result_values}->{free} if (defined($instance_mode->{option_results}->{free})); $threshold_value = $self->{result_values}->{free} if (defined($self->{instance_mode}->{option_results}->{free}));
if ($instance_mode->{option_results}->{units} eq '%') { if ($self->{instance_mode}->{option_results}->{units} eq '%') {
$threshold_value = $self->{result_values}->{prct_used}; $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' } ]); $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; return $exit;
@ -117,23 +115,15 @@ sub new {
bless $self, $class; bless $self, $class;
$self->{version} = '1.0'; $self->{version} = '1.0';
$options{options}->add_options(arguments => $options{options}->add_options(arguments => {
{ "filter-name:s" => { name => 'filter_name' },
"filter-name:s" => { name => 'filter_name' }, "units:s" => { name => 'units', default => '%' },
"units:s" => { name => 'units', default => '%' }, "free" => { name => 'free' },
"free" => { name => 'free' }, });
});
return $self; return $self;
} }
sub check_options {
my ($self, %options) = @_;
$self->SUPER::check_options(%options);
$instance_mode = $self;
}
sub prefix_volume_output { sub prefix_volume_output {
my ($self, %options) = @_; my ($self, %options) = @_;

View File

@ -43,19 +43,17 @@ sub set_counters {
]; ];
} }
my $instance_mode;
sub custom_usage_perfdata { sub custom_usage_perfdata {
my ($self, %options) = @_; my ($self, %options) = @_;
my $label = 'used'; my $label = 'used';
my $value_perf = $self->{result_values}->{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'; $label = 'free';
$value_perf = $self->{result_values}->{free}; $value_perf = $self->{result_values}->{free};
} }
my %total_options = (); my %total_options = ();
if ($instance_mode->{option_results}->{units} eq '%') { if ($self->{instance_mode}->{option_results}->{units} eq '%') {
$total_options{total} = $self->{result_values}->{total}; $total_options{total} = $self->{result_values}->{total};
$total_options{cast_int} = 1; $total_options{cast_int} = 1;
} }
@ -72,10 +70,10 @@ sub custom_usage_threshold {
my ($exit, $threshold_value); my ($exit, $threshold_value);
$threshold_value = $self->{result_values}->{used}; $threshold_value = $self->{result_values}->{used};
$threshold_value = $self->{result_values}->{free} if (defined($instance_mode->{option_results}->{free})); $threshold_value = $self->{result_values}->{free} if (defined($self->{instance_mode}->{option_results}->{free}));
if ($instance_mode->{option_results}->{units} eq '%') { if ($self->{instance_mode}->{option_results}->{units} eq '%') {
$threshold_value = $self->{result_values}->{prct_used}; $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' } ]); $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; return $exit;
@ -115,21 +113,14 @@ sub new {
bless $self, $class; bless $self, $class;
$self->{version} = '1.0'; $self->{version} = '1.0';
$options{options}->add_options(arguments => $options{options}->add_options(arguments => {
{ "units:s" => { name => 'units', default => '%' },
"units:s" => { name => 'units', default => '%' }, "free" => { name => 'free' },
"free" => { name => 'free' }, });
});
return $self; return $self;
} }
sub check_options {
my ($self, %options) = @_;
$self->SUPER::check_options(%options);
$instance_mode = $self;
}
sub manage_selection { sub manage_selection {
my ($self, %options) = @_; my ($self, %options) = @_;

View File

@ -25,8 +25,6 @@ use base qw(centreon::plugins::templates::counter);
use strict; use strict;
use warnings; use warnings;
my $instance_mode;
sub custom_usage_perfdata { sub custom_usage_perfdata {
my ($self, %options) = @_; my ($self, %options) = @_;
@ -46,10 +44,10 @@ sub custom_usage_threshold {
my ($exit, $threshold_value); my ($exit, $threshold_value);
$threshold_value = $self->{result_values}->{used}; $threshold_value = $self->{result_values}->{used};
$threshold_value = $self->{result_values}->{free} if (defined($instance_mode->{option_results}->{free})); $threshold_value = $self->{result_values}->{free} if (defined($self->{instance_mode}->{option_results}->{free}));
if ($instance_mode->{option_results}->{units} eq '%') { if ($self->{instance_mode}->{option_results}->{units} eq '%') {
$threshold_value = $self->{result_values}->{prct_used}; $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, $exit = $self->{perfdata}->threshold_check(value => $threshold_value,
threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' },
@ -110,10 +108,10 @@ sub custom_snapshot_threshold {
my ($exit, $threshold_value); my ($exit, $threshold_value);
$threshold_value = $self->{result_values}->{used}; $threshold_value = $self->{result_values}->{used};
$threshold_value = $self->{result_values}->{free} if (defined($instance_mode->{option_results}->{free})); $threshold_value = $self->{result_values}->{free} if (defined($self->{instance_mode}->{option_results}->{free}));
if ($instance_mode->{option_results}->{units} eq '%') { if ($self->{instance_mode}->{option_results}->{units} eq '%') {
$threshold_value = $self->{result_values}->{prct_used}; $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, $exit = $self->{perfdata}->threshold_check(value => $threshold_value,
threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' },
@ -194,25 +192,17 @@ sub new {
bless $self, $class; bless $self, $class;
$self->{version} = '1.0'; $self->{version} = '1.0';
$options{options}->add_options(arguments => $options{options}->add_options(arguments => {
{ "filter-name:s" => { name => 'filter_name' },
"filter-name:s" => { name => 'filter_name' }, "filter-node:s" => { name => 'filter_node' },
"filter-node:s" => { name => 'filter_node' }, "filter-cluster:s" => { name => 'filter_cluster' },
"filter-cluster:s" => { name => 'filter_cluster' }, "filter-state:s" => { name => 'filter_state' },
"filter-state:s" => { name => 'filter_state' }, "filter-type:s" => { name => 'filter_type' },
"filter-type:s" => { name => 'filter_type' }, "units:s" => { name => 'units', default => '%' },
"units:s" => { name => 'units', default => '%' }, "free" => { name => 'free' },
"free" => { name => 'free' }, });
});
return $self;
}
sub check_options { return $self;
my ($self, %options) = @_;
$self->SUPER::check_options(%options);
$instance_mode = $self;
} }
sub manage_selection { sub manage_selection {

View File

@ -25,8 +25,6 @@ use base qw(centreon::plugins::templates::counter);
use strict; use strict;
use warnings; use warnings;
my $instance_mode;
sub custom_usage_perfdata { sub custom_usage_perfdata {
my ($self, %options) = @_; my ($self, %options) = @_;
@ -46,10 +44,10 @@ sub custom_usage_threshold {
my ($exit, $threshold_value); my ($exit, $threshold_value);
$threshold_value = $self->{result_values}->{used}; $threshold_value = $self->{result_values}->{used};
$threshold_value = $self->{result_values}->{free} if (defined($instance_mode->{option_results}->{free})); $threshold_value = $self->{result_values}->{free} if (defined($self->{instance_mode}->{option_results}->{free}));
if ($instance_mode->{option_results}->{units} eq '%') { if ($self->{instance_mode}->{option_results}->{units} eq '%') {
$threshold_value = $self->{result_values}->{prct_used}; $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, $exit = $self->{perfdata}->threshold_check(value => $threshold_value,
threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' },
@ -122,23 +120,15 @@ sub new {
bless $self, $class; bless $self, $class;
$self->{version} = '1.0'; $self->{version} = '1.0';
$options{options}->add_options(arguments => $options{options}->add_options(arguments => {
{ "filter-name:s" => { name => 'filter_name' },
"filter-name:s" => { name => 'filter_name' }, "units:s" => { name => 'units', default => '%' },
"units:s" => { name => 'units', default => '%' }, "free" => { name => 'free' },
"free" => { name => 'free' }, });
});
return $self; return $self;
} }
sub check_options {
my ($self, %options) = @_;
$self->SUPER::check_options(%options);
$instance_mode = $self;
}
sub manage_selection { sub manage_selection {
my ($self, %options) = @_; my ($self, %options) = @_;

View File

@ -25,8 +25,6 @@ use base qw(centreon::plugins::templates::counter);
use strict; use strict;
use warnings; use warnings;
my $instance_mode;
sub custom_usage_perfdata { sub custom_usage_perfdata {
my ($self, %options) = @_; my ($self, %options) = @_;
@ -46,10 +44,10 @@ sub custom_usage_threshold {
my ($exit, $threshold_value); my ($exit, $threshold_value);
$threshold_value = $self->{result_values}->{used}; $threshold_value = $self->{result_values}->{used};
$threshold_value = $self->{result_values}->{free} if (defined($instance_mode->{option_results}->{free})); $threshold_value = $self->{result_values}->{free} if (defined($self->{instance_mode}->{option_results}->{free}));
if ($instance_mode->{option_results}->{units} eq '%') { if ($self->{instance_mode}->{option_results}->{units} eq '%') {
$threshold_value = $self->{result_values}->{prct_used}; $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, $exit = $self->{perfdata}->threshold_check(value => $threshold_value,
threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' },
@ -156,10 +154,10 @@ sub custom_snapshot_threshold {
my ($exit, $threshold_value); my ($exit, $threshold_value);
$threshold_value = $self->{result_values}->{used}; $threshold_value = $self->{result_values}->{used};
$threshold_value = $self->{result_values}->{free} if (defined($instance_mode->{option_results}->{free})); $threshold_value = $self->{result_values}->{free} if (defined($self->{instance_mode}->{option_results}->{free}));
if ($instance_mode->{option_results}->{units} eq '%') { if ($self->{instance_mode}->{option_results}->{units} eq '%') {
$threshold_value = $self->{result_values}->{prct_used}; $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, $exit = $self->{perfdata}->threshold_check(value => $threshold_value,
threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' },
@ -215,10 +213,10 @@ sub custom_compression_threshold {
my ($exit, $threshold_value); my ($exit, $threshold_value);
$threshold_value = $self->{result_values}->{used}; $threshold_value = $self->{result_values}->{used};
$threshold_value = $self->{result_values}->{free} if (defined($instance_mode->{option_results}->{free})); $threshold_value = $self->{result_values}->{free} if (defined($self->{instance_mode}->{option_results}->{free}));
if ($instance_mode->{option_results}->{units} eq '%') { if ($self->{instance_mode}->{option_results}->{units} eq '%') {
$threshold_value = $self->{result_values}->{prct_used}; $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, $exit = $self->{perfdata}->threshold_check(value => $threshold_value,
threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' },
@ -275,10 +273,10 @@ sub custom_deduplication_threshold {
my ($exit, $threshold_value); my ($exit, $threshold_value);
$threshold_value = $self->{result_values}->{used}; $threshold_value = $self->{result_values}->{used};
$threshold_value = $self->{result_values}->{free} if (defined($instance_mode->{option_results}->{free})); $threshold_value = $self->{result_values}->{free} if (defined($self->{instance_mode}->{option_results}->{free}));
if ($instance_mode->{option_results}->{units} eq '%') { if ($self->{instance_mode}->{option_results}->{units} eq '%') {
$threshold_value = $self->{result_values}->{prct_used}; $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, $exit = $self->{perfdata}->threshold_check(value => $threshold_value,
threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' },
@ -379,26 +377,18 @@ sub new {
bless $self, $class; bless $self, $class;
$self->{version} = '1.0'; $self->{version} = '1.0';
$options{options}->add_options(arguments => $options{options}->add_options(arguments => {
{ "filter-name:s" => { name => 'filter_name' },
"filter-name:s" => { name => 'filter_name' }, "filter-state:s" => { name => 'filter_state' },
"filter-state:s" => { name => 'filter_state' }, "filter-style:s" => { name => 'filter_style' },
"filter-style:s" => { name => 'filter_style' }, "filter-type:s" => { name => 'filter_type' },
"filter-type:s" => { name => 'filter_type' }, "units:s" => { name => 'units', default => '%' },
"units:s" => { name => 'units', default => '%' }, "free" => { name => 'free' },
"free" => { name => 'free' }, });
});
return $self; return $self;
} }
sub check_options {
my ($self, %options) = @_;
$self->SUPER::check_options(%options);
$instance_mode = $self;
}
sub manage_selection { sub manage_selection {
my ($self, %options) = @_; my ($self, %options) = @_;

View File

@ -71,22 +71,20 @@ sub set_counters {
]; ];
} }
my $instance_mode;
sub custom_usage_perfdata { sub custom_usage_perfdata {
my ($self, %options) = @_; my ($self, %options) = @_;
return if ($self->{result_values}->{total} <= 0); return if ($self->{result_values}->{total} <= 0);
my $label = 'used'; my $label = 'used';
my $value_perf = $self->{result_values}->{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'; $label = 'free';
$value_perf = $self->{result_values}->{free}; $value_perf = $self->{result_values}->{free};
} }
my $extra_label = ''; my $extra_label = '';
$extra_label = '_' . $self->{result_values}->{display} if (!defined($options{extra_instance}) || $options{extra_instance} != 0); $extra_label = '_' . $self->{result_values}->{display} if (!defined($options{extra_instance}) || $options{extra_instance} != 0);
my %total_options = (); my %total_options = ();
if ($instance_mode->{option_results}->{units} eq '%') { if ($self->{instance_mode}->{option_results}->{units} eq '%') {
$total_options{total} = $self->{result_values}->{total}; $total_options{total} = $self->{result_values}->{total};
$total_options{cast_int} = 1; $total_options{cast_int} = 1;
} }
@ -104,10 +102,10 @@ sub custom_usage_threshold {
return 'ok' if ($self->{result_values}->{total} <= 0); return 'ok' if ($self->{result_values}->{total} <= 0);
my ($exit, $threshold_value); my ($exit, $threshold_value);
$threshold_value = $self->{result_values}->{used}; $threshold_value = $self->{result_values}->{used};
$threshold_value = $self->{result_values}->{free} if (defined($instance_mode->{option_results}->{free})); $threshold_value = $self->{result_values}->{free} if (defined($self->{instance_mode}->{option_results}->{free}));
if ($instance_mode->{option_results}->{units} eq '%') { if ($self->{instance_mode}->{option_results}->{units} eq '%') {
$threshold_value = $self->{result_values}->{prct_used}; $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' } ]); $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; return $exit;
@ -166,21 +164,14 @@ sub new {
bless $self, $class; bless $self, $class;
$self->{version} = '1.0'; $self->{version} = '1.0';
$options{options}->add_options(arguments => $options{options}->add_options(arguments => {
{ "units:s" => { name => 'units', default => '%' },
"units:s" => { name => 'units', default => '%' }, "free" => { name => 'free' },
"free" => { name => 'free' }, "filter-name:s" => { name => 'filter_name' },
"filter-name:s" => { name => 'filter_name' }, "filter-type:s" => { name => 'filter_type' },
"filter-type:s" => { name => 'filter_type' }, });
});
return $self;
}
sub check_options { return $self;
my ($self, %options) = @_;
$self->SUPER::check_options(%options);
$instance_mode = $self;
} }
my %map_types = ( my %map_types = (

View File

@ -25,8 +25,6 @@ use base qw(centreon::plugins::templates::counter);
use strict; use strict;
use warnings; use warnings;
my $instance_mode;
sub set_counters { sub set_counters {
my ($self, %options) = @_; my ($self, %options) = @_;
@ -51,14 +49,14 @@ sub custom_usage_perfdata {
my $label = 'used'; my $label = 'used';
my $value_perf = $self->{result_values}->{used}; my $value_perf = $self->{result_values}->{used};
if ($self->{result_values}->{total} > 0 && defined($instance_mode->{option_results}->{free})) { if ($self->{result_values}->{total} > 0 && defined($self->{instance_mode}->{option_results}->{free})) {
$label = 'free'; $label = 'free';
$value_perf = $self->{result_values}->{free}; $value_perf = $self->{result_values}->{free};
} }
my $extra_label = ''; my $extra_label = '';
$extra_label = '_' . $self->{result_values}->{name} if (!defined($options{extra_instance}) || $options{extra_instance} != 0); $extra_label = '_' . $self->{result_values}->{name} if (!defined($options{extra_instance}) || $options{extra_instance} != 0);
my %total_options = (); my %total_options = ();
if ($self->{result_values}->{total} > 0 && $instance_mode->{option_results}->{units} eq '%') { if ($self->{result_values}->{total} > 0 && $self->{instance_mode}->{option_results}->{units} eq '%') {
$total_options{total} = $self->{result_values}->{total}; $total_options{total} = $self->{result_values}->{total};
$total_options{cast_int} = 1; $total_options{cast_int} = 1;
} }
@ -74,13 +72,13 @@ sub custom_usage_threshold {
my ($self, %options) = @_; my ($self, %options) = @_;
# cannot use '%' or free option with unlimited system # cannot use '%' or free option with unlimited system
return 'ok' if ($self->{result_values}->{total} <= 0 && ($instance_mode->{option_results}->{units} eq '%' || $instance_mode->{option_results}->{free})); return 'ok' if ($self->{result_values}->{total} <= 0 && ($self->{instance_mode}->{option_results}->{units} eq '%' || $self->{instance_mode}->{option_results}->{free}));
my ($exit, $threshold_value); my ($exit, $threshold_value);
$threshold_value = $self->{result_values}->{used}; $threshold_value = $self->{result_values}->{used};
$threshold_value = $self->{result_values}->{free} if (defined($instance_mode->{option_results}->{free})); $threshold_value = $self->{result_values}->{free} if (defined($self->{instance_mode}->{option_results}->{free}));
if ($instance_mode->{option_results}->{units} eq '%') { if ($self->{instance_mode}->{option_results}->{units} eq '%') {
$threshold_value = $self->{result_values}->{prct_used}; $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' } ]); $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; return $exit;
@ -136,26 +134,18 @@ sub new {
bless $self, $class; bless $self, $class;
$self->{version} = '1.0'; $self->{version} = '1.0';
$options{options}->add_options(arguments => $options{options}->add_options(arguments => {
{ "units:s" => { name => 'units', default => '%' },
"units:s" => { name => 'units', default => '%' }, "free" => { name => 'free' },
"free" => { name => 'free' }, "filter-vserver:s" => { name => 'filter_vserver' },
"filter-vserver:s" => { name => 'filter_vserver' }, "filter-volume:s" => { name => 'filter_volume' },
"filter-volume:s" => { name => 'filter_volume' }, "filter-qtree:s" => { name => 'filter_qtree' },
"filter-qtree:s" => { name => 'filter_qtree' }, "not-kbytes" => { name => 'not_kbytes' },
"not-kbytes" => { name => 'not_kbytes' }, });
});
return $self; return $self;
} }
sub check_options {
my ($self, %options) = @_;
$self->SUPER::check_options(%options);
$instance_mode = $self;
}
my $mapping = { my $mapping = {
qrV2Tree => { oid => '.1.3.6.1.4.1.789.1.4.6.1.14' }, qrV2Tree => { oid => '.1.3.6.1.4.1.789.1.4.6.1.14' },
qrV264KBytesUsed => { oid => '.1.3.6.1.4.1.789.1.4.6.1.25' }, qrV264KBytesUsed => { oid => '.1.3.6.1.4.1.789.1.4.6.1.25' },

View File

@ -25,21 +25,19 @@ use base qw(centreon::plugins::templates::counter);
use strict; use strict;
use warnings; use warnings;
my $instance_mode;
sub custom_usage_perfdata { sub custom_usage_perfdata {
my ($self, %options) = @_; my ($self, %options) = @_;
my $label = $self->{result_values}->{label} . '_used'; my $label = $self->{result_values}->{label} . '_used';
my $value_perf = $self->{result_values}->{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'; $label = $self->{result_values}->{label} . '_free';
$value_perf = $self->{result_values}->{free}; $value_perf = $self->{result_values}->{free};
} }
my $extra_label = ''; my $extra_label = '';
$extra_label = '_' . $self->{result_values}->{display} if (!defined($options{extra_instance}) || $options{extra_instance} != 0); $extra_label = '_' . $self->{result_values}->{display} if (!defined($options{extra_instance}) || $options{extra_instance} != 0);
my %total_options = (); my %total_options = ();
if ($instance_mode->{option_results}->{units} eq '%') { if ($self->{instance_mode}->{option_results}->{units} eq '%') {
$total_options{total} = $self->{result_values}->{total}; $total_options{total} = $self->{result_values}->{total};
$total_options{cast_int} = 1; $total_options{cast_int} = 1;
} }
@ -56,10 +54,10 @@ sub custom_usage_threshold {
my ($exit, $threshold_value); my ($exit, $threshold_value);
$threshold_value = $self->{result_values}->{used}; $threshold_value = $self->{result_values}->{used};
$threshold_value = $self->{result_values}->{free} if (defined($instance_mode->{option_results}->{free})); $threshold_value = $self->{result_values}->{free} if (defined($self->{instance_mode}->{option_results}->{free}));
if ($instance_mode->{option_results}->{units} eq '%') { if ($self->{instance_mode}->{option_results}->{units} eq '%') {
$threshold_value = $self->{result_values}->{prct_used}; $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' } ]); $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; return $exit;
@ -128,24 +126,16 @@ sub new {
bless $self, $class; bless $self, $class;
$self->{version} = '1.0'; $self->{version} = '1.0';
$options{options}->add_options(arguments => $options{options}->add_options(arguments => {
{ "filter-name:s" => { name => 'filter_name' },
"filter-name:s" => { name => 'filter_name' }, "filter-project:s" => { name => 'filter_project' },
"filter-project:s" => { name => 'filter_project' }, "units:s" => { name => 'units', default => '%' },
"units:s" => { name => 'units', default => '%' }, "free" => { name => 'free' },
"free" => { name => 'free' }, });
});
return $self; return $self;
} }
sub check_options {
my ($self, %options) = @_;
$self->SUPER::check_options(%options);
$instance_mode = $self;
}
sub prefix_share_output { sub prefix_share_output {
my ($self, %options) = @_; my ($self, %options) = @_;

View File

@ -25,21 +25,19 @@ use base qw(centreon::plugins::templates::counter);
use strict; use strict;
use warnings; use warnings;
my $instance_mode;
sub custom_usage_perfdata { sub custom_usage_perfdata {
my ($self, %options) = @_; my ($self, %options) = @_;
my $label = 'used'; my $label = 'used';
my $value_perf = $self->{result_values}->{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'; $label = 'free';
$value_perf = $self->{result_values}->{free}; $value_perf = $self->{result_values}->{free};
} }
my $extra_label = ''; my $extra_label = '';
$extra_label = '_' . $self->{result_values}->{display} if (!defined($options{extra_instance}) || $options{extra_instance} != 0); $extra_label = '_' . $self->{result_values}->{display} if (!defined($options{extra_instance}) || $options{extra_instance} != 0);
my %total_options = (); my %total_options = ();
if ($instance_mode->{option_results}->{units} eq '%') { if ($self->{instance_mode}->{option_results}->{units} eq '%') {
$total_options{total} = $self->{result_values}->{total}; $total_options{total} = $self->{result_values}->{total};
$total_options{cast_int} = 1; $total_options{cast_int} = 1;
} }
@ -56,10 +54,10 @@ sub custom_usage_threshold {
my ($exit, $threshold_value); my ($exit, $threshold_value);
$threshold_value = $self->{result_values}->{used}; $threshold_value = $self->{result_values}->{used};
$threshold_value = $self->{result_values}->{free} if (defined($instance_mode->{option_results}->{free})); $threshold_value = $self->{result_values}->{free} if (defined($self->{instance_mode}->{option_results}->{free}));
if ($instance_mode->{option_results}->{units} eq '%') { if ($self->{instance_mode}->{option_results}->{units} eq '%') {
$threshold_value = $self->{result_values}->{prct_used}; $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' } ]); $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; return $exit;
@ -144,23 +142,15 @@ sub new {
bless $self, $class; bless $self, $class;
$self->{version} = '1.0'; $self->{version} = '1.0';
$options{options}->add_options(arguments => $options{options}->add_options(arguments => {
{ "filter-name:s" => { name => 'filter_name' },
"filter-name:s" => { name => 'filter_name' }, "units:s" => { name => 'units', default => '%' },
"units:s" => { name => 'units', default => '%' }, "free" => { name => 'free' },
"free" => { name => 'free' }, });
});
return $self; return $self;
} }
sub check_options {
my ($self, %options) = @_;
$self->SUPER::check_options(%options);
$instance_mode = $self;
}
sub prefix_volume_output { sub prefix_volume_output {
my ($self, %options) = @_; my ($self, %options) = @_;

View File

@ -25,8 +25,6 @@ use base qw(centreon::plugins::templates::counter);
use strict; use strict;
use warnings; use warnings;
my $instance_mode;
sub custom_usage_perfdata { sub custom_usage_perfdata {
my ($self, %options) = @_; my ($self, %options) = @_;
@ -43,10 +41,10 @@ sub custom_usage_threshold {
my ($exit, $threshold_value); my ($exit, $threshold_value);
$threshold_value = $self->{result_values}->{used}; $threshold_value = $self->{result_values}->{used};
$threshold_value = $self->{result_values}->{free} if (defined($instance_mode->{option_results}->{free})); $threshold_value = $self->{result_values}->{free} if (defined($self->{instance_mode}->{option_results}->{free}));
if ($instance_mode->{option_results}->{units} eq '%') { if ($self->{instance_mode}->{option_results}->{units} eq '%') {
$threshold_value = $self->{result_values}->{prct_used}; $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, $exit = $self->{perfdata}->threshold_check(value => $threshold_value,
threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' },
@ -71,8 +69,8 @@ sub custom_usage_output {
sub custom_usage_calc { sub custom_usage_calc {
my ($self, %options) = @_; my ($self, %options) = @_;
$self->{result_values}->{total} = $instance_mode->convert_to_bytes(raw_value => $options{new_datas}->{$self->{instance} . '_disk_capacity'}); $self->{result_values}->{total} = $self->{instance_mode}->convert_to_bytes(raw_value => $options{new_datas}->{$self->{instance} . '_disk_capacity'});
$self->{result_values}->{used} = $instance_mode->convert_to_bytes(raw_value => $options{new_datas}->{$self->{instance} . '_used_disk_space'}); $self->{result_values}->{used} = $self->{instance_mode}->convert_to_bytes(raw_value => $options{new_datas}->{$self->{instance} . '_used_disk_space'});
if ($self->{result_values}->{total} != 0) { if ($self->{result_values}->{total} != 0) {
$self->{result_values}->{free} = $self->{result_values}->{total} - $self->{result_values}->{used}; $self->{result_values}->{free} = $self->{result_values}->{total} - $self->{result_values}->{used};
@ -116,8 +114,8 @@ sub custom_volume_output {
sub custom_volume_calc { sub custom_volume_calc {
my ($self, %options) = @_; my ($self, %options) = @_;
$self->{result_values}->{volume} = $instance_mode->convert_to_bytes(raw_value => $options{new_datas}->{$self->{instance} . '_' . $options{extra_options}->{label_ref}}); $self->{result_values}->{volume} = $self->{instance_mode}->convert_to_bytes(raw_value => $options{new_datas}->{$self->{instance} . '_' . $options{extra_options}->{label_ref}});
$self->{result_values}->{total} = $instance_mode->convert_to_bytes(raw_value => $options{new_datas}->{$self->{instance} . '_disk_capacity'}); $self->{result_values}->{total} = $self->{instance_mode}->convert_to_bytes(raw_value => $options{new_datas}->{$self->{instance} . '_disk_capacity'});
$self->{result_values}->{display} = $options{extra_options}->{display_ref}; $self->{result_values}->{display} = $options{extra_options}->{display_ref};
$self->{result_values}->{label} = $options{extra_options}->{label_ref}; $self->{result_values}->{label} = $options{extra_options}->{label_ref};
@ -219,20 +217,19 @@ sub new {
bless $self, $class; bless $self, $class;
$self->{version} = '1.0'; $self->{version} = '1.0';
$options{options}->add_options(arguments => $options{options}->add_options(arguments => {
{ "hostname:s" => { name => 'hostname' },
"hostname:s" => { name => 'hostname' }, "ssh-option:s@" => { name => 'ssh_option' },
"ssh-option:s@" => { name => 'ssh_option' }, "ssh-path:s" => { name => 'ssh_path' },
"ssh-path:s" => { name => 'ssh_path' }, "ssh-command:s" => { name => 'ssh_command', default => 'ssh' },
"ssh-command:s" => { name => 'ssh_command', default => 'ssh' }, "timeout:s" => { name => 'timeout', default => 30 },
"timeout:s" => { name => 'timeout', default => 30 }, "sudo" => { name => 'sudo' },
"sudo" => { name => 'sudo' }, "command:s" => { name => 'command', default => 'syscli' },
"command:s" => { name => 'command', default => 'syscli' }, "command-path:s" => { name => 'command_path' },
"command-path:s" => { name => 'command_path' }, "command-options:s" => { name => 'command_options', default => '--get diskusage' },
"command-options:s" => { name => 'command_options', default => '--get diskusage' }, "units:s" => { name => 'units', default => '%' },
"units:s" => { name => 'units', default => '%' }, "free" => { name => 'free' },
"free" => { name => 'free' }, });
});
return $self; return $self;
} }
@ -243,9 +240,7 @@ sub check_options {
if (defined($self->{option_results}->{hostname}) && $self->{option_results}->{hostname} ne '') { if (defined($self->{option_results}->{hostname}) && $self->{option_results}->{hostname} ne '') {
$self->{option_results}->{remote} = 1; $self->{option_results}->{remote} = 1;
} }
$instance_mode = $self;
} }
sub manage_selection { sub manage_selection {

View File

@ -25,8 +25,6 @@ use base qw(centreon::plugins::templates::counter);
use strict; use strict;
use warnings; use warnings;
my $instance_mode;
sub custom_usage_perfdata { sub custom_usage_perfdata {
my ($self, %options) = @_; my ($self, %options) = @_;
@ -43,10 +41,10 @@ sub custom_usage_threshold {
my ($exit, $threshold_value); my ($exit, $threshold_value);
$threshold_value = $self->{result_values}->{used}; $threshold_value = $self->{result_values}->{used};
$threshold_value = $self->{result_values}->{free} if (defined($instance_mode->{option_results}->{free})); $threshold_value = $self->{result_values}->{free} if (defined($self->{instance_mode}->{option_results}->{free}));
if ($instance_mode->{option_results}->{units} eq '%') { if ($self->{instance_mode}->{option_results}->{units} eq '%') {
$threshold_value = $self->{result_values}->{prct_used}; $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, $exit = $self->{perfdata}->threshold_check(value => $threshold_value,
threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' },
@ -71,8 +69,8 @@ sub custom_usage_output {
sub custom_usage_calc { sub custom_usage_calc {
my ($self, %options) = @_; my ($self, %options) = @_;
$self->{result_values}->{total} = $instance_mode->convert_to_bytes(raw_value => $options{new_datas}->{$self->{instance} . '_total'}); $self->{result_values}->{total} = $self->{instance_mode}->convert_to_bytes(raw_value => $options{new_datas}->{$self->{instance} . '_total'});
$self->{result_values}->{free} = $instance_mode->convert_to_bytes(raw_value => $options{new_datas}->{$self->{instance} . '_free'}); $self->{result_values}->{free} = $self->{instance_mode}->convert_to_bytes(raw_value => $options{new_datas}->{$self->{instance} . '_free'});
if ($self->{result_values}->{total} != 0) { if ($self->{result_values}->{total} != 0) {
$self->{result_values}->{used} = $self->{result_values}->{total} - $self->{result_values}->{free}; $self->{result_values}->{used} = $self->{result_values}->{total} - $self->{result_values}->{free};
@ -129,20 +127,19 @@ sub new {
bless $self, $class; bless $self, $class;
$self->{version} = '1.0'; $self->{version} = '1.0';
$options{options}->add_options(arguments => $options{options}->add_options(arguments => {
{ "hostname:s" => { name => 'hostname' },
"hostname:s" => { name => 'hostname' }, "ssh-option:s@" => { name => 'ssh_option' },
"ssh-option:s@" => { name => 'ssh_option' }, "ssh-path:s" => { name => 'ssh_path' },
"ssh-path:s" => { name => 'ssh_path' }, "ssh-command:s" => { name => 'ssh_command', default => 'ssh' },
"ssh-command:s" => { name => 'ssh_command', default => 'ssh' }, "timeout:s" => { name => 'timeout', default => 30 },
"timeout:s" => { name => 'timeout', default => 30 }, "sudo" => { name => 'sudo' },
"sudo" => { name => 'sudo' }, "command:s" => { name => 'command', default => 'syscli' },
"command:s" => { name => 'command', default => 'syscli' }, "command-path:s" => { name => 'command_path' },
"command-path:s" => { name => 'command_path' }, "command-options:s" => { name => 'command_options', default => '--getstatus systemmemory' },
"command-options:s" => { name => 'command_options', default => '--getstatus systemmemory' }, "units:s" => { name => 'units', default => '%' },
"units:s" => { name => 'units', default => '%' }, "free" => { name => 'free' },
"free" => { name => 'free' }, });
});
return $self; return $self;
} }
@ -153,9 +150,7 @@ sub check_options {
if (defined($self->{option_results}->{hostname}) && $self->{option_results}->{hostname} ne '') { if (defined($self->{option_results}->{hostname}) && $self->{option_results}->{hostname} ne '') {
$self->{option_results}->{remote} = 1; $self->{option_results}->{remote} = 1;
} }
$instance_mode = $self;
} }
sub manage_selection { sub manage_selection {

View File

@ -25,8 +25,6 @@ use base qw(centreon::plugins::templates::counter);
use strict; use strict;
use warnings; use warnings;
my $instance_mode;
sub custom_volume_perfdata { sub custom_volume_perfdata {
my ($self, %options) = @_; my ($self, %options) = @_;
@ -56,7 +54,7 @@ sub custom_volume_output {
sub custom_volume_calc { sub custom_volume_calc {
my ($self, %options) = @_; my ($self, %options) = @_;
$self->{result_values}->{volume} = $instance_mode->convert_to_bytes(raw_value => $options{new_datas}->{$self->{instance} . '_' . $options{extra_options}->{label_ref}}); $self->{result_values}->{volume} = $self->{instance_mode}->convert_to_bytes(raw_value => $options{new_datas}->{$self->{instance} . '_' . $options{extra_options}->{label_ref}});
$self->{result_values}->{display} = $options{extra_options}->{display_ref}; $self->{result_values}->{display} = $options{extra_options}->{display_ref};
$self->{result_values}->{label} = $options{extra_options}->{label_ref}; $self->{result_values}->{label} = $options{extra_options}->{label_ref};
@ -196,18 +194,17 @@ sub new {
bless $self, $class; bless $self, $class;
$self->{version} = '1.0'; $self->{version} = '1.0';
$options{options}->add_options(arguments => $options{options}->add_options(arguments => {
{ "hostname:s" => { name => 'hostname' },
"hostname:s" => { name => 'hostname' }, "ssh-option:s@" => { name => 'ssh_option' },
"ssh-option:s@" => { name => 'ssh_option' }, "ssh-path:s" => { name => 'ssh_path' },
"ssh-path:s" => { name => 'ssh_path' }, "ssh-command:s" => { name => 'ssh_command', default => 'ssh' },
"ssh-command:s" => { name => 'ssh_command', default => 'ssh' }, "timeout:s" => { name => 'timeout', default => 30 },
"timeout:s" => { name => 'timeout', default => 30 }, "sudo" => { name => 'sudo' },
"sudo" => { name => 'sudo' }, "command:s" => { name => 'command', default => 'syscli' },
"command:s" => { name => 'command', default => 'syscli' }, "command-path:s" => { name => 'command_path' },
"command-path:s" => { name => 'command_path' }, "command-options:s" => { name => 'command_options', default => '--get datareductionstat' },
"command-options:s" => { name => 'command_options', default => '--get datareductionstat' }, });
});
return $self; return $self;
} }
@ -218,9 +215,7 @@ sub check_options {
if (defined($self->{option_results}->{hostname}) && $self->{option_results}->{hostname} ne '') { if (defined($self->{option_results}->{hostname}) && $self->{option_results}->{hostname} ne '') {
$self->{option_results}->{remote} = 1; $self->{option_results}->{remote} = 1;
} }
$instance_mode = $self;
} }
sub manage_selection { sub manage_selection {

View File

@ -25,8 +25,6 @@ use base qw(centreon::plugins::templates::counter);
use strict; use strict;
use warnings; use warnings;
my $instance_mode;
sub custom_volume_perfdata { sub custom_volume_perfdata {
my ($self, %options) = @_; my ($self, %options) = @_;
@ -56,7 +54,7 @@ sub custom_volume_output {
sub custom_volume_calc { sub custom_volume_calc {
my ($self, %options) = @_; my ($self, %options) = @_;
$self->{result_values}->{volume} = $instance_mode->convert_to_bytes(raw_value => $options{new_datas}->{$self->{instance} . '_' . $options{extra_options}->{label_ref}}); $self->{result_values}->{volume} = $self->{instance_mode}->convert_to_bytes(raw_value => $options{new_datas}->{$self->{instance} . '_' . $options{extra_options}->{label_ref}});
$self->{result_values}->{display} = $options{extra_options}->{display_ref}; $self->{result_values}->{display} = $options{extra_options}->{display_ref};
$self->{result_values}->{label} = $options{extra_options}->{label_ref}; $self->{result_values}->{label} = $options{extra_options}->{label_ref};
@ -115,18 +113,17 @@ sub new {
bless $self, $class; bless $self, $class;
$self->{version} = '1.0'; $self->{version} = '1.0';
$options{options}->add_options(arguments => $options{options}->add_options(arguments => {
{ "hostname:s" => { name => 'hostname' },
"hostname:s" => { name => 'hostname' }, "ssh-option:s@" => { name => 'ssh_option' },
"ssh-option:s@" => { name => 'ssh_option' }, "ssh-path:s" => { name => 'ssh_path' },
"ssh-path:s" => { name => 'ssh_path' }, "ssh-command:s" => { name => 'ssh_command', default => 'ssh' },
"ssh-command:s" => { name => 'ssh_command', default => 'ssh' }, "timeout:s" => { name => 'timeout', default => 30 },
"timeout:s" => { name => 'timeout', default => 30 }, "sudo" => { name => 'sudo' },
"sudo" => { name => 'sudo' }, "command:s" => { name => 'command', default => 'syscli' },
"command:s" => { name => 'command', default => 'syscli' }, "command-path:s" => { name => 'command_path' },
"command-path:s" => { name => 'command_path' }, "command-options:s" => { name => 'command_options', default => '--get ingestrate' },
"command-options:s" => { name => 'command_options', default => '--get ingestrate' }, });
});
return $self; return $self;
} }
@ -138,8 +135,6 @@ sub check_options {
if (defined($self->{option_results}->{hostname}) && $self->{option_results}->{hostname} ne '') { if (defined($self->{option_results}->{hostname}) && $self->{option_results}->{hostname} ne '') {
$self->{option_results}->{remote} = 1; $self->{option_results}->{remote} = 1;
} }
$instance_mode = $self;
} }
sub manage_selection { sub manage_selection {