cleaning code (WIP)

This commit is contained in:
garnier-quentin 2019-03-26 16:49:07 +01:00
parent 4b2018384e
commit fbd17e4be4
24 changed files with 306 additions and 454 deletions

View File

@ -25,13 +25,11 @@ use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
my $instance_mode;
sub custom_compliance_perfdata {
my ($self, %options) = @_;
my %total_options = ();
if ($instance_mode->{option_results}->{units} eq '%') {
if ($self->{instance_mode}->{option_results}->{units} eq '%') {
$total_options{total} = $self->{result_values}->{total};
$total_options{cast_int} = 1;
}
@ -47,7 +45,7 @@ sub custom_compliance_threshold {
my ($self, %options) = @_;
my $threshold_value = $self->{result_values}->{count};
if ($instance_mode->{option_results}->{units} eq '%') {
if ($self->{instance_mode}->{option_results}->{units} eq '%') {
$threshold_value = $self->{result_values}->{prct_count};
}
my $exit = $self->{perfdata}->threshold_check(value => $threshold_value,
@ -146,13 +144,6 @@ sub new {
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::check_options(%options);
$instance_mode = $self;
}
sub manage_selection {
my ($self, %options) = @_;

View File

@ -25,8 +25,6 @@ use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
my $instance_mode;
sub prefix_metric_output {
my ($self, %options) = @_;
@ -48,7 +46,7 @@ sub custom_metric_calc {
sub custom_metric_threshold {
my ($self, %options) = @_;
my $exit = $self->{perfdata}->threshold_check(value => defined($instance_mode->{option_results}->{per_sec}) ? $self->{result_values}->{value_per_sec} : $self->{result_values}->{value},
my $exit = $self->{perfdata}->threshold_check(value => defined($self->{instance_mode}->{option_results}->{per_sec}) ? $self->{result_values}->{value_per_sec} : $self->{result_values}->{value},
threshold => [ { label => 'critical-' . lc($self->{result_values}->{metric}) . "-" . lc($self->{result_values}->{stat}), exit_litteral => 'critical' },
{ label => 'warning-' . lc($self->{result_values}->{metric}) . "-" . lc($self->{result_values}->{stat}), exit_litteral => 'warning' } ]);
return $exit;
@ -61,8 +59,8 @@ sub custom_metric_perfdata {
$extra_label = '_' . lc($self->{result_values}->{display}) if (!defined($options{extra_instance}) || $options{extra_instance} != 0);
$self->{output}->perfdata_add(label => lc($self->{result_values}->{metric}) . "_" . lc($self->{result_values}->{stat}) . $extra_label,
unit => defined($instance_mode->{option_results}->{per_sec}) ? 'requests/s' : 'requests',
value => sprintf("%.2f", defined($instance_mode->{option_results}->{per_sec}) ? $self->{result_values}->{value_per_sec} : $self->{result_values}->{value}),
unit => defined($self->{instance_mode}->{option_results}->{per_sec}) ? 'requests/s' : 'requests',
value => sprintf("%.2f", defined($self->{instance_mode}->{option_results}->{per_sec}) ? $self->{result_values}->{value_per_sec} : $self->{result_values}->{value}),
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . lc($self->{result_values}->{metric}) . "-" . lc($self->{result_values}->{stat})),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . lc($self->{result_values}->{metric}) . "-" . lc($self->{result_values}->{stat})),
);
@ -72,7 +70,7 @@ sub custom_metric_output {
my ($self, %options) = @_;
my $msg = "";
if (defined($instance_mode->{option_results}->{per_sec})) {
if (defined($self->{instance_mode}->{option_results}->{per_sec})) {
my ($value, $unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{value_per_sec});
$msg = $self->{result_values}->{metric} . ": " . $value . "requests/s";
} else {
@ -111,12 +109,11 @@ sub new {
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
"id:s@" => { name => 'id' },
"per-sec" => { name => 'per_sec' },
});
$options{options}->add_options(arguments => {
"id:s@" => { name => 'id' },
"per-sec" => { name => 'per_sec' },
});
return $self;
}
@ -148,9 +145,7 @@ sub check_options {
}
}
push @{$self->{aws_metrics}}, 'Requests';
$instance_mode = $self;
push @{$self->{aws_metrics}}, 'Requests';
}
sub manage_selection {

View File

@ -25,8 +25,6 @@ use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
my $instance_mode;
sub prefix_metric_output {
my ($self, %options) = @_;
@ -48,7 +46,7 @@ sub custom_metric_calc {
sub custom_metric_threshold {
my ($self, %options) = @_;
my $exit = $self->{perfdata}->threshold_check(value => defined($instance_mode->{option_results}->{per_sec}) ? $self->{result_values}->{value_per_sec} : $self->{result_values}->{value},
my $exit = $self->{perfdata}->threshold_check(value => defined($self->{instance_mode}->{option_results}->{per_sec}) ? $self->{result_values}->{value_per_sec} : $self->{result_values}->{value},
threshold => [ { label => 'critical-' . lc($self->{result_values}->{metric}) . "-" . lc($self->{result_values}->{stat}), exit_litteral => 'critical' },
{ label => 'warning-' . lc($self->{result_values}->{metric}) . "-" . lc($self->{result_values}->{stat}), exit_litteral => 'warning' } ]);
return $exit;
@ -61,8 +59,8 @@ sub custom_metric_perfdata {
$extra_label = '_' . lc($self->{result_values}->{display}) if (!defined($options{extra_instance}) || $options{extra_instance} != 0);
$self->{output}->perfdata_add(label => lc($self->{result_values}->{metric}) . "_" . lc($self->{result_values}->{stat}) . $extra_label,
unit => defined($instance_mode->{option_results}->{per_sec}) ? 'B/s' : 'B',
value => sprintf("%.2f", defined($instance_mode->{option_results}->{per_sec}) ? $self->{result_values}->{value_per_sec} : $self->{result_values}->{value}),
unit => defined($self->{instance_mode}->{option_results}->{per_sec}) ? 'B/s' : 'B',
value => sprintf("%.2f", defined($self->{instance_mode}->{option_results}->{per_sec}) ? $self->{result_values}->{value_per_sec} : $self->{result_values}->{value}),
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . lc($self->{result_values}->{metric}) . "-" . lc($self->{result_values}->{stat})),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . lc($self->{result_values}->{metric}) . "-" . lc($self->{result_values}->{stat})),
);
@ -72,7 +70,7 @@ sub custom_metric_output {
my ($self, %options) = @_;
my $msg = "";
if (defined($instance_mode->{option_results}->{per_sec})) {
if (defined($self->{instance_mode}->{option_results}->{per_sec})) {
my ($value, $unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{value_per_sec});
$msg = $self->{result_values}->{metric} . ": " . $value . $unit . "/s";
} else {
@ -111,13 +109,12 @@ sub new {
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
"id:s@" => { name => 'id' },
"filter-metric:s" => { name => 'filter_metric' },
"per-sec" => { name => 'per_sec' },
});
$options{options}->add_options(arguments => {
"id:s@" => { name => 'id' },
"filter-metric:s" => { name => 'filter_metric' },
"per-sec" => { name => 'per_sec' },
});
return $self;
}
@ -155,8 +152,6 @@ sub check_options {
push @{$self->{aws_metrics}}, $metric;
}
$instance_mode = $self;
}
sub manage_selection {

View File

@ -30,8 +30,6 @@ my %map_type = (
"asg" => "AutoScalingGroupName",
);
my $instance_mode;
sub prefix_metric_output {
my ($self, %options) = @_;
@ -53,7 +51,7 @@ sub custom_metric_calc {
sub custom_metric_threshold {
my ($self, %options) = @_;
my $exit = $self->{perfdata}->threshold_check(value => defined($instance_mode->{option_results}->{per_sec}) ? $self->{result_values}->{value_per_sec} : $self->{result_values}->{value},
my $exit = $self->{perfdata}->threshold_check(value => defined($self->{instance_mode}->{option_results}->{per_sec}) ? $self->{result_values}->{value_per_sec} : $self->{result_values}->{value},
threshold => [ { label => 'critical-' . lc($self->{result_values}->{metric}) . "-" . lc($self->{result_values}->{stat}), exit_litteral => 'critical' },
{ label => 'warning-' . lc($self->{result_values}->{metric}) . "-" . lc($self->{result_values}->{stat}), exit_litteral => 'warning' } ]);
return $exit;
@ -66,8 +64,8 @@ sub custom_usage_perfdata {
$extra_label = '_' . lc($self->{result_values}->{display}) if (!defined($options{extra_instance}) || $options{extra_instance} != 0);
$self->{output}->perfdata_add(label => lc($self->{result_values}->{metric}) . "_" . lc($self->{result_values}->{stat}) . $extra_label,
unit => defined($instance_mode->{option_results}->{per_sec}) ? 'B/s' : 'B',
value => sprintf("%.2f", defined($instance_mode->{option_results}->{per_sec}) ? $self->{result_values}->{value_per_sec} : $self->{result_values}->{value}),
unit => defined($self->{instance_mode}->{option_results}->{per_sec}) ? 'B/s' : 'B',
value => sprintf("%.2f", defined($self->{instance_mode}->{option_results}->{per_sec}) ? $self->{result_values}->{value_per_sec} : $self->{result_values}->{value}),
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . lc($self->{result_values}->{metric}) . "-" . lc($self->{result_values}->{stat})),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . lc($self->{result_values}->{metric}) . "-" . lc($self->{result_values}->{stat})),
);
@ -77,7 +75,7 @@ sub custom_usage_output {
my ($self, %options) = @_;
my $msg = "";
if (defined($instance_mode->{option_results}->{per_sec})) {
if (defined($self->{instance_mode}->{option_results}->{per_sec})) {
my ($value, $unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{value_per_sec});
$msg = $self->{result_values}->{metric} . ": " . $value . $unit . "/s";
} else {
@ -94,8 +92,8 @@ sub custom_ops_perfdata {
$extra_label = '_' . lc($self->{result_values}->{display}) if (!defined($options{extra_instance}) || $options{extra_instance} != 0);
$self->{output}->perfdata_add(label => lc($self->{result_values}->{metric}) . "_" . lc($self->{result_values}->{stat}) . $extra_label,
unit => defined($instance_mode->{option_results}->{per_sec}) ? 'ops/s' : 'ops',
value => sprintf("%.2f", defined($instance_mode->{option_results}->{per_sec}) ? $self->{result_values}->{value_per_sec} : $self->{result_values}->{value}),
unit => defined($self->{instance_mode}->{option_results}->{per_sec}) ? 'ops/s' : 'ops',
value => sprintf("%.2f", defined($self->{instance_mode}->{option_results}->{per_sec}) ? $self->{result_values}->{value_per_sec} : $self->{result_values}->{value}),
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . lc($self->{result_values}->{metric}) . "-" . lc($self->{result_values}->{stat})),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . lc($self->{result_values}->{metric}) . "-" . lc($self->{result_values}->{stat})),
);
@ -106,7 +104,7 @@ sub custom_ops_output {
my $msg ="";
if (defined($instance_mode->{option_results}->{per_sec})) {
if (defined($self->{instance_mode}->{option_results}->{per_sec})) {
$msg = sprintf("%s: %.2f ops/s", $self->{result_values}->{metric}, $self->{result_values}->{value_per_sec});
} else {
$msg = sprintf("%s: %.2f ops", $self->{result_values}->{metric}, $self->{result_values}->{value});
@ -156,14 +154,13 @@ sub new {
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
"type:s" => { name => 'type' },
"name:s@" => { name => 'name' },
"filter-metric:s" => { name => 'filter_metric' },
"per-sec" => { name => 'per_sec' },
});
$options{options}->add_options(arguments => {
"type:s" => { name => 'type' },
"name:s@" => { name => 'name' },
"filter-metric:s" => { name => 'filter_metric' },
"per-sec" => { name => 'per_sec' },
});
return $self;
}
@ -211,8 +208,6 @@ sub check_options {
push @{$self->{aws_metrics}}, $metric;
}
$instance_mode = $self;
}
sub manage_selection {

View File

@ -30,8 +30,6 @@ my %map_type = (
"asg" => "AutoScalingGroupName",
);
my $instance_mode;
sub prefix_metric_output {
my ($self, %options) = @_;
@ -53,7 +51,7 @@ sub custom_metric_calc {
sub custom_metric_threshold {
my ($self, %options) = @_;
my $exit = $self->{perfdata}->threshold_check(value => defined($instance_mode->{option_results}->{per_sec}) ? $self->{result_values}->{value_per_sec} : $self->{result_values}->{value},
my $exit = $self->{perfdata}->threshold_check(value => defined($self->{instance_mode}->{option_results}->{per_sec}) ? $self->{result_values}->{value_per_sec} : $self->{result_values}->{value},
threshold => [ { label => 'critical-' . lc($self->{result_values}->{metric}) . "-" . lc($self->{result_values}->{stat}), exit_litteral => 'critical' },
{ label => 'warning-' . lc($self->{result_values}->{metric}) . "-" . lc($self->{result_values}->{stat}), exit_litteral => 'warning' } ]);
return $exit;
@ -66,8 +64,8 @@ sub custom_traffic_perfdata {
$extra_label = '_' . lc($self->{result_values}->{display}) if (!defined($options{extra_instance}) || $options{extra_instance} != 0);
$self->{output}->perfdata_add(label => lc($self->{result_values}->{metric}) . "_" . lc($self->{result_values}->{stat}) . $extra_label,
unit => defined($instance_mode->{option_results}->{per_sec}) ? 'B/s' : 'B',
value => sprintf("%.2f", defined($instance_mode->{option_results}->{per_sec}) ? $self->{result_values}->{value_per_sec} : $self->{result_values}->{value}),
unit => defined($self->{instance_mode}->{option_results}->{per_sec}) ? 'B/s' : 'B',
value => sprintf("%.2f", defined($self->{instance_mode}->{option_results}->{per_sec}) ? $self->{result_values}->{value_per_sec} : $self->{result_values}->{value}),
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . lc($self->{result_values}->{metric}) . "-" . lc($self->{result_values}->{stat})),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . lc($self->{result_values}->{metric}) . "-" . lc($self->{result_values}->{stat})),
);
@ -77,7 +75,7 @@ sub custom_traffic_output {
my ($self, %options) = @_;
my $msg = "";
if (defined($instance_mode->{option_results}->{per_sec})) {
if (defined($self->{instance_mode}->{option_results}->{per_sec})) {
my ($value, $unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{value_per_sec});
$msg = $self->{result_values}->{metric} . ": " . $value . $unit . "/s";
} else {
@ -94,8 +92,8 @@ sub custom_packets_perfdata {
$extra_label = '_' . lc($self->{result_values}->{display}) if (!defined($options{extra_instance}) || $options{extra_instance} != 0);
$self->{output}->perfdata_add(label => lc($self->{result_values}->{metric}) . "_" . lc($self->{result_values}->{stat}) . $extra_label,
unit => defined($instance_mode->{option_results}->{per_sec}) ? 'packets/s' : 'packets',
value => sprintf("%.2f", defined($instance_mode->{option_results}->{per_sec}) ? $self->{result_values}->{value_per_sec} : $self->{result_values}->{value}),
unit => defined($self->{instance_mode}->{option_results}->{per_sec}) ? 'packets/s' : 'packets',
value => sprintf("%.2f", defined($self->{instance_mode}->{option_results}->{per_sec}) ? $self->{result_values}->{value_per_sec} : $self->{result_values}->{value}),
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . lc($self->{result_values}->{metric}) . "-" . lc($self->{result_values}->{stat})),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . lc($self->{result_values}->{metric}) . "-" . lc($self->{result_values}->{stat})),
);
@ -106,7 +104,7 @@ sub custom_packets_output {
my $msg ="";
if (defined($instance_mode->{option_results}->{per_sec})) {
if (defined($self->{instance_mode}->{option_results}->{per_sec})) {
$msg = sprintf("%s: %.2f packets/s", $self->{result_values}->{metric}, $self->{result_values}->{value_per_sec});
} else {
$msg = sprintf("%s: %.2f packets", $self->{result_values}->{metric}, $self->{result_values}->{value});
@ -156,14 +154,13 @@ sub new {
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
"type:s" => { name => 'type' },
"name:s@" => { name => 'name' },
"filter-metric:s" => { name => 'filter_metric' },
"per-sec" => { name => 'per_sec' },
});
$options{options}->add_options(arguments => {
"type:s" => { name => 'type' },
"name:s@" => { name => 'name' },
"filter-metric:s" => { name => 'filter_metric' },
"per-sec" => { name => 'per_sec' },
});
return $self;
}
@ -211,8 +208,6 @@ sub check_options {
push @{$self->{aws_metrics}}, $metric;
}
$instance_mode = $self;
}
sub manage_selection {

View File

@ -25,8 +25,6 @@ use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
my $instance_mode;
sub prefix_metric_output {
my ($self, %options) = @_;
@ -53,7 +51,7 @@ sub custom_metric_calc {
sub custom_metric_threshold {
my ($self, %options) = @_;
my $exit = $self->{perfdata}->threshold_check(value => defined($instance_mode->{option_results}->{per_sec}) ? $self->{result_values}->{value_per_sec} : $self->{result_values}->{value},
my $exit = $self->{perfdata}->threshold_check(value => defined($self->{instance_mode}->{option_results}->{per_sec}) ? $self->{result_values}->{value_per_sec} : $self->{result_values}->{value},
threshold => [ { label => 'critical-' . lc($self->{result_values}->{metric}) . "-" . lc($self->{result_values}->{stat}), exit_litteral => 'critical' },
{ label => 'warning-' . lc($self->{result_values}->{metric}) . "-" . lc($self->{result_values}->{stat}), exit_litteral => 'warning' } ]);
return $exit;
@ -66,8 +64,8 @@ sub custom_metric_perfdata {
$extra_label = '_' . lc($self->{result_values}->{display}) if (!defined($options{extra_instance}) || $options{extra_instance} != 0);
$self->{output}->perfdata_add(label => lc($self->{result_values}->{metric}) . "_" . lc($self->{result_values}->{stat}) . $extra_label,
unit => defined($instance_mode->{option_results}->{per_sec}) ? 'cmd/s' : 'cmd',
value => sprintf("%.2f", defined($instance_mode->{option_results}->{per_sec}) ? $self->{result_values}->{value_per_sec} : $self->{result_values}->{value}),
unit => defined($self->{instance_mode}->{option_results}->{per_sec}) ? 'cmd/s' : 'cmd',
value => sprintf("%.2f", defined($self->{instance_mode}->{option_results}->{per_sec}) ? $self->{result_values}->{value_per_sec} : $self->{result_values}->{value}),
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . lc($self->{result_values}->{metric}) . "-" . lc($self->{result_values}->{stat})),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . lc($self->{result_values}->{metric}) . "-" . lc($self->{result_values}->{stat})),
);
@ -77,7 +75,7 @@ sub custom_metric_output {
my ($self, %options) = @_;
my $msg = "";
if (defined($instance_mode->{option_results}->{per_sec})) {
if (defined($self->{instance_mode}->{option_results}->{per_sec})) {
$msg = sprintf("%s: %.2f cmd/s", $self->{result_values}->{metric}, $self->{result_values}->{value_per_sec});
} else {
$msg = sprintf("%s: %.2f cmd", $self->{result_values}->{metric}, $self->{result_values}->{value});
@ -114,14 +112,13 @@ sub new {
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
"name:s@" => { name => 'name' },
"node-id:s" => { name => 'node_id' },
"filter-metric:s" => { name => 'filter_metric' },
"per-sec" => { name => 'per_sec' },
});
$options{options}->add_options(arguments => {
"name:s@" => { name => 'name' },
"node-id:s" => { name => 'node_id' },
"filter-metric:s" => { name => 'filter_metric' },
"per-sec" => { name => 'per_sec' },
});
return $self;
}
@ -159,8 +156,6 @@ sub check_options {
push @{$self->{aws_metrics}}, $metric;
}
$instance_mode = $self;
}
sub manage_selection {

View File

@ -25,8 +25,6 @@ use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
my $instance_mode;
sub prefix_metric_output {
my ($self, %options) = @_;
@ -53,7 +51,7 @@ sub custom_metric_calc {
sub custom_metric_threshold {
my ($self, %options) = @_;
my $exit = $self->{perfdata}->threshold_check(value => defined($instance_mode->{option_results}->{per_sec}) ? $self->{result_values}->{value_per_sec} : $self->{result_values}->{value},
my $exit = $self->{perfdata}->threshold_check(value => defined($self->{instance_mode}->{option_results}->{per_sec}) ? $self->{result_values}->{value_per_sec} : $self->{result_values}->{value},
threshold => [ { label => 'critical-' . lc($self->{result_values}->{metric}) . "-" . lc($self->{result_values}->{stat}), exit_litteral => 'critical' },
{ label => 'warning-' . lc($self->{result_values}->{metric}) . "-" . lc($self->{result_values}->{stat}), exit_litteral => 'warning' } ]);
return $exit;
@ -66,8 +64,8 @@ sub custom_metric_perfdata {
$extra_label = '_' . lc($self->{result_values}->{display}) if (!defined($options{extra_instance}) || $options{extra_instance} != 0);
$self->{output}->perfdata_add(label => lc($self->{result_values}->{metric}) . "_" . lc($self->{result_values}->{stat}) . $extra_label,
unit => defined($instance_mode->{option_results}->{per_sec}) ? 'cmd/s' : 'cmd',
value => sprintf("%.2f", defined($instance_mode->{option_results}->{per_sec}) ? $self->{result_values}->{value_per_sec} : $self->{result_values}->{value}),
unit => defined($self->{instance_mode}->{option_results}->{per_sec}) ? 'cmd/s' : 'cmd',
value => sprintf("%.2f", defined($self->{instance_mode}->{option_results}->{per_sec}) ? $self->{result_values}->{value_per_sec} : $self->{result_values}->{value}),
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . lc($self->{result_values}->{metric}) . "-" . lc($self->{result_values}->{stat})),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . lc($self->{result_values}->{metric}) . "-" . lc($self->{result_values}->{stat})),
);
@ -77,7 +75,7 @@ sub custom_metric_output {
my ($self, %options) = @_;
my $msg = "";
if (defined($instance_mode->{option_results}->{per_sec})) {
if (defined($self->{instance_mode}->{option_results}->{per_sec})) {
$msg = sprintf("%s: %.2f cmd/s", $self->{result_values}->{metric}, $self->{result_values}->{value_per_sec});
} else {
$msg = sprintf("%s: %.2f cmd", $self->{result_values}->{metric}, $self->{result_values}->{value});
@ -115,14 +113,13 @@ sub new {
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
"name:s@" => { name => 'name' },
"node-id:s" => { name => 'node_id' },
"filter-metric:s" => { name => 'filter_metric' },
"per-sec" => { name => 'per_sec' },
});
$options{options}->add_options(arguments => {
"name:s@" => { name => 'name' },
"node-id:s" => { name => 'node_id' },
"filter-metric:s" => { name => 'filter_metric' },
"per-sec" => { name => 'per_sec' },
});
return $self;
}
@ -161,8 +158,6 @@ sub check_options {
push @{$self->{aws_metrics}}, $metric;
}
$instance_mode = $self;
}
sub manage_selection {

View File

@ -25,8 +25,6 @@ use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
my $instance_mode;
sub prefix_metric_output {
my ($self, %options) = @_;
@ -53,7 +51,7 @@ sub custom_connection_calc {
sub custom_connection_threshold {
my ($self, %options) = @_;
my $exit = $self->{perfdata}->threshold_check(value => defined($instance_mode->{option_results}->{per_sec}) ? $self->{result_values}->{value_per_sec} : $self->{result_values}->{value},
my $exit = $self->{perfdata}->threshold_check(value => defined($self->{instance_mode}->{option_results}->{per_sec}) ? $self->{result_values}->{value_per_sec} : $self->{result_values}->{value},
threshold => [ { label => 'critical-' . lc($self->{result_values}->{metric}) . "-" . lc($self->{result_values}->{stat}), exit_litteral => 'critical' },
{ label => 'warning-' . lc($self->{result_values}->{metric}) . "-" . lc($self->{result_values}->{stat}), exit_litteral => 'warning' } ]);
return $exit;
@ -66,8 +64,8 @@ sub custom_connection_perfdata {
$extra_label = '_' . lc($self->{result_values}->{display}) if (!defined($options{extra_instance}) || $options{extra_instance} != 0);
$self->{output}->perfdata_add(label => lc($self->{result_values}->{metric}) . "_" . lc($self->{result_values}->{stat}) . $extra_label,
unit => defined($instance_mode->{option_results}->{per_sec}) ? 'conn/s' : 'conn',
value => sprintf("%.2f", defined($instance_mode->{option_results}->{per_sec}) ? $self->{result_values}->{value_per_sec} : $self->{result_values}->{value}),
unit => defined($self->{instance_mode}->{option_results}->{per_sec}) ? 'conn/s' : 'conn',
value => sprintf("%.2f", defined($self->{instance_mode}->{option_results}->{per_sec}) ? $self->{result_values}->{value_per_sec} : $self->{result_values}->{value}),
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . lc($self->{result_values}->{metric}) . "-" . lc($self->{result_values}->{stat})),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . lc($self->{result_values}->{metric}) . "-" . lc($self->{result_values}->{stat})),
);
@ -77,7 +75,7 @@ sub custom_connection_output {
my ($self, %options) = @_;
my $msg = "";
if (defined($instance_mode->{option_results}->{per_sec})) {
if (defined($self->{instance_mode}->{option_results}->{per_sec})) {
$msg = sprintf("%s: %.2f connections/s", $self->{result_values}->{metric}, $self->{result_values}->{value_per_sec});
} else {
$msg = sprintf("%s: %.2f connections", $self->{result_values}->{metric}, $self->{result_values}->{value});
@ -126,14 +124,13 @@ sub new {
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
"name:s@" => { name => 'name' },
"node-id:s" => { name => 'node_id' },
"filter-metric:s" => { name => 'filter_metric' },
"per-sec" => { name => 'per_sec' },
});
$options{options}->add_options(arguments => {
"name:s@" => { name => 'name' },
"node-id:s" => { name => 'node_id' },
"filter-metric:s" => { name => 'filter_metric' },
"per-sec" => { name => 'per_sec' },
});
return $self;
}
@ -171,8 +168,6 @@ sub check_options {
push @{$self->{aws_metrics}}, $metric;
}
$instance_mode = $self;
}
sub manage_selection {

View File

@ -25,8 +25,6 @@ use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
my $instance_mode;
sub prefix_metric_output {
my ($self, %options) = @_;
@ -53,7 +51,7 @@ sub custom_metric_calc {
sub custom_metric_threshold {
my ($self, %options) = @_;
my $exit = $self->{perfdata}->threshold_check(value => defined($instance_mode->{option_results}->{per_sec}) ? $self->{result_values}->{value_per_sec} : $self->{result_values}->{value},
my $exit = $self->{perfdata}->threshold_check(value => defined($self->{instance_mode}->{option_results}->{per_sec}) ? $self->{result_values}->{value_per_sec} : $self->{result_values}->{value},
threshold => [ { label => 'critical-' . lc($self->{result_values}->{metric}) . "-" . lc($self->{result_values}->{stat}), exit_litteral => 'critical' },
{ label => 'warning-' . lc($self->{result_values}->{metric}) . "-" . lc($self->{result_values}->{stat}), exit_litteral => 'warning' } ]);
return $exit;
@ -66,8 +64,8 @@ sub custom_metric_perfdata {
$extra_label = '_' . lc($self->{result_values}->{display}) if (!defined($options{extra_instance}) || $options{extra_instance} != 0);
$self->{output}->perfdata_add(label => lc($self->{result_values}->{metric}) . "_" . lc($self->{result_values}->{stat}) . $extra_label,
unit => defined($instance_mode->{option_results}->{per_sec}) ? 'evictions/s' : 'evictions',
value => sprintf("%.2f", defined($instance_mode->{option_results}->{per_sec}) ? $self->{result_values}->{value_per_sec} : $self->{result_values}->{value}),
unit => defined($self->{instance_mode}->{option_results}->{per_sec}) ? 'evictions/s' : 'evictions',
value => sprintf("%.2f", defined($self->{instance_mode}->{option_results}->{per_sec}) ? $self->{result_values}->{value_per_sec} : $self->{result_values}->{value}),
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . lc($self->{result_values}->{metric}) . "-" . lc($self->{result_values}->{stat})),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . lc($self->{result_values}->{metric}) . "-" . lc($self->{result_values}->{stat})),
);
@ -77,7 +75,7 @@ sub custom_metric_output {
my ($self, %options) = @_;
my $msg = "";
if (defined($instance_mode->{option_results}->{per_sec})) {
if (defined($self->{instance_mode}->{option_results}->{per_sec})) {
$msg = sprintf("%s: %.2f evictions/s", $self->{result_values}->{metric}, $self->{result_values}->{value_per_sec});
} else {
$msg = sprintf("%s: %.2f evictions", $self->{result_values}->{metric}, $self->{result_values}->{value});
@ -114,14 +112,13 @@ sub new {
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
"name:s@" => { name => 'name' },
"node-id:s" => { name => 'node_id' },
"filter-metric:s" => { name => 'filter_metric' },
"per-sec" => { name => 'per_sec' },
});
$options{options}->add_options(arguments => {
"name:s@" => { name => 'name' },
"node-id:s" => { name => 'node_id' },
"filter-metric:s" => { name => 'filter_metric' },
"per-sec" => { name => 'per_sec' },
});
return $self;
}
@ -159,8 +156,6 @@ sub check_options {
push @{$self->{aws_metrics}}, $metric;
}
$instance_mode = $self;
}
sub manage_selection {

View File

@ -25,8 +25,6 @@ use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
my $instance_mode;
sub prefix_metric_output {
my ($self, %options) = @_;
@ -53,7 +51,7 @@ sub custom_item_calc {
sub custom_item_threshold {
my ($self, %options) = @_;
my $exit = $self->{perfdata}->threshold_check(value => defined($instance_mode->{option_results}->{per_sec}) ? $self->{result_values}->{value_per_sec} : $self->{result_values}->{value},
my $exit = $self->{perfdata}->threshold_check(value => defined($self->{instance_mode}->{option_results}->{per_sec}) ? $self->{result_values}->{value_per_sec} : $self->{result_values}->{value},
threshold => [ { label => 'critical-' . lc($self->{result_values}->{metric}) . "-" . lc($self->{result_values}->{stat}), exit_litteral => 'critical' },
{ label => 'warning-' . lc($self->{result_values}->{metric}) . "-" . lc($self->{result_values}->{stat}), exit_litteral => 'warning' } ]);
return $exit;
@ -66,8 +64,8 @@ sub custom_item_perfdata {
$extra_label = '_' . lc($self->{result_values}->{display}) if (!defined($options{extra_instance}) || $options{extra_instance} != 0);
$self->{output}->perfdata_add(label => lc($self->{result_values}->{metric}) . "_" . lc($self->{result_values}->{stat}) . $extra_label,
unit => defined($instance_mode->{option_results}->{per_sec}) ? 'items/s' : 'items',
value => sprintf("%.2f", defined($instance_mode->{option_results}->{per_sec}) ? $self->{result_values}->{value_per_sec} : $self->{result_values}->{value}),
unit => defined($self->{instance_mode}->{option_results}->{per_sec}) ? 'items/s' : 'items',
value => sprintf("%.2f", defined($self->{instance_mode}->{option_results}->{per_sec}) ? $self->{result_values}->{value_per_sec} : $self->{result_values}->{value}),
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . lc($self->{result_values}->{metric}) . "-" . lc($self->{result_values}->{stat})),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . lc($self->{result_values}->{metric}) . "-" . lc($self->{result_values}->{stat})),
);
@ -77,7 +75,7 @@ sub custom_item_output {
my ($self, %options) = @_;
my $msg = "";
if (defined($instance_mode->{option_results}->{per_sec})) {
if (defined($self->{instance_mode}->{option_results}->{per_sec})) {
$msg = sprintf("%s: %.2f items/s", $self->{result_values}->{metric}, $self->{result_values}->{value_per_sec});
} else {
$msg = sprintf("%s: %.2f items", $self->{result_values}->{metric}, $self->{result_values}->{value});
@ -126,14 +124,13 @@ sub new {
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
"name:s@" => { name => 'name' },
"node-id:s" => { name => 'node_id' },
"filter-metric:s" => { name => 'filter_metric' },
"per-sec" => { name => 'per_sec' },
});
$options{options}->add_options(arguments => {
"name:s@" => { name => 'name' },
"node-id:s" => { name => 'node_id' },
"filter-metric:s" => { name => 'filter_metric' },
"per-sec" => { name => 'per_sec' },
});
return $self;
}
@ -171,8 +168,6 @@ sub check_options {
push @{$self->{aws_metrics}}, $metric;
}
$instance_mode = $self;
}
sub manage_selection {

View File

@ -25,8 +25,6 @@ use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
my $instance_mode;
sub prefix_metric_output {
my ($self, %options) = @_;
@ -53,7 +51,7 @@ sub custom_traffic_calc {
sub custom_traffic_threshold {
my ($self, %options) = @_;
my $exit = $self->{perfdata}->threshold_check(value => defined($instance_mode->{option_results}->{per_sec}) ? $self->{result_values}->{value_per_sec} : $self->{result_values}->{value},
my $exit = $self->{perfdata}->threshold_check(value => defined($self->{instance_mode}->{option_results}->{per_sec}) ? $self->{result_values}->{value_per_sec} : $self->{result_values}->{value},
threshold => [ { label => 'critical-' . lc($self->{result_values}->{metric}) . "-" . lc($self->{result_values}->{stat}), exit_litteral => 'critical' },
{ label => 'warning-' . lc($self->{result_values}->{metric}) . "-" . lc($self->{result_values}->{stat}), exit_litteral => 'warning' } ]);
return $exit;
@ -66,8 +64,8 @@ sub custom_traffic_perfdata {
$extra_label = '_' . lc($self->{result_values}->{display}) if (!defined($options{extra_instance}) || $options{extra_instance} != 0);
$self->{output}->perfdata_add(label => lc($self->{result_values}->{metric}) . "_" . lc($self->{result_values}->{stat}) . $extra_label,
unit => defined($instance_mode->{option_results}->{per_sec}) ? 'B/s' : 'B',
value => sprintf("%.2f", defined($instance_mode->{option_results}->{per_sec}) ? $self->{result_values}->{value_per_sec} : $self->{result_values}->{value}),
unit => defined($self->{instance_mode}->{option_results}->{per_sec}) ? 'B/s' : 'B',
value => sprintf("%.2f", defined($self->{instance_mode}->{option_results}->{per_sec}) ? $self->{result_values}->{value_per_sec} : $self->{result_values}->{value}),
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . lc($self->{result_values}->{metric}) . "-" . lc($self->{result_values}->{stat})),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . lc($self->{result_values}->{metric}) . "-" . lc($self->{result_values}->{stat})),
);
@ -77,7 +75,7 @@ sub custom_traffic_output {
my ($self, %options) = @_;
my $msg = "";
if (defined($instance_mode->{option_results}->{per_sec})) {
if (defined($self->{instance_mode}->{option_results}->{per_sec})) {
my ($value, $unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{value_per_sec});
$msg = $self->{result_values}->{metric} . ": " . $value . $unit . "/s";
} else {
@ -116,14 +114,13 @@ sub new {
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
"name:s@" => { name => 'name' },
"node-id:s" => { name => 'node_id' },
"filter-metric:s" => { name => 'filter_metric' },
"per-sec" => { name => 'per_sec' },
});
$options{options}->add_options(arguments => {
"name:s@" => { name => 'name' },
"node-id:s" => { name => 'node_id' },
"filter-metric:s" => { name => 'filter_metric' },
"per-sec" => { name => 'per_sec' },
});
return $self;
}
@ -161,8 +158,6 @@ sub check_options {
push @{$self->{aws_metrics}}, $metric;
}
$instance_mode = $self;
}
sub manage_selection {

View File

@ -25,8 +25,6 @@ use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
my $instance_mode;
sub prefix_metric_output {
my ($self, %options) = @_;
@ -53,7 +51,7 @@ sub custom_metric_calc {
sub custom_metric_threshold {
my ($self, %options) = @_;
my $exit = $self->{perfdata}->threshold_check(value => defined($instance_mode->{option_results}->{per_sec}) ? $self->{result_values}->{value_per_sec} : $self->{result_values}->{value},
my $exit = $self->{perfdata}->threshold_check(value => defined($self->{instance_mode}->{option_results}->{per_sec}) ? $self->{result_values}->{value_per_sec} : $self->{result_values}->{value},
threshold => [ { label => 'critical-' . lc($self->{result_values}->{metric}) . "-" . lc($self->{result_values}->{stat}), exit_litteral => 'critical' },
{ label => 'warning-' . lc($self->{result_values}->{metric}) . "-" . lc($self->{result_values}->{stat}), exit_litteral => 'warning' } ]);
return $exit;
@ -66,8 +64,8 @@ sub custom_metric_perfdata {
$extra_label = '_' . lc($self->{result_values}->{display}) if (!defined($options{extra_instance}) || $options{extra_instance} != 0);
$self->{output}->perfdata_add(label => lc($self->{result_values}->{metric}) . "_" . lc($self->{result_values}->{stat}) . $extra_label,
unit => defined($instance_mode->{option_results}->{per_sec}) ? 'B/s' : 'B',
value => sprintf("%.2f", defined($instance_mode->{option_results}->{per_sec}) ? $self->{result_values}->{value_per_sec} : $self->{result_values}->{value}),
unit => defined($self->{instance_mode}->{option_results}->{per_sec}) ? 'B/s' : 'B',
value => sprintf("%.2f", defined($self->{instance_mode}->{option_results}->{per_sec}) ? $self->{result_values}->{value_per_sec} : $self->{result_values}->{value}),
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . lc($self->{result_values}->{metric}) . "-" . lc($self->{result_values}->{stat})),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . lc($self->{result_values}->{metric}) . "-" . lc($self->{result_values}->{stat})),
);
@ -77,7 +75,7 @@ sub custom_metric_output {
my ($self, %options) = @_;
my $msg = "";
if (defined($instance_mode->{option_results}->{per_sec})) {
if (defined($self->{instance_mode}->{option_results}->{per_sec})) {
my ($value, $unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{value_per_sec});
$msg = $self->{result_values}->{metric} . ": " . $value . $unit . "/s";
} else {
@ -128,14 +126,13 @@ sub new {
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
"name:s@" => { name => 'name' },
"node-id:s" => { name => 'node_id' },
"filter-metric:s" => { name => 'filter_metric' },
"per-sec" => { name => 'per_sec' },
});
$options{options}->add_options(arguments => {
"name:s@" => { name => 'name' },
"node-id:s" => { name => 'node_id' },
"filter-metric:s" => { name => 'filter_metric' },
"per-sec" => { name => 'per_sec' },
});
return $self;
}
@ -173,8 +170,6 @@ sub check_options {
push @{$self->{aws_metrics}}, $metric;
}
$instance_mode = $self;
}
sub manage_selection {

View File

@ -25,8 +25,6 @@ use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
my $instance_mode;
sub prefix_metric_output {
my ($self, %options) = @_;
@ -53,7 +51,7 @@ sub custom_metric_calc {
sub custom_metric_threshold {
my ($self, %options) = @_;
my $exit = $self->{perfdata}->threshold_check(value => defined($instance_mode->{option_results}->{per_sec}) ? $self->{result_values}->{value_per_sec} : $self->{result_values}->{value},
my $exit = $self->{perfdata}->threshold_check(value => defined($self->{instance_mode}->{option_results}->{per_sec}) ? $self->{result_values}->{value_per_sec} : $self->{result_values}->{value},
threshold => [ { label => 'critical-' . lc($self->{result_values}->{metric}) . "-" . lc($self->{result_values}->{stat}), exit_litteral => 'critical' },
{ label => 'warning-' . lc($self->{result_values}->{metric}) . "-" . lc($self->{result_values}->{stat}), exit_litteral => 'warning' } ]);
return $exit;
@ -66,8 +64,8 @@ sub custom_metric_perfdata {
$extra_label = '_' . lc($self->{result_values}->{display}) if (!defined($options{extra_instance}) || $options{extra_instance} != 0);
$self->{output}->perfdata_add(label => lc($self->{result_values}->{metric}) . "_" . lc($self->{result_values}->{stat}) . $extra_label,
unit => defined($instance_mode->{option_results}->{per_sec}) ? 'req/s' : 'req',
value => sprintf("%.2f", defined($instance_mode->{option_results}->{per_sec}) ? $self->{result_values}->{value_per_sec} : $self->{result_values}->{value}),
unit => defined($self->{instance_mode}->{option_results}->{per_sec}) ? 'req/s' : 'req',
value => sprintf("%.2f", defined($self->{instance_mode}->{option_results}->{per_sec}) ? $self->{result_values}->{value_per_sec} : $self->{result_values}->{value}),
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . lc($self->{result_values}->{metric}) . "-" . lc($self->{result_values}->{stat})),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . lc($self->{result_values}->{metric}) . "-" . lc($self->{result_values}->{stat})),
);
@ -77,7 +75,7 @@ sub custom_metric_output {
my ($self, %options) = @_;
my $msg = "";
if (defined($instance_mode->{option_results}->{per_sec})) {
if (defined($self->{instance_mode}->{option_results}->{per_sec})) {
$msg = sprintf("%s: %.2f requests/s", $self->{result_values}->{metric}, $self->{result_values}->{value_per_sec});
} else {
$msg = sprintf("%s: %.2f requests", $self->{result_values}->{metric}, $self->{result_values}->{value});
@ -115,14 +113,13 @@ sub new {
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
"name:s@" => { name => 'name' },
"node-id:s" => { name => 'node_id' },
"filter-metric:s" => { name => 'filter_metric' },
"per-sec" => { name => 'per_sec' },
});
$options{options}->add_options(arguments => {
"name:s@" => { name => 'name' },
"node-id:s" => { name => 'node_id' },
"filter-metric:s" => { name => 'filter_metric' },
"per-sec" => { name => 'per_sec' },
});
return $self;
}
@ -161,8 +158,6 @@ sub check_options {
push @{$self->{aws_metrics}}, $metric;
}
$instance_mode = $self;
}
sub manage_selection {

View File

@ -25,8 +25,6 @@ use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
my $instance_mode;
sub prefix_metric_output {
my ($self, %options) = @_;
@ -53,7 +51,7 @@ sub custom_metric_calc {
sub custom_metric_threshold {
my ($self, %options) = @_;
my $exit = $self->{perfdata}->threshold_check(value => defined($instance_mode->{option_results}->{per_sec}) ? $self->{result_values}->{value_per_sec} : $self->{result_values}->{value},
my $exit = $self->{perfdata}->threshold_check(value => defined($self->{instance_mode}->{option_results}->{per_sec}) ? $self->{result_values}->{value_per_sec} : $self->{result_values}->{value},
threshold => [ { label => 'critical-' . lc($self->{result_values}->{metric}) . "-" . lc($self->{result_values}->{stat}), exit_litteral => 'critical' },
{ label => 'warning-' . lc($self->{result_values}->{metric}) . "-" . lc($self->{result_values}->{stat}), exit_litteral => 'warning' } ]);
return $exit;
@ -66,8 +64,8 @@ sub custom_metric_perfdata {
$extra_label = '_' . lc($self->{result_values}->{display}) if (!defined($options{extra_instance}) || $options{extra_instance} != 0);
$self->{output}->perfdata_add(label => lc($self->{result_values}->{metric}) . "_" . lc($self->{result_values}->{stat}) . $extra_label,
unit => defined($instance_mode->{option_results}->{per_sec}) ? 'req/s' : 'req',
value => sprintf("%.2f", defined($instance_mode->{option_results}->{per_sec}) ? $self->{result_values}->{value_per_sec} : $self->{result_values}->{value}),
unit => defined($self->{instance_mode}->{option_results}->{per_sec}) ? 'req/s' : 'req',
value => sprintf("%.2f", defined($self->{instance_mode}->{option_results}->{per_sec}) ? $self->{result_values}->{value_per_sec} : $self->{result_values}->{value}),
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . lc($self->{result_values}->{metric}) . "-" . lc($self->{result_values}->{stat})),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . lc($self->{result_values}->{metric}) . "-" . lc($self->{result_values}->{stat})),
);
@ -77,7 +75,7 @@ sub custom_metric_output {
my ($self, %options) = @_;
my $msg = "";
if (defined($instance_mode->{option_results}->{per_sec})) {
if (defined($self->{instance_mode}->{option_results}->{per_sec})) {
$msg = sprintf("%s: %.2f requests/s", $self->{result_values}->{metric}, $self->{result_values}->{value_per_sec});
} else {
$msg = sprintf("%s: %.2f requests", $self->{result_values}->{metric}, $self->{result_values}->{value});
@ -114,14 +112,13 @@ sub new {
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
"name:s@" => { name => 'name' },
"node-id:s" => { name => 'node_id' },
"filter-metric:s" => { name => 'filter_metric' },
"per-sec" => { name => 'per_sec' },
});
$options{options}->add_options(arguments => {
"name:s@" => { name => 'name' },
"node-id:s" => { name => 'node_id' },
"filter-metric:s" => { name => 'filter_metric' },
"per-sec" => { name => 'per_sec' },
});
return $self;
}
@ -159,8 +156,6 @@ sub check_options {
push @{$self->{aws_metrics}}, $metric;
}
$instance_mode = $self;
}
sub manage_selection {

View File

@ -29,9 +29,6 @@ my %map_type = (
"cluster" => "DbClusterIdentifier",
);
my $instance_mode;
sub prefix_metric_output {
my ($self, %options) = @_;
@ -53,7 +50,7 @@ sub custom_metric_calc {
sub custom_metric_threshold {
my ($self, %options) = @_;
my $exit = $self->{perfdata}->threshold_check(value => defined($instance_mode->{option_results}->{per_sec}) ? $self->{result_values}->{value_per_sec} : $self->{result_values}->{value},
my $exit = $self->{perfdata}->threshold_check(value => defined($self->{instance_mode}->{option_results}->{per_sec}) ? $self->{result_values}->{value_per_sec} : $self->{result_values}->{value},
threshold => [ { label => 'critical-' . lc($self->{result_values}->{metric}) . "-" . lc($self->{result_values}->{stat}), exit_litteral => 'critical' },
{ label => 'warning-' . lc($self->{result_values}->{metric}) . "-" . lc($self->{result_values}->{stat}), exit_litteral => 'warning' } ]);
return $exit;
@ -66,8 +63,8 @@ sub custom_ops_perfdata {
$extra_label = '_' . lc($self->{result_values}->{display}) if (!defined($options{extra_instance}) || $options{extra_instance} != 0);
$self->{output}->perfdata_add(label => lc($self->{result_values}->{metric}) . "_" . lc($self->{result_values}->{stat}) . $extra_label,
unit => defined($instance_mode->{option_results}->{per_sec}) ? 'ops/s' : 'ops',
value => sprintf("%.2f", defined($instance_mode->{option_results}->{per_sec}) ? $self->{result_values}->{value_per_sec} : $self->{result_values}->{value}),
unit => defined($self->{instance_mode}->{option_results}->{per_sec}) ? 'ops/s' : 'ops',
value => sprintf("%.2f", defined($self->{instance_mode}->{option_results}->{per_sec}) ? $self->{result_values}->{value_per_sec} : $self->{result_values}->{value}),
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . lc($self->{result_values}->{metric}) . "-" . lc($self->{result_values}->{stat})),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . lc($self->{result_values}->{metric}) . "-" . lc($self->{result_values}->{stat})),
);
@ -78,7 +75,7 @@ sub custom_ops_output {
my $msg ="";
if (defined($instance_mode->{option_results}->{per_sec})) {
if (defined($self->{instance_mode}->{option_results}->{per_sec})) {
$msg = sprintf("%s: %.2f ops/s", $self->{result_values}->{metric}, $self->{result_values}->{value_per_sec});
} else {
$msg = sprintf("%s: %.2f ops", $self->{result_values}->{metric}, $self->{result_values}->{value});
@ -129,14 +126,13 @@ sub new {
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
"type:s" => { name => 'type', default => 'cluster' },
"name:s@" => { name => 'name' },
"filter-metric:s" => { name => 'filter_metric' },
"per-sec" => { name => 'per_sec' },
});
$options{options}->add_options(arguments => {
"type:s" => { name => 'type', default => 'cluster' },
"name:s@" => { name => 'name' },
"filter-metric:s" => { name => 'filter_metric' },
"per-sec" => { name => 'per_sec' },
});
return $self;
}
@ -184,8 +180,6 @@ sub check_options {
push @{$self->{aws_metrics}}, $metric;
}
$instance_mode = $self;
}
sub manage_selection {

View File

@ -25,8 +25,6 @@ use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
my $instance_mode;
sub custom_app_state_threshold {
my ($self, %options) = @_;
my $status = 'ok';
@ -36,11 +34,11 @@ sub custom_app_state_threshold {
local $SIG{__WARN__} = sub { $message = $_[0]; };
local $SIG{__DIE__} = sub { $message = $_[0]; };
if (defined($instance_mode->{option_results}->{critical_app_state}) && $instance_mode->{option_results}->{critical_app_state} ne '' &&
eval "$instance_mode->{option_results}->{critical_app_state}") {
if (defined($self->{instance_mode}->{option_results}->{critical_app_state}) && $self->{instance_mode}->{option_results}->{critical_app_state} ne '' &&
eval "$self->{instance_mode}->{option_results}->{critical_app_state}") {
$status = 'critical';
} elsif (defined($instance_mode->{option_results}->{warning_app_state}) && $instance_mode->{option_results}->{warning_app_state} ne '' &&
eval "$instance_mode->{option_results}->{warning_app_state}") {
} elsif (defined($self->{instance_mode}->{option_results}->{warning_app_state}) && $self->{instance_mode}->{option_results}->{warning_app_state} ne '' &&
eval "$self->{instance_mode}->{option_results}->{warning_app_state}") {
$status = 'warning';
}
};
@ -77,11 +75,11 @@ sub custom_inst_state_threshold {
local $SIG{__WARN__} = sub { $message = $_[0]; };
local $SIG{__DIE__} = sub { $message = $_[0]; };
if (defined($instance_mode->{option_results}->{critical_instance_state}) && $instance_mode->{option_results}->{critical_instance_state} ne '' &&
eval "$instance_mode->{option_results}->{critical_instance_state}") {
if (defined($self->{instance_mode}->{option_results}->{critical_instance_state}) && $self->{instance_mode}->{option_results}->{critical_instance_state} ne '' &&
eval "$self->{instance_mode}->{option_results}->{critical_instance_state}") {
$status = 'critical';
} elsif (defined($instance_mode->{option_results}->{warning_instance_state}) && $instance_mode->{option_results}->{warning_instance_state} ne '' &&
eval "$instance_mode->{option_results}->{warning_instance_state}") {
} elsif (defined($self->{instance_mode}->{option_results}->{warning_instance_state}) && $self->{instance_mode}->{option_results}->{warning_instance_state} ne '' &&
eval "$self->{instance_mode}->{option_results}->{warning_instance_state}") {
$status = 'warning';
}
};
@ -182,15 +180,14 @@ sub new {
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
"app-guid:s" => { name => 'app_guid' },
"warning-app-state:s" => { name => 'warning_app_state' },
"critical-app-state:s" => { name => 'critical_app_state', default => '%{state} !~ /STARTED/i' },
"warning-instance-state:s" => { name => 'warning_instance_state' },
"critical-instance-state:s" => { name => 'critical_instance_state', default => '%{state} !~ /RUNNING/i' },
});
$options{options}->add_options(arguments => {
"app-guid:s" => { name => 'app_guid' },
"warning-app-state:s" => { name => 'warning_app_state' },
"critical-app-state:s" => { name => 'critical_app_state', default => '%{state} !~ /STARTED/i' },
"warning-instance-state:s" => { name => 'warning_instance_state' },
"critical-instance-state:s" => { name => 'critical_instance_state', default => '%{state} !~ /RUNNING/i' },
});
return $self;
}
@ -203,7 +200,6 @@ sub check_options {
$self->{output}->option_exit();
}
$instance_mode = $self;
$self->change_macros(macros => ['warning_app_state', 'critical_app_state', 'warning_instance_state', 'critical_instance_state']);
}

View File

@ -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;
@ -117,23 +115,15 @@ sub new {
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
"filter-service:s" => { name => 'filter_service' },
"units:s" => { name => 'units', default => '%' },
"free" => { name => 'free' },
});
$options{options}->add_options(arguments => {
"filter-service:s" => { name => 'filter_service' },
"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_services_output {
my ($self, %options) = @_;

View File

@ -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;
@ -127,37 +125,30 @@ 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 => 'bdf' },
"command-path:s" => { name => 'command_path' },
"command-options:s" => { name => 'command_options', default => ' 2>&1' },
"filter-fs:s" => { name => 'filter_fs', },
"units:s" => { name => 'units', default => '%' },
"free" => { name => 'free' },
"name:s" => { name => 'name' },
"regexp" => { name => 'use_regexp' },
"regexp-isensitive" => { name => 'use_regexpi' },
"space-reservation:s" => { name => 'space_reservation' },
});
$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 => 'bdf' },
"command-path:s" => { name => 'command_path' },
"command-options:s" => { name => 'command_options', default => ' 2>&1' },
"filter-fs:s" => { name => 'filter_fs', },
"units:s" => { name => 'units', default => '%' },
"free" => { name => 'free' },
"name:s" => { name => 'name' },
"regexp" => { name => 'use_regexp' },
"regexp-isensitive" => { name => 'use_regexpi' },
"space-reservation:s" => { name => 'space_reservation' },
});
$self->{result} = {};
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::check_options(%options);
$instance_mode = $self;
}
sub manage_selection {
my ($self, %options) = @_;

View File

@ -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_storage_output {
my ($self, %options) = @_;

View File

@ -26,8 +26,6 @@ use strict;
use warnings;
use centreon::plugins::misc;
my $instance_mode;
sub custom_usage_perfdata {
my ($self, %options) = @_;
@ -83,8 +81,8 @@ sub custom_usage_calc {
$self->{result_values}->{used} = $options{new_datas}->{$self->{instance} . '_' . $self->{result_values}->{label_ref} . '_used'};
$self->{result_values}->{warn_label} = $self->{label};
if (defined($instance_mode->{option_results}->{'warning-' . $self->{label}}) && $instance_mode->{option_results}->{'warning-' . $self->{label}} ne '') {
$self->{result_values}->{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 '') {
$self->{result_values}->{warn_limit} = $self->{instance_mode}->{option_results}->{'warning-' . $self->{label}};
} elsif ($options{new_datas}->{$self->{instance} . '_' . $self->{result_values}->{label_ref} . '_soft'} > 0) {
$self->{result_values}->{warn_limit} = $options{new_datas}->{$self->{instance} . '_' . $self->{result_values}->{label_ref} . '_soft'};
$self->{perfdata}->threshold_validate(label => 'warning-' . $self->{label} . '_' . $self->{result_values}->{display}, value => $self->{result_values}->{warn_limit});
@ -92,8 +90,8 @@ sub custom_usage_calc {
}
$self->{result_values}->{crit_label} = $self->{label};
if (defined($instance_mode->{option_results}->{'critical-' . $self->{label}}) && $instance_mode->{option_results}->{'critical-' . $self->{label}} ne '') {
$self->{result_values}->{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 '') {
$self->{result_values}->{crit_limit} = $self->{instance_mode}->{option_results}->{'critical-' . $self->{label}};
} elsif ($options{new_datas}->{$self->{instance} . '_' . $self->{result_values}->{label_ref} . '_hard'} > 0) {
$self->{result_values}->{crit_limit} = $options{new_datas}->{$self->{instance} . '_' . $self->{result_values}->{label_ref} . '_hard'} - 1;
$self->{perfdata}->threshold_validate(label => 'critical-' . $self->{label} . '_' . $self->{result_values}->{display}, value => $self->{result_values}->{crit_limit});
@ -141,32 +139,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 => 'repquota' },
"command-path:s" => { name => 'command_path' },
"command-options:s" => { name => 'command_options', default => '-a -i 2>&1' },
"filter-user:s" => { name => 'filter_user', },
"filter-fs:s" => { name => 'filter_fs', },
});
$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 => 'repquota' },
"command-path:s" => { name => 'command_path' },
"command-options:s" => { name => 'command_options', default => '-a -i 2>&1' },
"filter-user:s" => { name => 'filter_user', },
"filter-fs:s" => { name => 'filter_fs', },
});
$self->{result} = {};
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::check_options(%options);
$instance_mode = $self;
}
sub manage_selection {
my ($self, %options) = @_;

View File

@ -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;
@ -127,38 +125,31 @@ 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 => 'df' },
"command-path:s" => { name => 'command_path' },
"command-options:s" => { name => 'command_options', default => '-P -k -T 2>&1' },
"filter-type:s" => { name => 'filter_type', },
"filter-fs:s" => { name => 'filter_fs', },
"units:s" => { name => 'units', default => '%' },
"free" => { name => 'free' },
"name:s" => { name => 'name' },
"regexp" => { name => 'use_regexp' },
"regexp-isensitive" => { name => 'use_regexpi' },
"space-reservation:s" => { name => 'space_reservation' },
});
$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 => 'df' },
"command-path:s" => { name => 'command_path' },
"command-options:s" => { name => 'command_options', default => '-P -k -T 2>&1' },
"filter-type:s" => { name => 'filter_type', },
"filter-fs:s" => { name => 'filter_fs', },
"units:s" => { name => 'units', default => '%' },
"free" => { name => 'free' },
"name:s" => { name => 'name' },
"regexp" => { name => 'use_regexp' },
"regexp-isensitive" => { name => 'use_regexpi' },
"space-reservation:s" => { name => 'space_reservation' },
});
$self->{result} = {};
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::check_options(%options);
$instance_mode = $self;
}
sub manage_selection {
my ($self, %options) = @_;
@ -299,4 +290,4 @@ The value is in percent of total (Default: none).
=back
=cut
=cut

View File

@ -25,20 +25,18 @@ use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
my $instance_mode;
sub custom_usage_perfdata {
my ($self, %options) = @_;
my $label = 'used';
my $value_perf = $self->{result_values}->{used};
if (defined($instance_mode->{option_results}->{free})) {
if (defined($self->{instance_mode}->{option_results}->{free})) {
$label = 'free';
$value_perf = $self->{result_values}->{free};
}
my %total_options = ();
if ($instance_mode->{option_results}->{units} eq '%') {
if ($self->{instance_mode}->{option_results}->{units} eq '%') {
$total_options{total} = $self->{result_values}->{total};
$total_options{cast_int} = 1;
}
@ -55,10 +53,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,22 +115,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) = @_;

View File

@ -27,21 +27,19 @@ use warnings;
use centreon::plugins::statefile;
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;
}
@ -58,10 +56,10 @@ sub custom_usage_threshold {
my ($exit, $threshold_value);
$threshold_value = $self->{result_values}->{used};
$threshold_value = $self->{result_values}->{free} if (defined($instance_mode->{option_results}->{free}));
if ($instance_mode->{option_results}->{units} eq '%') {
$threshold_value = $self->{result_values}->{free} if (defined($self->{instance_mode}->{option_results}->{free}));
if ($self->{instance_mode}->{option_results}->{units} eq '%') {
$threshold_value = $self->{result_values}->{prct_used};
$threshold_value = $self->{result_values}->{prct_free} if (defined($instance_mode->{option_results}->{free}));
$threshold_value = $self->{result_values}->{prct_free} if (defined($self->{instance_mode}->{option_results}->{free}));
}
$exit = $self->{perfdata}->threshold_check(value => $threshold_value, threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, { label => 'warning-'. $self->{label}, exit_litteral => 'warning' } ]);
return $exit;
@ -86,8 +84,8 @@ sub custom_usage_calc {
$self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'};
$self->{result_values}->{total} = $options{new_datas}->{$self->{instance} . '_size'};
my $reserved_value = 0;
if (defined($instance_mode->{option_results}->{space_reservation})) {
$reserved_value = $instance_mode->{option_results}->{space_reservation} * $self->{result_values}->{total} / 100;
if (defined($self->{instance_mode}->{option_results}->{space_reservation})) {
$reserved_value = $self->{instance_mode}->{option_results}->{space_reservation} * $self->{result_values}->{total} / 100;
}
$self->{result_values}->{used} = $options{new_datas}->{$self->{instance} . '_used'};
@ -153,21 +151,20 @@ sub new {
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
"units:s" => { name => 'units', default => '%' },
"free" => { name => 'free' },
"reload-cache-time:s" => { name => 'reload_cache_time', default => 180 },
"name" => { name => 'use_name' },
"diskpath:s" => { name => 'diskpath' },
"regexp" => { name => 'use_regexp' },
"regexp-isensitive" => { name => 'use_regexpi' },
"display-transform-src:s" => { name => 'display_transform_src' },
"display-transform-dst:s" => { name => 'display_transform_dst' },
"show-cache" => { name => 'show_cache' },
"space-reservation:s" => { name => 'space_reservation' },
"filter-counters:s" => { name => 'filter_counters', default => 'usage' },
});
$options{options}->add_options(arguments => {
"units:s" => { name => 'units', default => '%' },
"free" => { name => 'free' },
"reload-cache-time:s" => { name => 'reload_cache_time', default => 180 },
"name" => { name => 'use_name' },
"diskpath:s" => { name => 'diskpath' },
"regexp" => { name => 'use_regexp' },
"regexp-isensitive" => { name => 'use_regexpi' },
"display-transform-src:s" => { name => 'display_transform_src' },
"display-transform-dst:s" => { name => 'display_transform_dst' },
"show-cache" => { name => 'show_cache' },
"space-reservation:s" => { name => 'space_reservation' },
"filter-counters:s" => { name => 'filter_counters', default => 'usage' },
});
$self->{diskpath_id_selected} = [];
$self->{statefile_cache} = centreon::plugins::statefile->new(%options);
@ -186,7 +183,6 @@ sub check_options {
}
$self->{statefile_cache}->check_options(%options);
$instance_mode = $self;
}
sub manage_selection {

View File

@ -27,8 +27,6 @@ use warnings;
use centreon::plugins::statefile;
use Digest::MD5 qw(md5_hex);
my $instance_mode;
my %oids_hrStorageTable = (
'hrstoragedescr' => '.1.3.6.1.2.1.25.2.3.1.3',
'hrfsmountpoint' => '.1.3.6.1.2.1.25.3.8.1.2',
@ -76,14 +74,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;
}
@ -100,10 +98,10 @@ sub custom_usage_threshold {
my ($exit, $threshold_value);
$threshold_value = $self->{result_values}->{used};
$threshold_value = $self->{result_values}->{free} if (defined($instance_mode->{option_results}->{free}));
if ($instance_mode->{option_results}->{units} eq '%') {
$threshold_value = $self->{result_values}->{free} if (defined($self->{instance_mode}->{option_results}->{free}));
if ($self->{instance_mode}->{option_results}->{units} eq '%') {
$threshold_value = $self->{result_values}->{prct_used};
$threshold_value = $self->{result_values}->{prct_free} if (defined($instance_mode->{option_results}->{free}));
$threshold_value = $self->{result_values}->{prct_free} if (defined($self->{instance_mode}->{option_results}->{free}));
}
$exit = $self->{perfdata}->threshold_check(value => $threshold_value, threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, { label => 'warning-'. $self->{label}, exit_litteral => 'warning' } ]);
return $exit;
@ -128,8 +126,8 @@ sub custom_usage_calc {
$self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'};
$self->{result_values}->{total} = $options{new_datas}->{$self->{instance} . '_size'} * $options{new_datas}->{$self->{instance} . '_allocation_units'};
my $reserved_value = 0;
if (defined($instance_mode->{option_results}->{space_reservation})) {
$reserved_value = $instance_mode->{option_results}->{space_reservation} * $self->{result_values}->{total} / 100;
if (defined($self->{instance_mode}->{option_results}->{space_reservation})) {
$reserved_value = $self->{instance_mode}->{option_results}->{space_reservation} * $self->{result_values}->{total} / 100;
}
$self->{result_values}->{used} = $options{new_datas}->{$self->{instance} . '_used'} * $options{new_datas}->{$self->{instance} . '_allocation_units'};
@ -249,7 +247,6 @@ sub check_options {
}
$self->{statefile_cache}->check_options(%options);
$instance_mode = $self;
}
sub access_result {