(plugin) cloud::aws::elasticache - update discovery (#4145)
This commit is contained in:
parent
bbe28a7931
commit
ec9ef04f73
|
@ -40,6 +40,7 @@ sub new {
|
||||||
BACKUP_VAULT => $self->can('discover_backup_vault'),
|
BACKUP_VAULT => $self->can('discover_backup_vault'),
|
||||||
# DYNAMODB => $self->can('discover_dynamodb_table'),
|
# DYNAMODB => $self->can('discover_dynamodb_table'),
|
||||||
CLOUDFRONT => $self->can('discover_cloudfront'),
|
CLOUDFRONT => $self->can('discover_cloudfront'),
|
||||||
|
ELASTICACHE => $self->can('discover_elasticache'),
|
||||||
EBS => $self->can('discover_ebs'),
|
EBS => $self->can('discover_ebs'),
|
||||||
EC2 => $self->can('discover_ec2'),
|
EC2 => $self->can('discover_ec2'),
|
||||||
EFS => $self->can('discover_efs'),
|
EFS => $self->can('discover_efs'),
|
||||||
|
@ -64,7 +65,6 @@ sub new {
|
||||||
sub check_options {
|
sub check_options {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
$self->SUPER::init(%options);
|
$self->SUPER::init(%options);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub discover_vpc {
|
sub discover_vpc {
|
||||||
|
@ -72,8 +72,11 @@ sub discover_vpc {
|
||||||
|
|
||||||
my @disco_data;
|
my @disco_data;
|
||||||
|
|
||||||
my $vpcs = $options{custom}->discovery(region => $options{region},
|
my $vpcs = $options{custom}->discovery(
|
||||||
service => 'ec2', command => 'describe-vpcs');
|
region => $options{region},
|
||||||
|
service => 'ec2',
|
||||||
|
command => 'describe-vpcs'
|
||||||
|
);
|
||||||
foreach my $vpc (@{$vpcs->{Vpcs}}) {
|
foreach my $vpc (@{$vpcs->{Vpcs}}) {
|
||||||
next if (!defined($vpc->{VpcId}));
|
next if (!defined($vpc->{VpcId}));
|
||||||
my %vpc;
|
my %vpc;
|
||||||
|
@ -138,6 +141,15 @@ sub discover_cloudfront {
|
||||||
return \@disco_data, \@disco_keys;
|
return \@disco_data, \@disco_keys;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub discover_elasticache {
|
||||||
|
my (%options) = @_;
|
||||||
|
|
||||||
|
use cloud::aws::elasticache::mode::discovery;
|
||||||
|
my @disco_data = cloud::aws::elasticache::mode::discovery->run(custom => $options{custom}, discover => 1);
|
||||||
|
my @disco_keys = keys %{$disco_data[0]} if (@disco_data != 0);
|
||||||
|
return \@disco_data, \@disco_keys;
|
||||||
|
}
|
||||||
|
|
||||||
sub discover_ebs {
|
sub discover_ebs {
|
||||||
my (%options) = @_;
|
my (%options) = @_;
|
||||||
|
|
||||||
|
|
|
@ -894,6 +894,26 @@ sub cloudfront_list_distributions {
|
||||||
return $results;
|
return $results;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub elasticache_describe_cache_clusters {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
my $cmd_options = $self->discovery_set_cmd(service => 'elasticache', command => 'describe-cache-clusters');
|
||||||
|
my $raw_results = $self->execute(cmd_options => $cmd_options);
|
||||||
|
|
||||||
|
my $results = [];
|
||||||
|
foreach (@{$raw_results->{CacheClusters}}) {
|
||||||
|
push @$results, {
|
||||||
|
CacheClusterId => $_->{CacheClusterId},
|
||||||
|
Engine => $_->{Engine},
|
||||||
|
EngineVersion => $_->{EngineVersion},
|
||||||
|
ReplicationGroupLogDeliveryEnabled => $_->{ReplicationGroupLogDeliveryEnabled},
|
||||||
|
SecurityGroups => $_->{SecurityGroups}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return $results;
|
||||||
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|
||||||
__END__
|
__END__
|
||||||
|
|
|
@ -762,6 +762,33 @@ sub cloudfront_list_distributions {
|
||||||
return $results;
|
return $results;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub elasticache_describe_cache_clusters {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
my $results = [];
|
||||||
|
eval {
|
||||||
|
my $ec = $self->{paws}->service('ElastiCache', region => $self->{option_results}->{region});
|
||||||
|
my $cacheClusterMessage = $ec->DescribeCacheClusters();
|
||||||
|
my $cacheClusters = $cacheClusterMessage->CacheClusters;
|
||||||
|
|
||||||
|
foreach (@$cacheClusters) {
|
||||||
|
push @$results, {
|
||||||
|
CacheClusterId => $_->{CacheClusterId},
|
||||||
|
Engine => $_->{Engine},
|
||||||
|
EngineVersion => $_->{EngineVersion},
|
||||||
|
ReplicationGroupLogDeliveryEnabled => $_->{ReplicationGroupLogDeliveryEnabled},
|
||||||
|
SecurityGroups => $_->{SecurityGroups}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
if ($@) {
|
||||||
|
$self->{output}->add_option_msg(short_msg => "error: $@");
|
||||||
|
$self->{output}->option_exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $results;
|
||||||
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|
||||||
__END__
|
__END__
|
||||||
|
|
|
@ -1,3 +1,23 @@
|
||||||
|
#
|
||||||
|
# Copyright 2023 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::elasticache::mode::discovery;
|
package cloud::aws::elasticache::mode::discovery;
|
||||||
|
|
||||||
use base qw(centreon::plugins::mode);
|
use base qw(centreon::plugins::mode);
|
||||||
|
@ -29,20 +49,17 @@ sub run {
|
||||||
|
|
||||||
$disco_stats->{start_time} = time();
|
$disco_stats->{start_time} = time();
|
||||||
|
|
||||||
my $instances = $options{custom}->discovery(
|
my $instances = $options{custom}->elasticache_describe_cache_clusters();
|
||||||
service => 'elasticache',
|
|
||||||
command => 'describe-cache-clusters'
|
|
||||||
);
|
|
||||||
|
|
||||||
foreach my $ecc_instance (@{$instances->{CacheClusters}}) {
|
foreach my $ecc_instance (@$instances) {
|
||||||
next if (!defined($ecc_instance->{CacheClusterId}));
|
next if (!defined($ecc_instance->{CacheClusterId}));
|
||||||
|
|
||||||
my %ecc;
|
my %ecc;
|
||||||
$ecc{type}= "elasticache";
|
$ecc{type}= 'elasticache';
|
||||||
$ecc{id} = $ecc_instance->{CacheClusterId};
|
$ecc{id} = $ecc_instance->{CacheClusterId};
|
||||||
$ecc{engine} = $ecc_instance->{Engine};
|
$ecc{engine} = $ecc_instance->{Engine};
|
||||||
$ecc{engine_version} = $ecc_instance->{EngineVersion};
|
$ecc{engine_version} = $ecc_instance->{EngineVersion};
|
||||||
$ecc{replication_group_log_delivery_enabled} = $ecc_instance->{ReplicationGroupLogDeliveryEnabled};
|
$ecc{replication_group_log_delivery_enabled} = $ecc_instance->{ReplicationGroupLogDeliveryEnabled} =~ /1|true/i ? 1 : 0;
|
||||||
|
|
||||||
foreach my $secureGroups (@{$ecc_instance->{SecurityGroups}}) {
|
foreach my $secureGroups (@{$ecc_instance->{SecurityGroups}}) {
|
||||||
push @{$ecc{security_groups}}, { status => $secureGroups->{Status}, security_group_id => $secureGroups->{SecurityGroupId} };
|
push @{$ecc{security_groups}}, { status => $secureGroups->{Status}, security_group_id => $secureGroups->{SecurityGroupId} };
|
||||||
}
|
}
|
||||||
|
@ -91,4 +108,3 @@ Prettify JSON output.
|
||||||
=back
|
=back
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
|
|
|
@ -29,8 +29,7 @@ sub new {
|
||||||
my $self = $class->SUPER::new( package => __PACKAGE__, %options );
|
my $self = $class->SUPER::new( package => __PACKAGE__, %options );
|
||||||
bless $self, $class;
|
bless $self, $class;
|
||||||
|
|
||||||
$self->{version} = '0.1';
|
$self->{modes} = {
|
||||||
%{ $self->{modes} } = (
|
|
||||||
'commands-memcached' => 'cloud::aws::elasticache::mode::commandsmemcached',
|
'commands-memcached' => 'cloud::aws::elasticache::mode::commandsmemcached',
|
||||||
'commands-redis' => 'cloud::aws::elasticache::mode::commandsredis',
|
'commands-redis' => 'cloud::aws::elasticache::mode::commandsredis',
|
||||||
'connections' => 'cloud::aws::elasticache::mode::connections',
|
'connections' => 'cloud::aws::elasticache::mode::connections',
|
||||||
|
@ -44,10 +43,10 @@ sub new {
|
||||||
'requests-redis' => 'cloud::aws::elasticache::mode::requestsredis',
|
'requests-redis' => 'cloud::aws::elasticache::mode::requestsredis',
|
||||||
'usage-memcached' => 'cloud::aws::elasticache::mode::usagememcached',
|
'usage-memcached' => 'cloud::aws::elasticache::mode::usagememcached',
|
||||||
'usage-redis' => 'cloud::aws::elasticache::mode::usageredis',
|
'usage-redis' => 'cloud::aws::elasticache::mode::usageredis',
|
||||||
);
|
};
|
||||||
|
|
||||||
$self->{custom_modes}{paws} = 'cloud::aws::custom::paws';
|
$self->{custom_modes}->{paws} = 'cloud::aws::custom::paws';
|
||||||
$self->{custom_modes}{awscli} = 'cloud::aws::custom::awscli';
|
$self->{custom_modes}->{awscli} = 'cloud::aws::custom::awscli';
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue