From 54a8a34fdfe9bc2b568714bb093386dfa6d7b960 Mon Sep 17 00:00:00 2001 From: Sims24 Date: Mon, 23 Sep 2019 17:33:20 +0200 Subject: [PATCH] feat(disco) add kinesis, apigateway, dynamodb discovery --- .../cloud/aws/cloudwatch/mode/discovery.pm | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/centreon-plugins/cloud/aws/cloudwatch/mode/discovery.pm b/centreon-plugins/cloud/aws/cloudwatch/mode/discovery.pm index 8c696cc49..ca990a8f5 100644 --- a/centreon-plugins/cloud/aws/cloudwatch/mode/discovery.pm +++ b/centreon-plugins/cloud/aws/cloudwatch/mode/discovery.pm @@ -42,6 +42,9 @@ sub new { RDS => $self->can('discover_rds'), ELB => $self->can('discover_elb'), VPN => $self->can('discover_vpn'), + KINESIS => $self->can('discover_kinesis_stream'), + DYNAMODB => $self->can('discover_dynamodb_table'), + APIGATEWAY => $self->can('discover_api') }; return $self; @@ -193,6 +196,66 @@ sub discover_vpn { return @disco_data; } +sub discover_kinesis_stream { + my (%options) = @_; + + my @disco_data; + + my $streams = $options{custom}->discovery(region => $options{region}, + service => 'kinesis', command => 'list-streams'); + + foreach my $stream (@{$streams->{StreamNames}}) { + my %stream; + $stream{type} = "kinesis_stream"; + $stream{name} = $stream; + push @disco_data, \%stream; + } + + return @disco_data; +} + +sub discover_dynamodb_table { + my (%options) = @_; + + my @disco_data; + + my $tables = $options{custom}->discovery(region => $options{region}, + service => 'dynamodb', command => 'list-tables'); + + foreach my $table (@{$tables->{TableNames}}) { + my %table; + $table{type} = "dynamodb_table"; + $table{name} = $table; + push @disco_data, \%table; + } + + return @disco_data; +} + +sub discover_api { + my (%options) = @_; + + my @disco_data; + + my $apis = $options{custom}->discovery(region => $options{region}, + service => 'apigateway', command => 'get-rest-apis'); + + foreach my $api (@{$apis->{items}}) { + my %api; + $api{id} = $api->{id}; + $api{name} = $api->{name}; + $api{description} = $api->{description}; + $api{version} = $api->{version}; + foreach my $type (@{$api->{endpointConfiguration}->{types}}) { + push @{$api{types}}, $type; + } + + push @disco_data, \%api; + } + + return @disco_data; +} + sub run { my ($self, %options) = @_;