fix efs path

This commit is contained in:
garnier-quentin 2020-03-31 18:36:35 +02:00 committed by Lotfi zaouche
parent 076c320652
commit 4d16c55602
5 changed files with 26 additions and 24 deletions

View File

@ -97,7 +97,7 @@ sub long_output {
sub set_counters {
my ($self, %options) = @_;
$self->{maps_counters_type} = [
{ name => 'metrics', type => 3, cb_prefix_output => 'prefix_metric_output', cb_long_output => 'long_output',
message_multiple => 'All FS metrics are ok', indent_long_output => ' ',
@ -128,10 +128,11 @@ sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
bless $self, $class;
$options{options}->add_options(arguments => {
"name:s@" => { name => 'name' },
'name:s@' => { name => 'name' },
});
return $self;
}
@ -153,7 +154,7 @@ sub check_options {
$self->{aws_timeframe} = defined($self->{option_results}->{timeframe}) ? $self->{option_results}->{timeframe} : 172800;
$self->{aws_period} = defined($self->{option_results}->{period}) ? $self->{option_results}->{period} : 86400;
$self->{aws_statistics} = ['Sum'];
foreach my $metric (keys %metrics_mapping) {
next if (defined($self->{option_results}->{filter_metric}) && $self->{option_results}->{filter_metric} ne ''
&& $metric !~ /$self->{option_results}->{filter_metric}/);
@ -175,7 +176,7 @@ sub manage_selection {
timeframe => $self->{aws_timeframe},
period => $self->{aws_period},
);
foreach my $metric (@{$self->{aws_metrics}}) {
foreach my $statistic (@{$self->{aws_statistics}}) {
next if (!defined($metric_results{$instance}->{$metric}->{lc($statistic)}) &&

View File

@ -76,7 +76,7 @@ my %metrics_mapping = (
sub custom_metric_calc {
my ($self, %options) = @_;
$self->{result_values}->{timeframe} = $options{new_datas}->{$self->{instance} . '_timeframe'};
$self->{result_values}->{value} = $options{new_datas}->{$self->{instance} . '_' . $options{extra_options}->{metric}};
$self->{result_values}->{value_per_sec} = $self->{result_values}->{value} / $self->{result_values}->{timeframe};
@ -90,7 +90,8 @@ sub custom_metric_threshold {
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-' . $metrics_mapping{$self->{result_values}->{metric}}->{label}, exit_litteral => 'critical' },
{ label => 'warning-' . $metrics_mapping{$self->{result_values}->{metric}}->{label}, exit_litteral => 'warning' } ]);
{ label => 'warning-' . $metrics_mapping{$self->{result_values}->{metric}}->{label}, exit_litteral => 'warning' } ]
);
return $exit;
}
@ -134,13 +135,13 @@ sub custom_metric_output {
sub prefix_metric_output {
my ($self, %options) = @_;
return "'" . $options{instance_value}->{display} . "' ";
}
sub prefix_statistics_output {
my ($self, %options) = @_;
return "Statistic '" . $options{instance_value}->{display} . "' Metrics ";
}
@ -152,7 +153,7 @@ sub long_output {
sub set_counters {
my ($self, %options) = @_;
$self->{maps_counters_type} = [
{ name => 'metrics', type => 3, cb_prefix_output => 'prefix_metric_output', cb_long_output => 'long_output',
message_multiple => 'All FS metrics are ok', indent_long_output => ' ',
@ -183,12 +184,12 @@ sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
bless $self, $class;
$options{options}->add_options(arguments => {
"type:s" => { name => 'type' },
"name:s@" => { name => 'name' },
"per-sec" => { name => 'per_sec' },
"filter-metric:s" => { name => 'filter_metric' },
'type:s' => { name => 'type' },
'name:s@' => { name => 'name' },
'per-sec' => { name => 'per_sec' },
'filter-metric:s' => { name => 'filter_metric' },
});
return $self;
@ -211,7 +212,7 @@ sub check_options {
$self->{aws_timeframe} = defined($self->{option_results}->{timeframe}) ? $self->{option_results}->{timeframe} : 600;
$self->{aws_period} = defined($self->{option_results}->{period}) ? $self->{option_results}->{period} : 60;
$self->{aws_statistics} = ['Average'];
if (defined($self->{option_results}->{statistic})) {
$self->{aws_statistics} = [];

View File

@ -30,11 +30,11 @@ sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$options{options}->add_options(arguments => {
"prettify" => { name => 'prettify' },
'prettify' => { name => 'prettify' }
});
return $self;
}
@ -87,7 +87,7 @@ sub run {
if ($@) {
$encoded_data = '{"code":"encode_error","message":"Cannot encode discovered data into JSON format"}';
}
$self->{output}->output_add(short_msg => $encoded_data);
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1);
$self->{output}->exit();

View File

@ -31,9 +31,9 @@ sub new {
$self->{version} = '1.0';
%{ $self->{modes} } = (
'connections' => 'cloud::aws::efs::mode::connections',
'datausage' => 'cloud::aws::efs::mode::datausage',
'discovery' => 'cloud::aws::efs::mode::discovery'
'connections' => 'cloud::aws::efs::mode::connections',
'datausage' => 'cloud::aws::efs::mode::datausage',
'discovery' => 'cloud::aws::efs::mode::discovery'
);
$self->{custom_modes}{paws} = 'cloud::aws::custom::paws';

View File

@ -235,7 +235,7 @@ sub filter_networks {
}
if (scalar(@$network_ids) > 5) {
$self->{output}->add_option_msg(short_msg => 'cannot check than 5 networks at once');
$self->{output}->add_option_msg(short_msg => 'cannot check than 5 networks at once (api rate limit)');
$self->{output}->option_exit();
}