clean code

This commit is contained in:
garnier-quentin 2019-03-26 18:11:01 +01:00
parent 23ecc86ed7
commit 8100ae4467
23 changed files with 235 additions and 401 deletions

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) = @_;
@ -50,7 +48,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-' . $self->{result_values}->{metric_label} . "-" . $self->{result_values}->{stat}, exit_litteral => 'critical' },
{ label => 'warning-' . $self->{result_values}->{metric_label} . "-" . $self->{result_values}->{stat}, exit_litteral => 'warning' } ]);
return $exit;
@ -63,8 +61,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 => $self->{result_values}->{metric_perf} . "_" . $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-' . $self->{result_values}->{metric_label} . "-" . $self->{result_values}->{stat}),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{result_values}->{metric_label} . "-" . $self->{result_values}->{stat}),
min => 0
@ -75,7 +73,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_name} . ": " . $value . $unit . "/s";
} else {
@ -161,14 +159,13 @@ sub new {
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
"resource:s@" => { name => 'resource' },
"resource-group:s" => { name => 'resource_group' },
"filter-metric:s" => { name => 'filter_metric' },
"per-sec" => { name => 'per_sec' },
});
$options{options}->add_options(arguments => {
"resource:s@" => { name => 'resource' },
"resource-group:s" => { name => 'resource_group' },
"filter-metric:s" => { name => 'filter_metric' },
"per-sec" => { name => 'per_sec' },
});
return $self;
}
@ -204,8 +201,6 @@ sub check_options {
push @{$self->{az_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) = @_;
@ -50,7 +48,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-' . $self->{result_values}->{metric_label} . "-" . $self->{result_values}->{stat}, exit_litteral => 'critical' },
{ label => 'warning-' . $self->{result_values}->{metric_label} . "-" . $self->{result_values}->{stat}, exit_litteral => 'warning' } ]);
return $exit;
@ -63,8 +61,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 => $self->{result_values}->{metric_perf} . "_" . $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-' . $self->{result_values}->{metric_label} . "-" . $self->{result_values}->{stat}),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{result_values}->{metric_label} . "-" . $self->{result_values}->{stat}),
min => 0
@ -75,7 +73,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_name} . ": " . $value . $unit . "/s";
} else {
@ -120,14 +118,13 @@ sub new {
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
"resource:s@" => { name => 'resource' },
"resource-group:s" => { name => 'resource_group' },
"filter-metric:s" => { name => 'filter_metric' },
"per-sec" => { name => 'per_sec' },
});
$options{options}->add_options(arguments => {
"resource:s@" => { name => 'resource' },
"resource-group:s" => { name => 'resource_group' },
"filter-metric:s" => { name => 'filter_metric' },
"per-sec" => { name => 'per_sec' },
});
return $self;
}
@ -162,8 +159,6 @@ sub check_options {
push @{$self->{az_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_traffic_output {
my ($self, %options) = @_;
@ -113,13 +111,12 @@ sub new {
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
"resource:s@" => { name => 'resource' },
"resource-group:s" => { name => 'resource_group' },
"filter-metric:s" => { name => 'filter_metric' },
});
$options{options}->add_options(arguments => {
"resource:s@" => { name => 'resource' },
"resource-group:s" => { name => 'resource_group' },
"filter-metric:s" => { name => 'filter_metric' },
});
return $self;
}
@ -154,8 +151,6 @@ sub check_options {
push @{$self->{az_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) = @_;
@ -50,7 +48,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-' . $self->{result_values}->{metric_label} . "-" . $self->{result_values}->{stat}, exit_litteral => 'critical' },
{ label => 'warning-' . $self->{result_values}->{metric_label} . "-" . $self->{result_values}->{stat}, exit_litteral => 'warning' } ]);
return $exit;
@ -63,8 +61,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 => $self->{result_values}->{metric_perf} . "_" . $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-' . $self->{result_values}->{metric_label} . "-" . $self->{result_values}->{stat}),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{result_values}->{metric_label} . "-" . $self->{result_values}->{stat}),
min => 0
@ -75,7 +73,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_name} . ": " . $value . $unit . "/s";
} else {
@ -92,8 +90,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 => $self->{result_values}->{metric_perf} . "_" . $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-' . $self->{result_values}->{metric_label} . "-" . $self->{result_values}->{stat}),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{result_values}->{metric_label} . "-" . $self->{result_values}->{stat}),
min => 0
@ -104,7 +102,7 @@ sub custom_packets_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 packets/s", $self->{result_values}->{metric_name}, $self->{result_values}->{value_per_sec});
} else {
$msg = sprintf("%s: %.2f packets", $self->{result_values}->{metric_name}, $self->{result_values}->{value});
@ -165,14 +163,13 @@ sub new {
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
"resource:s@" => { name => 'resource' },
"resource-group:s" => { name => 'resource_group' },
"filter-metric:s" => { name => 'filter_metric' },
"per-sec" => { name => 'per_sec' },
});
$options{options}->add_options(arguments => {
"resource:s@" => { name => 'resource' },
"resource-group:s" => { name => 'resource_group' },
"filter-metric:s" => { name => 'filter_metric' },
"per-sec" => { name => 'per_sec' },
});
return $self;
}
@ -207,8 +204,6 @@ sub check_options {
push @{$self->{az_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) = @_;
@ -133,13 +131,12 @@ sub new {
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
"resource:s@" => { name => 'resource' },
"resource-group:s" => { name => 'resource_group' },
"filter-metric:s" => { name => 'filter_metric' },
});
$options{options}->add_options(arguments => {
"resource:s@" => { name => 'resource' },
"resource-group:s" => { name => 'resource_group' },
"filter-metric:s" => { name => 'filter_metric' },
});
return $self;
}
@ -174,8 +171,6 @@ sub check_options {
push @{$self->{az_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) = @_;
@ -51,7 +49,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-' . $self->{result_values}->{metric_label} . "-" . $self->{result_values}->{stat}, exit_litteral => 'critical' },
{ label => 'warning-' . $self->{result_values}->{metric_label} . "-" . $self->{result_values}->{stat}, exit_litteral => 'warning' } ]);
return $exit;
@ -64,8 +62,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 => $self->{result_values}->{metric_perf} . "_" . $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-' . $self->{result_values}->{metric_label} . "-" . $self->{result_values}->{stat}),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{result_values}->{metric_label} . "-" . $self->{result_values}->{stat}),
min => 0
@ -76,7 +74,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_name} . ": " . $value . $unit . "/s";
} else {
@ -93,8 +91,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 => $self->{result_values}->{metric_perf} . "_" . $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-' . $self->{result_values}->{metric_label} . "-" . $self->{result_values}->{stat}),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{result_values}->{metric_label} . "-" . $self->{result_values}->{stat}),
min => 0
@ -105,7 +103,7 @@ sub custom_packets_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 packets/s", $self->{result_values}->{metric_name}, $self->{result_values}->{value_per_sec});
} else {
$msg = sprintf("%s: %.2f packets", $self->{result_values}->{metric_name}, $self->{result_values}->{value});
@ -166,14 +164,13 @@ sub new {
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
"resource:s@" => { name => 'resource' },
"resource-group:s" => { name => 'resource_group' },
"filter-metric:s" => { name => 'filter_metric' },
"per-sec" => { name => 'per_sec' },
});
$options{options}->add_options(arguments => {
"resource:s@" => { name => 'resource' },
"resource-group:s" => { name => 'resource_group' },
"filter-metric:s" => { name => 'filter_metric' },
"per-sec" => { name => 'per_sec' },
});
return $self;
}
@ -209,8 +206,6 @@ sub check_options {
push @{$self->{az_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) = @_;
@ -55,7 +53,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-' . $self->{result_values}->{metric_label} . "-" . $self->{result_values}->{stat}, exit_litteral => 'critical' },
{ label => 'warning-' . $self->{result_values}->{metric_label} . "-" . $self->{result_values}->{stat}, exit_litteral => 'warning' } ]);
return $exit;
@ -68,8 +66,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 => $self->{result_values}->{metric_perf} . "_" . $self->{result_values}->{stat} . $extra_label,
unit => defined($instance_mode->{option_results}->{per_sec}) ? 'transactions/s' : 'transactions',
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}) ? 'transactions/s' : 'transactions',
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-' . $self->{result_values}->{metric_label} . "-" . $self->{result_values}->{stat}),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{result_values}->{metric_label} . "-" . $self->{result_values}->{stat}),
min => 0
@ -80,7 +78,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})) {
$msg = sprintf("%s: %.2f transactions/s", $self->{result_values}->{metric_name}, $self->{result_values}->{value_per_sec});
} else {
$msg = sprintf("%s: %.2f transactions", $self->{result_values}->{metric_name}, $self->{result_values}->{value});
@ -120,14 +118,13 @@ sub new {
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
"resource:s@" => { name => 'resource' },
"resource-group:s" => { name => 'resource_group' },
"resource-namespace:s" => { name => 'resource_namespace' },
"per-sec" => { name => 'per_sec' },
});
$options{options}->add_options(arguments => {
"resource:s@" => { name => 'resource' },
"resource-group:s" => { name => 'resource_group' },
"resource-namespace:s" => { name => 'resource_namespace' },
"per-sec" => { name => 'per_sec' },
});
return $self;
}
@ -160,8 +157,6 @@ sub check_options {
foreach my $metric ('Transactions') {
push @{$self->{az_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) = @_;
@ -68,14 +66,13 @@ sub new {
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
"resource:s@" => { name => 'resource' },
"resource-group:s" => { name => 'resource_group' },
"resource-namespace:s" => { name => 'resource_namespace' },
"filter-metric:s" => { name => 'filter_metric' },
});
$options{options}->add_options(arguments => {
"resource:s@" => { name => 'resource' },
"resource-group:s" => { name => 'resource_group' },
"resource-namespace:s" => { name => 'resource_namespace' },
"filter-metric:s" => { name => 'filter_metric' },
});
return $self;
}
@ -111,8 +108,6 @@ sub check_options {
push @{$self->{az_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) = @_;
@ -55,7 +53,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-' . $self->{result_values}->{metric_label} . "-" . $self->{result_values}->{stat}, exit_litteral => 'critical' },
{ label => 'warning-' . $self->{result_values}->{metric_label} . "-" . $self->{result_values}->{stat}, exit_litteral => 'warning' } ]);
return $exit;
@ -68,8 +66,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 => $self->{result_values}->{metric_perf} . "_" . $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-' . $self->{result_values}->{metric_label} . "-" . $self->{result_values}->{stat}),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{result_values}->{metric_label} . "-" . $self->{result_values}->{stat}),
min => 0
@ -80,7 +78,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_name} . ": " . $value . ' ' . $unit . "/s";
} else {
@ -122,15 +120,14 @@ sub new {
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
"resource:s@" => { name => 'resource' },
"resource-group:s" => { name => 'resource_group' },
"resource-namespace:s" => { name => 'resource_namespace' },
"filter-metric:s" => { name => 'filter_metric' },
"per-sec" => { name => 'per_sec' },
});
$options{options}->add_options(arguments => {
"resource:s@" => { name => 'resource' },
"resource-group:s" => { name => 'resource_group' },
"resource-namespace:s" => { name => 'resource_namespace' },
"filter-metric:s" => { name => 'filter_metric' },
"per-sec" => { name => 'per_sec' },
});
return $self;
}
@ -166,8 +163,6 @@ sub check_options {
push @{$self->{az_metrics}}, $metric;
}
$instance_mode = $self;
}
sub manage_selection {

View File

@ -26,8 +26,6 @@ use strict;
use warnings;
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold);
my $instance_mode;
sub custom_pod_status_output {
my ($self, %options) = @_;
@ -69,7 +67,7 @@ sub custom_ready_perfdata {
my $extra_label = '';
$extra_label = '_' . $self->{result_values}->{display} if (!defined($options{extra_instance}) || $options{extra_instance} != 0);
my %total_options = ();
if ($self->{result_values}->{total} > 0 && $instance_mode->{option_results}->{units} eq '%') {
if ($self->{result_values}->{total} > 0 && $self->{instance_mode}->{option_results}->{units} eq '%') {
$total_options{total} = $self->{result_values}->{total};
$total_options{cast_int} = 1;
}
@ -86,7 +84,7 @@ sub custom_ready_threshold {
my ($exit, $threshold_value);
$threshold_value = $self->{result_values}->{ready};
if ($instance_mode->{option_results}->{units} eq '%') {
if ($self->{instance_mode}->{option_results}->{units} eq '%') {
$threshold_value = $self->{result_values}->{prct_ready};
}
$exit = $self->{perfdata}->threshold_check(value => $threshold_value, threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' },
@ -222,9 +220,7 @@ sub check_options {
$self->SUPER::check_options(%options);
$self->change_macros(macros => ['warning_pod_status', 'critical_pod_status',
'warning_container_status', 'critical_container_status']);
$instance_mode = $self;
'warning_container_status', 'critical_container_status']);
}
sub manage_selection {

View File

@ -25,13 +25,11 @@ use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
my $instance_mode;
sub custom_active_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_active_threshold {
my ($self, %options) = @_;
my $threshold_value = $self->{result_values}->{active};
if ($instance_mode->{option_results}->{units} eq '%') {
if ($self->{instance_mode}->{option_results}->{units} eq '%') {
$threshold_value = $self->{result_values}->{prct_active};
}
my $exit = $self->{perfdata}->threshold_check(value => $threshold_value,
@ -176,23 +174,15 @@ sub new {
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
"filter-mailbox:s" => { name => 'filter_mailbox' },
"units:s" => { name => 'units', default => '%' },
"filter-counters:s" => { name => 'filter_counters', default => 'active|total' },
});
$options{options}->add_options(arguments => {
"filter-mailbox:s" => { name => 'filter_mailbox' },
"units:s" => { name => 'units', default => '%' },
"filter-counters:s" => { name => 'filter_counters', default => 'active|total' },
});
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,13 +25,11 @@ use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
my $instance_mode;
sub custom_active_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_active_threshold {
my ($self, %options) = @_;
my $threshold_value = $self->{result_values}->{active};
if ($instance_mode->{option_results}->{units} eq '%') {
if ($self->{instance_mode}->{option_results}->{units} eq '%') {
$threshold_value = $self->{result_values}->{prct_active};
}
my $exit = $self->{perfdata}->threshold_check(value => $threshold_value,
@ -100,11 +98,11 @@ sub custom_status_threshold {
local $SIG{__WARN__} = sub { $message = $_[0]; };
local $SIG{__DIE__} = sub { $message = $_[0]; };
if (defined($instance_mode->{option_results}->{critical_status}) && $instance_mode->{option_results}->{critical_status} ne '' &&
eval "$instance_mode->{option_results}->{critical_status}") {
if (defined($self->{instance_mode}->{option_results}->{critical_status}) && $self->{instance_mode}->{option_results}->{critical_status} ne '' &&
eval "$self->{instance_mode}->{option_results}->{critical_status}") {
$status = 'critical';
} elsif (defined($instance_mode->{option_results}->{warning_status}) && $instance_mode->{option_results}->{warning_status} ne '' &&
eval "$instance_mode->{option_results}->{warning_status}") {
} elsif (defined($self->{instance_mode}->{option_results}->{warning_status}) && $self->{instance_mode}->{option_results}->{warning_status} ne '' &&
eval "$self->{instance_mode}->{option_results}->{warning_status}") {
$status = 'warning';
}
};
@ -223,34 +221,22 @@ sub new {
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
"filter-mailbox:s" => { name => 'filter_mailbox' },
"warning-status:s" => { name => 'warning_status', default => '%{used} > %{issue_warning_quota}' },
"critical-status:s" => { name => 'critical_status', default => '%{used} > %{prohibit_send_quota}' },
"units:s" => { name => 'units', default => '%' },
"filter-counters:s" => { name => 'filter_counters', default => 'active|total' },
});
$options{options}->add_options(arguments => {
"filter-mailbox:s" => { name => 'filter_mailbox' },
"warning-status:s" => { name => 'warning_status', default => '%{used} > %{issue_warning_quota}' },
"critical-status:s" => { name => 'critical_status', default => '%{used} > %{prohibit_send_quota}' },
"units:s" => { name => 'units', default => '%' },
"filter-counters:s" => { name => 'filter_counters', default => 'active|total' },
});
return $self;
}
sub change_macros {
my ($self, %options) = @_;
foreach (('warning_status', 'critical_status')) {
if (defined($self->{option_results}->{$_})) {
$self->{option_results}->{$_} =~ s/%\{(.*?)\}/\$self->{result_values}->{$1}/g;
}
}
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::check_options(%options);
$instance_mode = $self;
$self->change_macros();
$self->change_macros(macros => ['warning_status', 'critical_status']);
}
sub manage_selection {

View File

@ -25,13 +25,11 @@ use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
my $instance_mode;
sub custom_active_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_active_threshold {
my ($self, %options) = @_;
my $threshold_value = $self->{result_values}->{active};
if ($instance_mode->{option_results}->{units} eq '%') {
if ($self->{instance_mode}->{option_results}->{units} eq '%') {
$threshold_value = $self->{result_values}->{prct_active};
}
my $exit = $self->{perfdata}->threshold_check(value => $threshold_value,
@ -98,10 +96,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' },
@ -250,23 +248,15 @@ sub new {
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
"filter-url:s" => { name => 'filter_url' },
"filter-owner:s" => { name => 'filter_owner' },
"units:s" => { name => 'units', default => '%' },
"free" => { name => 'free' },
"filter-counters:s" => { name => 'filter_counters', default => 'active-sites|total' },
});
return $self;
}
$options{options}->add_options(arguments => {
"filter-url:s" => { name => 'filter_url' },
"filter-owner:s" => { name => 'filter_owner' },
"units:s" => { name => 'units', default => '%' },
"free" => { name => 'free' },
"filter-counters:s" => { name => 'filter_counters', default => 'active-sites|total' },
});
sub check_options {
my ($self, %options) = @_;
$self->SUPER::check_options(%options);
$instance_mode = $self;
return $self;
}
sub manage_selection {

View File

@ -25,13 +25,11 @@ use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
my $instance_mode;
sub custom_active_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_active_threshold {
my ($self, %options) = @_;
my $threshold_value = $self->{result_values}->{active};
if ($instance_mode->{option_results}->{units} eq '%') {
if ($self->{instance_mode}->{option_results}->{units} eq '%') {
$threshold_value = $self->{result_values}->{prct_active};
}
my $exit = $self->{perfdata}->threshold_check(value => $threshold_value,
@ -98,10 +96,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' },
@ -286,23 +284,15 @@ sub new {
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
"filter-url:s" => { name => 'filter_url' },
"filter-id:s" => { name => 'filter_id' },
"units:s" => { name => 'units', default => '%' },
"free" => { name => 'free' },
"filter-counters:s" => { name => 'filter_counters', default => 'active-sites|total' },
});
return $self;
}
$options{options}->add_options(arguments => {
"filter-url:s" => { name => 'filter_url' },
"filter-id:s" => { name => 'filter_id' },
"units:s" => { name => 'units', default => '%' },
"free" => { name => 'free' },
"filter-counters:s" => { name => 'filter_counters', default => 'active-sites|total' },
});
sub check_options {
my ($self, %options) = @_;
$self->SUPER::check_options(%options);
$instance_mode = $self;
return $self;
}
sub manage_selection {

View File

@ -25,13 +25,11 @@ use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
my $instance_mode;
sub custom_active_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_active_threshold {
my ($self, %options) = @_;
my $threshold_value = $self->{result_values}->{active};
if ($instance_mode->{option_results}->{units} eq '%') {
if ($self->{instance_mode}->{option_results}->{units} eq '%') {
$threshold_value = $self->{result_values}->{prct_active};
}
my $exit = $self->{perfdata}->threshold_check(value => $threshold_value,
@ -212,23 +210,15 @@ sub new {
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
"filter-user:s" => { name => 'filter_user' },
"units:s" => { name => 'units', default => '%' },
"filter-counters:s" => { name => 'filter_counters', default => 'active|total' },
});
$options{options}->add_options(arguments => {
"filter-user:s" => { name => 'filter_user' },
"units:s" => { name => 'units', default => '%' },
"filter-counters:s" => { name => 'filter_counters', default => 'active|total' },
});
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,13 +25,11 @@ use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
my $instance_mode;
sub custom_active_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_active_threshold {
my ($self, %options) = @_;
my $threshold_value = $self->{result_values}->{active};
if ($instance_mode->{option_results}->{units} eq '%') {
if ($self->{instance_mode}->{option_results}->{units} eq '%') {
$threshold_value = $self->{result_values}->{prct_active};
}
my $exit = $self->{perfdata}->threshold_check(value => $threshold_value,
@ -158,23 +156,14 @@ sub new {
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
"filter-user:s" => { name => 'filter_user' },
"units:s" => { name => 'units', default => '%' },
"filter-counters:s" => { name => 'filter_counters' },
});
$options{options}->add_options(arguments => {
"filter-user:s" => { name => 'filter_user' },
"units:s" => { name => 'units', default => '%' },
});
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,13 +25,11 @@ use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
my $instance_mode;
sub custom_active_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_active_threshold {
my ($self, %options) = @_;
my $threshold_value = $self->{result_values}->{active};
if ($instance_mode->{option_results}->{units} eq '%') {
if ($self->{instance_mode}->{option_results}->{units} eq '%') {
$threshold_value = $self->{result_values}->{prct_active};
}
my $exit = $self->{perfdata}->threshold_check(value => $threshold_value,
@ -176,23 +174,15 @@ sub new {
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
"filter-user:s" => { name => 'filter_user' },
"units:s" => { name => 'units', default => '%' },
"filter-counters:s" => { name => 'filter_counters', default => 'active|total' },
});
$options{options}->add_options(arguments => {
"filter-user:s" => { name => 'filter_user' },
"units:s" => { name => 'units', default => '%' },
"filter-counters:s" => { name => 'filter_counters', default => 'active|total' },
});
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,13 +25,11 @@ use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
my $instance_mode;
sub custom_active_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_active_threshold {
my ($self, %options) = @_;
my $threshold_value = $self->{result_values}->{active};
if ($instance_mode->{option_results}->{units} eq '%') {
if ($self->{instance_mode}->{option_results}->{units} eq '%') {
$threshold_value = $self->{result_values}->{prct_active};
}
my $exit = $self->{perfdata}->threshold_check(value => $threshold_value,
@ -167,23 +165,14 @@ sub new {
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
"filter-user:s" => { name => 'filter_user' },
"units:s" => { name => 'units', default => '%' },
"filter-counters:s" => { name => 'filter_counters' },
});
$options{options}->add_options(arguments => {
"filter-user:s" => { name => 'filter_user' },
"units:s" => { name => 'units', default => '%' },
});
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,13 +25,11 @@ use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
my $instance_mode;
sub custom_active_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_active_threshold {
my ($self, %options) = @_;
my $threshold_value = $self->{result_values}->{active};
if ($instance_mode->{option_results}->{units} eq '%') {
if ($self->{instance_mode}->{option_results}->{units} eq '%') {
$threshold_value = $self->{result_values}->{prct_active};
}
my $exit = $self->{perfdata}->threshold_check(value => $threshold_value,
@ -194,23 +192,15 @@ sub new {
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
"filter-user:s" => { name => 'filter_user' },
"units:s" => { name => 'units', default => '%' },
"filter-counters:s" => { name => 'filter_counters', default => 'active|total' },
});
$options{options}->add_options(arguments => {
"filter-user:s" => { name => 'filter_user' },
"units:s" => { name => 'units', default => '%' },
"filter-counters:s" => { name => 'filter_counters', default => 'active|total' },
});
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 custom_usage_perfdata {
my ($self, %options) = @_;
@ -35,7 +33,7 @@ sub custom_usage_perfdata {
my $extra_label = '';
$extra_label = '_' . $self->{result_values}->{perf} if (!defined($options{extra_instance}) || $options{extra_instance} != 0);
my %total_options = ();
if ($self->{result_values}->{total} > 0 && $instance_mode->{option_results}->{units} eq '%') {
if ($self->{result_values}->{total} > 0 && $self->{instance_mode}->{option_results}->{units} eq '%') {
$total_options{total} = $self->{result_values}->{total};
$total_options{cast_int} = 1;
}
@ -50,10 +48,10 @@ sub custom_usage_perfdata {
sub custom_usage_threshold {
my ($self, %options) = @_;
return 'ok' if ($self->{result_values}->{total} <= 0 && $instance_mode->{option_results}->{units} eq '%');
return 'ok' if ($self->{result_values}->{total} <= 0 && $self->{instance_mode}->{option_results}->{units} eq '%');
my ($exit, $threshold_value);
$threshold_value = $self->{result_values}->{used};
if ($instance_mode->{option_results}->{units} eq '%') {
if ($self->{instance_mode}->{option_results}->{units} eq '%') {
$threshold_value = $self->{result_values}->{prct_used};
}
$exit = $self->{perfdata}->threshold_check(value => $threshold_value, threshold => [ { label => 'critical-' . $self->{result_values}->{label}, exit_litteral => 'critical' },
@ -168,16 +166,15 @@ sub new {
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
"container:s" => { name => 'container', default => 'container_name!~".*POD.*"' },
"pod:s" => { name => 'pod', default => 'pod_name=~".*"' },
"extra-filter:s@" => { name => 'extra_filter' },
"units:s" => { name => 'units', default => '%' },
"metric-overload:s@" => { name => 'metric_overload' },
"filter-counters:s" => { name => 'filter_counters' },
});
$options{options}->add_options(arguments => {
"container:s" => { name => 'container', default => 'container_name!~".*POD.*"' },
"pod:s" => { name => 'pod', default => 'pod_name=~".*"' },
"extra-filter:s@" => { name => 'extra_filter' },
"units:s" => { name => 'units', default => '%' },
"metric-overload:s@" => { name => 'metric_overload' },
"filter-counters:s" => { name => 'filter_counters' },
});
return $self;
}
@ -210,9 +207,7 @@ sub check_options {
$self->{extra_filter} = '';
foreach my $filter (@{$self->{option_results}->{extra_filter}}) {
$self->{extra_filter} .= ',' . $filter;
}
$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_usage_perfdata {
my ($self, %options) = @_;
@ -34,12 +32,12 @@ sub custom_usage_perfdata {
$extra_label = '_' . $self->{result_values}->{label} if (!defined($options{extra_instance}) || $options{extra_instance} != 0);
my $label = 'used';
my $value_perf = $self->{result_values}->{used};
if (defined($instance_mode->{option_results}->{free})) {
if (defined($self->{instance_mode}->{option_results}->{free})) {
$label = 'free';
$value_perf = $self->{result_values}->{free};
}
my %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;
@ -149,17 +147,16 @@ sub new {
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
"container:s" => { name => 'container', default => 'container_name!~".*POD.*"' },
"pod:s" => { name => 'pod', default => 'pod_name=~".*"' },
"device:s" => { name => 'device', default => 'device=~".*"' },
"extra-filter:s@" => { name => 'extra_filter' },
"units:s" => { name => 'units', default => '%' },
"free" => { name => 'free' },
"metric-overload:s@" => { name => 'metric_overload' },
});
$options{options}->add_options(arguments => {
"container:s" => { name => 'container', default => 'container_name!~".*POD.*"' },
"pod:s" => { name => 'pod', default => 'pod_name=~".*"' },
"device:s" => { name => 'device', default => 'device=~".*"' },
"extra-filter:s@" => { name => 'extra_filter' },
"units:s" => { name => 'units', default => '%' },
"free" => { name => 'free' },
"metric-overload:s@" => { name => 'metric_overload' },
});
return $self;
}
@ -188,9 +185,7 @@ sub check_options {
$self->{extra_filter} = '';
foreach my $filter (@{$self->{option_results}->{extra_filter}}) {
$self->{extra_filter} .= ',' . $filter;
}
$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_usage_perfdata {
my ($self, %options) = @_;
@ -35,7 +33,7 @@ sub custom_usage_perfdata {
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;
}
@ -52,7 +50,7 @@ sub custom_usage_threshold {
my ($exit, $threshold_value);
$threshold_value = $self->{result_values}->{used};
if ($instance_mode->{option_results}->{units} eq '%') {
if ($self->{instance_mode}->{option_results}->{units} eq '%') {
$threshold_value = $self->{result_values}->{prct_used};
}
$exit = $self->{perfdata}->threshold_check(value => $threshold_value, threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' },
@ -137,15 +135,13 @@ sub new {
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
"instance:s" => { name => 'instance', default => 'instance=~".*"' },
"units:s" => { name => 'units', default => '%' },
"extra-filter:s@" => { name => 'extra_filter' },
"metric-overload:s@" => { name => 'metric_overload' },
"filter-counters:s" => { name => 'filter_counters' },
});
$options{options}->add_options(arguments => {
"instance:s" => { name => 'instance', default => 'instance=~".*"' },
"units:s" => { name => 'units', default => '%' },
"extra-filter:s@" => { name => 'extra_filter' },
"metric-overload:s@" => { name => 'metric_overload' },
});
return $self;
}
@ -176,9 +172,7 @@ sub check_options {
$self->{extra_filter} = '';
foreach my $filter (@{$self->{option_results}->{extra_filter}}) {
$self->{extra_filter} .= ',' . $filter;
}
$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_usage_perfdata {
my ($self, %options) = @_;
@ -34,12 +32,12 @@ sub custom_usage_perfdata {
$extra_label = '_' . $self->{result_values}->{label} if (!defined($options{extra_instance}) || $options{extra_instance} != 0);
my $label = 'used';
my $value_perf = $self->{result_values}->{used};
if (defined($instance_mode->{option_results}->{free})) {
if (defined($self->{instance_mode}->{option_results}->{free})) {
$label = 'free';
$value_perf = $self->{result_values}->{free};
}
my %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;
@ -149,17 +147,16 @@ sub new {
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
"instance:s" => { name => 'instance', default => 'instance=~".*"' },
"mountpoint:s" => { name => 'mountpoint', default => 'mountpoint=~".*"' },
"fstype:s" => { name => 'fstype', default => 'fstype!~"linuxfs|rootfs|tmpfs"' },
"units:s" => { name => 'units', default => '%' },
"free" => { name => 'free' },
"extra-filter:s@" => { name => 'extra_filter' },
"metric-overload:s@" => { name => 'metric_overload' },
});
$options{options}->add_options(arguments => {
"instance:s" => { name => 'instance', default => 'instance=~".*"' },
"mountpoint:s" => { name => 'mountpoint', default => 'mountpoint=~".*"' },
"fstype:s" => { name => 'fstype', default => 'fstype!~"linuxfs|rootfs|tmpfs"' },
"units:s" => { name => 'units', default => '%' },
"free" => { name => 'free' },
"extra-filter:s@" => { name => 'extra_filter' },
"metric-overload:s@" => { name => 'metric_overload' },
});
return $self;
}
@ -188,9 +185,7 @@ sub check_options {
$self->{extra_filter} = '';
foreach my $filter (@{$self->{option_results}->{extra_filter}}) {
$self->{extra_filter} .= ',' . $filter;
}
$instance_mode = $self;
}
}
sub manage_selection {