wip aws health service
This commit is contained in:
parent
df69f26234
commit
8758a19a02
|
@ -641,6 +641,38 @@ sub vpn_list_connections {
|
||||||
return $connections_results;
|
return $connections_results;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub health_describe_events_set_cmd {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
return if (defined($self->{option_results}->{command_options}) && $self->{option_results}->{command_options} ne '');
|
||||||
|
|
||||||
|
my $cmd_options = "health describe-events --region $self->{option_results}->{region} --output json";
|
||||||
|
|
||||||
|
my ($filter, $filter_append) = ('', '');
|
||||||
|
foreach ((['service', 'services'], ['region', 'regions'], ['entity_value', 'entityValues'], ['event_status', 'eventStatusCodes'])) {
|
||||||
|
next if (!defined($options{ $_->[0] }));
|
||||||
|
|
||||||
|
foreach my $entry (@{$options{ $_->[0] }}) {
|
||||||
|
$filter .= $filter_append . $_->[1] . '=' . $entry;
|
||||||
|
$filter_append = ',';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$cmd_options .= " --filter '$filter'" if ($filter ne '');
|
||||||
|
$cmd_options .= " --endpoint-url $self->{endpoint_url}" if (defined($self->{endpoint_url}) && $self->{endpoint_url} ne '');
|
||||||
|
|
||||||
|
return $cmd_options;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub health_describe_events {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
my $cmd_options = $self->health_describe_events_set_cmd(%options);
|
||||||
|
my $raw_results = $self->execute(cmd_options => $cmd_options);
|
||||||
|
|
||||||
|
return $raw_results->{events};
|
||||||
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|
||||||
__END__
|
__END__
|
||||||
|
|
|
@ -0,0 +1,173 @@
|
||||||
|
#
|
||||||
|
# Copyright 2020 Centreon (http://www.centreon.com/)
|
||||||
|
#
|
||||||
|
# Centreon is a full-fledged industry-strength solution that meets
|
||||||
|
# the needs in IT infrastructure and application monitoring for
|
||||||
|
# service performance.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
#
|
||||||
|
|
||||||
|
package cloud::aws::health::mode::events;
|
||||||
|
|
||||||
|
use base qw(centreon::plugins::templates::counter);
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
|
||||||
|
sub prefix_global_output {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
return 'Events ';
|
||||||
|
}
|
||||||
|
|
||||||
|
sub set_counters {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
$self->{maps_counters_type} = [
|
||||||
|
{ name => 'global', cb_prefix_output => 'prefix_global_output', type => 0 },
|
||||||
|
|
||||||
|
];
|
||||||
|
|
||||||
|
$self->{maps_counters}->{global} = [
|
||||||
|
{ label => 'total', nlabel => 'events.total.count', set => {
|
||||||
|
key_values => [ { name => 'total' } ],
|
||||||
|
output_template => 'total: %s',
|
||||||
|
perfdatas => [
|
||||||
|
{ template => '%s', min => 0 }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ label => 'open', nlabel => 'events.open.count', set => {
|
||||||
|
key_values => [ { name => 'open' } ],
|
||||||
|
output_template => 'open: %s',
|
||||||
|
perfdatas => [
|
||||||
|
{ template => '%s', min => 0 }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ label => 'closed', nlabel => 'events.closed.count', set => {
|
||||||
|
key_values => [ { name => 'closed' } ],
|
||||||
|
output_template => 'closed: %s',
|
||||||
|
perfdatas => [
|
||||||
|
{ template => '%s', min => 0 }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ label => 'upcoming', nlabel => 'events.upcoming.count', set => {
|
||||||
|
key_values => [ { name => 'upcoming' } ],
|
||||||
|
output_template => 'upcoming: %s',
|
||||||
|
perfdatas => [
|
||||||
|
{ template => '%s', min => 0 }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
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 => {
|
||||||
|
'filter-service:s@' => { name => 'filter_service' },
|
||||||
|
'filter-region:s@' => { name => 'filter_region' },
|
||||||
|
'filter-entity-value:s@' => { name => 'filter_entity_value' },
|
||||||
|
'filter-event-status:s@' => { name => 'filter_event_status' }
|
||||||
|
});
|
||||||
|
|
||||||
|
return $self;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub check_options {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
$self->SUPER::check_options(%options);
|
||||||
|
|
||||||
|
$self->{filter_options} = {};
|
||||||
|
foreach (('service', 'region', 'entity_value', 'event_status')) {
|
||||||
|
$self->{filter_options}->{'filter_' . $_} = undef;
|
||||||
|
if (defined($self->{option_results}->{'filter_' . $_})) {
|
||||||
|
foreach my $option (@{$self->{option_results}->{'filter_' . $_}}) {
|
||||||
|
next if ($options eq '');
|
||||||
|
|
||||||
|
$self->{filter_options}->{'filter_' . $_} = [] if (!defined($self->{'filter_' . $_}));
|
||||||
|
push @{$self->{filter_options}->{'filter_' . $_}}, $option;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sub manage_selection {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
my $results = $options{custom}->health_describe_events(
|
||||||
|
%{$self->{filter_options}}
|
||||||
|
);
|
||||||
|
|
||||||
|
$self->{global} = { total => 0, open => 0, closed => 0, upcoming => 0 };
|
||||||
|
foreach my $entry (@$results) {
|
||||||
|
$self->{global}->{ lc($entry->{statusCode}) }++;
|
||||||
|
$self->{global}->{total}++;
|
||||||
|
|
||||||
|
$self->{output}->output_add(long_msg =>
|
||||||
|
sprintf(
|
||||||
|
'[service: %s][region: %s][status: %s][type: %s][start: %s]',
|
||||||
|
$entry->{service},
|
||||||
|
$entry->{region},
|
||||||
|
$entry->{statusCode},
|
||||||
|
$entry->{eventTypeCode},
|
||||||
|
$entry->{startTime}
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
1;
|
||||||
|
|
||||||
|
__END__
|
||||||
|
|
||||||
|
=head1 MODE
|
||||||
|
|
||||||
|
Check health events.
|
||||||
|
|
||||||
|
=over 8
|
||||||
|
|
||||||
|
=item B<--filter-service>
|
||||||
|
|
||||||
|
Filter result by service (multiple option).
|
||||||
|
Example: --filter-service=EC2 --filter-service=RDS
|
||||||
|
|
||||||
|
=item B<--filter-region>
|
||||||
|
|
||||||
|
Filter result by region (multiple option).
|
||||||
|
Example: --filter-region=ap-southeast-1 --filter-region=eu-west-1
|
||||||
|
|
||||||
|
=item B<--filter-entity-value>
|
||||||
|
|
||||||
|
Filter result by entity value (multiple option).
|
||||||
|
Example: --filter-entity-value=i-34ab692e --filter-entity-value=vol-426ab23e
|
||||||
|
|
||||||
|
=item B<--filter-event-status>
|
||||||
|
|
||||||
|
Filter result by event status (multiple option).
|
||||||
|
Example: --filter-event-status=open --filter-event-status=closed
|
||||||
|
|
||||||
|
=item B<--warning-*> B<--critical-*>
|
||||||
|
|
||||||
|
Thresholds.
|
||||||
|
Can be: 'total', 'open', 'closed', 'upcoming'.
|
||||||
|
|
||||||
|
=back
|
||||||
|
|
||||||
|
=cut
|
|
@ -0,0 +1,50 @@
|
||||||
|
#
|
||||||
|
# Copyright 2020 Centreon (http://www.centreon.com/)
|
||||||
|
#
|
||||||
|
# Centreon is a full-fledged industry-strength solution that meets
|
||||||
|
# the needs in IT infrastructure and application monitoring for
|
||||||
|
# service performance.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
#
|
||||||
|
|
||||||
|
package cloud::aws::health::plugin;
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
use base qw(centreon::plugins::script_custom);
|
||||||
|
|
||||||
|
sub new {
|
||||||
|
my ( $class, %options ) = @_;
|
||||||
|
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||||
|
bless $self, $class;
|
||||||
|
|
||||||
|
$self->{version} = '0.1';
|
||||||
|
$self->{modes} = {
|
||||||
|
'events' => 'cloud::aws::health::mode::events'
|
||||||
|
};
|
||||||
|
|
||||||
|
$self->{custom_modes}->{paws} = 'cloud::aws::custom::paws';
|
||||||
|
$self->{custom_modes}->{awscli} = 'cloud::aws::custom::awscli';
|
||||||
|
return $self;
|
||||||
|
}
|
||||||
|
|
||||||
|
1;
|
||||||
|
|
||||||
|
__END__
|
||||||
|
|
||||||
|
=head1 PLUGIN DESCRIPTION
|
||||||
|
|
||||||
|
Check Amazon Health service.
|
||||||
|
|
||||||
|
=cut
|
Loading…
Reference in New Issue