(plugin) cloud::outscale - new (#4350)
This commit is contained in:
parent
9665ea68c4
commit
69737a11dd
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"dependencies": [
|
||||
"libdatetime-perl"
|
||||
]
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"pkg_name": "centreon-plugin-Cloud-Outscale-Api",
|
||||
"pkg_summary": "Centreon Plugin to monitor Outscale using API",
|
||||
"plugin_name": "centreon_outscale_api.pl",
|
||||
"files": [
|
||||
"centreon/plugins/script_custom.pm",
|
||||
"cloud/outscale/"
|
||||
]
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"dependencies": [
|
||||
"perl(DateTime)"
|
||||
]
|
||||
}
|
|
@ -0,0 +1,403 @@
|
|||
#
|
||||
# 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::outscale::custom::http;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use centreon::plugins::http;
|
||||
use JSON::XS;
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = {};
|
||||
bless $self, $class;
|
||||
|
||||
if (!defined($options{output})) {
|
||||
print "Class Custom: Need to specify 'output' argument.\n";
|
||||
exit 3;
|
||||
}
|
||||
if (!defined($options{options})) {
|
||||
$options{output}->add_option_msg(short_msg => "Class Custom: Need to specify 'options' argument.");
|
||||
$options{output}->option_exit();
|
||||
}
|
||||
|
||||
if (!defined($options{noptions})) {
|
||||
$options{options}->add_options(arguments => {
|
||||
'osc-secret-key:s' => { name => 'osc_secret_key' },
|
||||
'osc-access-key:s' => { name => 'osc_access_key' },
|
||||
'region:s' => { name => 'region' },
|
||||
'port:s' => { name => 'port' },
|
||||
'proto:s' => { name => 'proto' },
|
||||
'timeout:s' => { name => 'timeout' },
|
||||
'api-path:s' => { name => 'api_path' },
|
||||
'unknown-http-status:s' => { name => 'unknown_http_status' },
|
||||
'warning-http-status:s' => { name => 'warning_http_status' },
|
||||
'critical-http-status:s' => { name => 'critical_http_status' }
|
||||
});
|
||||
}
|
||||
$options{options}->add_help(package => __PACKAGE__, sections => 'REST API OPTIONS', once => 1);
|
||||
|
||||
$self->{output} = $options{output};
|
||||
$self->{http} = centreon::plugins::http->new(%options, default_backend => 'curl');
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub set_options {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{option_results} = $options{option_results};
|
||||
}
|
||||
|
||||
sub set_defaults {}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{port} = (defined($self->{option_results}->{port})) ? $self->{option_results}->{port} : 443;
|
||||
$self->{proto} = (defined($self->{option_results}->{proto})) ? $self->{option_results}->{proto} : 'https';
|
||||
$self->{timeout} = (defined($self->{option_results}->{timeout})) ? $self->{option_results}->{timeout} : 50;
|
||||
$self->{unknown_http_status} = (defined($self->{option_results}->{unknown_http_status})) ? $self->{option_results}->{unknown_http_status} : '%{http_code} < 200 or %{http_code} >= 300';
|
||||
$self->{warning_http_status} = (defined($self->{option_results}->{warning_http_status})) ? $self->{option_results}->{warning_http_status} : '';
|
||||
$self->{critical_http_status} = (defined($self->{option_results}->{critical_http_status})) ? $self->{option_results}->{critical_http_status} : '';
|
||||
$self->{api_path} = (defined($self->{option_results}->{api_path})) ? $self->{option_results}->{api_path} : '/api/v1';
|
||||
|
||||
if (!defined($self->{option_results}->{region}) || $self->{option_results}->{region} eq '') {
|
||||
$self->{output}->add_option_msg(short_msg => "Need to specify --region option.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
if (!defined($self->{option_results}->{osc_access_key}) || $self->{option_results}->{osc_access_key} eq '') {
|
||||
$self->{output}->add_option_msg(short_msg => "Need to specify --osc-access-key option.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
if (!defined($self->{option_results}->{osc_secret_key}) || $self->{option_results}->{osc_secret_key} eq '') {
|
||||
$self->{output}->add_option_msg(short_msg => "Need to specify --osc-secret-key option.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
sub build_options_for_httplib {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{option_results}->{timeout} = $self->{timeout};
|
||||
$self->{option_results}->{port} = $self->{port};
|
||||
$self->{option_results}->{proto} = $self->{proto};
|
||||
$self->{option_results}->{timeout} = $self->{timeout};
|
||||
}
|
||||
|
||||
sub settings {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return if (defined($self->{settings_done}));
|
||||
$self->build_options_for_httplib();
|
||||
$self->{http}->add_header(key => 'Accept', value => 'application/json');
|
||||
$self->{http}->set_options(%{$self->{option_results}});
|
||||
$self->{settings_done} = 1;
|
||||
}
|
||||
|
||||
sub request_api {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->settings();
|
||||
my $content = $self->{http}->request(
|
||||
hostname => 'api.' . $self->{option_results}->{region} . '.outscale.com',
|
||||
method => $options{method},
|
||||
url_path => $self->{api_path} . $options{endpoint},
|
||||
get_param => $options{get_param},
|
||||
header => $options{header},
|
||||
query_form_post => $options{query_form_post},
|
||||
credentials => 1,
|
||||
username => $self->{option_results}->{osc_access_key},
|
||||
password => $self->{option_results}->{osc_secret_key},
|
||||
curl_opt => ["CURLOPT_AWS_SIGV4 => 'osc'"],
|
||||
unknown_status => $self->{unknown_http_status},
|
||||
warning_status => $self->{warning_http_status},
|
||||
critical_status => $self->{critical_http_status}
|
||||
);
|
||||
|
||||
if (!defined($content) || $content eq '') {
|
||||
$self->{output}->add_option_msg(short_msg => "API returns empty content [code: '" . $self->{http}->get_code() . "'] [message: '" . $self->{http}->get_message() . "']");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
my $decoded;
|
||||
eval {
|
||||
$decoded = JSON::XS->new->utf8->decode($content);
|
||||
};
|
||||
if ($@) {
|
||||
$self->{output}->add_option_msg(short_msg => "Cannot decode response (add --debug option to display returned content)");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
return $decoded;
|
||||
}
|
||||
|
||||
sub load_balancer_read {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $raw_results = $self->request_api(
|
||||
method => 'POST',
|
||||
endpoint => '/ReadLoadBalancers',
|
||||
header => ['Content-Type: application/json'],
|
||||
query_form_post => ''
|
||||
);
|
||||
|
||||
return $raw_results->{LoadBalancers};
|
||||
}
|
||||
|
||||
sub read_vms_health {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $post;
|
||||
eval {
|
||||
$post = JSON::XS->new->utf8->encode({ LoadBalancerName => $options{load_balancer_name} });
|
||||
};
|
||||
if ($@) {
|
||||
$self->{output}->add_option_msg(short_msg => 'cannot encode json request');
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
my $raw_results = $self->request_api(
|
||||
method => 'POST',
|
||||
endpoint => '/ReadVmsHealth',
|
||||
header => ['Content-Type: application/json'],
|
||||
query_form_post => $post
|
||||
);
|
||||
|
||||
return $raw_results->{BackendVmHealth};
|
||||
}
|
||||
|
||||
sub read_vms {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $raw_results = $self->request_api(
|
||||
method => 'POST',
|
||||
endpoint => '/ReadVms',
|
||||
header => ['Content-Type: application/json'],
|
||||
query_form_post => ''
|
||||
);
|
||||
|
||||
return $raw_results->{Vms};
|
||||
}
|
||||
|
||||
sub read_client_gateways {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $raw_results = $self->request_api(
|
||||
method => 'POST',
|
||||
endpoint => '/ReadClientGateways',
|
||||
header => ['Content-Type: application/json'],
|
||||
query_form_post => ''
|
||||
);
|
||||
|
||||
return $raw_results->{ClientGateways};
|
||||
}
|
||||
|
||||
sub read_consumption_account {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $post;
|
||||
eval {
|
||||
$post = JSON::XS->new->utf8->encode({ FromDate => $options{from_date}, ToDate => $options{to_date} });
|
||||
};
|
||||
if ($@) {
|
||||
$self->{output}->add_option_msg(short_msg => 'cannot encode json request');
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
my $raw_results = $self->request_api(
|
||||
method => 'POST',
|
||||
endpoint => '/ReadConsumptionAccount',
|
||||
header => ['Content-Type: application/json'],
|
||||
query_form_post => $post
|
||||
);
|
||||
|
||||
return $raw_results->{ConsumptionEntries};
|
||||
}
|
||||
|
||||
sub read_virtual_gateways {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $raw_results = $self->request_api(
|
||||
method => 'POST',
|
||||
endpoint => '/ReadVirtualGateways',
|
||||
header => ['Content-Type: application/json'],
|
||||
query_form_post => ''
|
||||
);
|
||||
|
||||
return $raw_results->{VirtualGateways};
|
||||
}
|
||||
|
||||
sub read_vpn_connections {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $raw_results = $self->request_api(
|
||||
method => 'POST',
|
||||
endpoint => '/ReadVpnConnections',
|
||||
header => ['Content-Type: application/json'],
|
||||
query_form_post => ''
|
||||
);
|
||||
|
||||
return $raw_results->{VpnConnections};
|
||||
}
|
||||
|
||||
sub read_volumes {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $raw_results = $self->request_api(
|
||||
method => 'POST',
|
||||
endpoint => '/ReadVolumes',
|
||||
header => ['Content-Type: application/json'],
|
||||
query_form_post => ''
|
||||
);
|
||||
|
||||
return $raw_results->{Volumes};
|
||||
}
|
||||
|
||||
sub read_nets {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $raw_results = $self->request_api(
|
||||
method => 'POST',
|
||||
endpoint => '/ReadNets',
|
||||
header => ['Content-Type: application/json'],
|
||||
query_form_post => ''
|
||||
);
|
||||
|
||||
return $raw_results->{Nets};
|
||||
}
|
||||
|
||||
sub read_quotas {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $raw_results = $self->request_api(
|
||||
method => 'POST',
|
||||
endpoint => '/ReadQuotas',
|
||||
header => ['Content-Type: application/json'],
|
||||
query_form_post => ''
|
||||
);
|
||||
|
||||
return $raw_results->{QuotaTypes};
|
||||
}
|
||||
|
||||
sub read_subnets {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $raw_results = $self->request_api(
|
||||
method => 'POST',
|
||||
endpoint => '/ReadSubnets',
|
||||
header => ['Content-Type: application/json'],
|
||||
query_form_post => ''
|
||||
);
|
||||
|
||||
return $raw_results->{Subnets};
|
||||
}
|
||||
|
||||
sub read_route_tables {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $raw_results = $self->request_api(
|
||||
method => 'POST',
|
||||
endpoint => '/ReadRouteTables',
|
||||
header => ['Content-Type: application/json'],
|
||||
query_form_post => ''
|
||||
);
|
||||
|
||||
return $raw_results->{RouteTables};
|
||||
}
|
||||
|
||||
sub read_internet_services {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $raw_results = $self->request_api(
|
||||
method => 'POST',
|
||||
endpoint => '/ReadInternetServices',
|
||||
header => ['Content-Type: application/json'],
|
||||
query_form_post => ''
|
||||
);
|
||||
|
||||
return $raw_results->{InternetServices};
|
||||
}
|
||||
|
||||
sub read_nat_services {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $raw_results = $self->request_api(
|
||||
method => 'POST',
|
||||
endpoint => '/ReadNatServices',
|
||||
header => ['Content-Type: application/json'],
|
||||
query_form_post => ''
|
||||
);
|
||||
|
||||
return $raw_results->{NatServices};
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Outscale Rest API
|
||||
|
||||
=head1 REST API OPTIONS
|
||||
|
||||
Outscale Rest API
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--osc-secret-key>
|
||||
|
||||
Set Outscale secret key.
|
||||
|
||||
=item B<--osc-access-key>
|
||||
|
||||
Set Outscale access key.
|
||||
|
||||
=item B<--region>
|
||||
|
||||
Set the region name (Required).
|
||||
|
||||
=item B<--port>
|
||||
|
||||
Port used (Default: 443)
|
||||
|
||||
=item B<--proto>
|
||||
|
||||
Specify https if needed (Default: 'https')
|
||||
|
||||
=item B<--token>
|
||||
|
||||
API token.
|
||||
|
||||
=item B<--timeout>
|
||||
|
||||
Set timeout in seconds (Default: 50).
|
||||
|
||||
=back
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
B<custom>.
|
||||
|
||||
=cut
|
|
@ -0,0 +1,468 @@
|
|||
#
|
||||
# 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::outscale::custom::osccli;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use centreon::plugins::misc;
|
||||
use JSON::XS;
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = {};
|
||||
bless $self, $class;
|
||||
|
||||
if (!defined($options{output})) {
|
||||
print "Class Custom: Need to specify 'output' argument.\n";
|
||||
exit 3;
|
||||
}
|
||||
if (!defined($options{options})) {
|
||||
$options{output}->add_option_msg(short_msg => "Class Custom: Need to specify 'options' argument.");
|
||||
$options{output}->option_exit();
|
||||
}
|
||||
|
||||
if (!defined($options{noptions})) {
|
||||
$options{options}->add_options(arguments => {
|
||||
'profile:s' => { name => 'profile' },
|
||||
'virtual-env:s' => { name => 'virtual_env' },
|
||||
'timeout:s' => { name => 'timeout', default => 50 },
|
||||
'sudo' => { name => 'sudo' },
|
||||
'command:s' => { name => 'command' },
|
||||
'command-path:s' => { name => 'command_path' },
|
||||
'command-options:s' => { name => 'command_options' },
|
||||
'proxyurl:s' => { name => 'proxyurl' }
|
||||
});
|
||||
}
|
||||
$options{options}->add_help(package => __PACKAGE__, sections => 'OSCCLI OPTIONS', once => 1);
|
||||
|
||||
$self->{output} = $options{output};
|
||||
$self->{custommode_name} = $options{custommode_name};
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub get_region {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return $self->{option_results}->{region};
|
||||
}
|
||||
|
||||
sub set_options {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{option_results} = $options{option_results};
|
||||
}
|
||||
|
||||
sub set_defaults {}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
if (defined($self->{option_results}->{proxyurl}) && $self->{option_results}->{proxyurl} ne '') {
|
||||
$ENV{HTTP_PROXY} = $self->{option_results}->{proxyurl};
|
||||
$ENV{HTTPS_PROXY} = $self->{option_results}->{proxyurl};
|
||||
}
|
||||
|
||||
if (defined($self->{option_results}->{virtual_env}) && $self->{option_results}->{virtual_env} ne '') {
|
||||
$ENV{VIRTUAL_ENV} = $self->{option_results}->{virtual_env};
|
||||
$ENV{PATH} = "$ENV{VIRTUAL_ENV}/bin:$ENV{PATH}";
|
||||
}
|
||||
|
||||
centreon::plugins::misc::check_security_command(
|
||||
output => $self->{output},
|
||||
command => $self->{option_results}->{command},
|
||||
command_options => $self->{option_results}->{command_options},
|
||||
command_path => $self->{option_results}->{command_path}
|
||||
);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
sub execute {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $command = defined($self->{option_results}->{command}) && $self->{option_results}->{command} ne '' ? $self->{option_results}->{command} : 'osc-cli';
|
||||
|
||||
my $cmd_options = $options{cmd_options};
|
||||
|
||||
$self->{output}->output_add(long_msg => "Command line: '" . $command . " " . $cmd_options . "'", debug => 1);
|
||||
|
||||
my ($response) = centreon::plugins::misc::execute(
|
||||
output => $self->{output},
|
||||
options => $self->{option_results},
|
||||
sudo => $self->{option_results}->{sudo},
|
||||
command => $command,
|
||||
command_path => $self->{option_results}->{command_path},
|
||||
command_options => $cmd_options,
|
||||
redirect_stderr => ($self->{output}->is_debug()) ? 0 : 1
|
||||
);
|
||||
|
||||
my $raw_results = {};
|
||||
|
||||
eval {
|
||||
$raw_results = JSON::XS->new->utf8->decode($response);
|
||||
};
|
||||
if ($@) {
|
||||
$self->{output}->output_add(long_msg => $response, debug => 1);
|
||||
$self->{output}->add_option_msg(short_msg => "Cannot decode response (add --debug option to display returned content)");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
return $raw_results;
|
||||
}
|
||||
|
||||
sub load_balancer_read_set_cmd {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return $self->{option_results}->{command_options} if (defined($self->{option_results}->{command_options}) && $self->{option_results}->{command_options} ne '');
|
||||
|
||||
my $cmd_options = 'api ReadLoadBalancers';
|
||||
$cmd_options .= " --profile '$self->{option_results}->{profile}'" if (defined($self->{option_results}->{profile}) && $self->{option_results}->{profile} ne '');
|
||||
|
||||
return $cmd_options;
|
||||
}
|
||||
|
||||
sub load_balancer_read {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $cmd_options = $self->load_balancer_read_set_cmd(%options);
|
||||
my $raw_results = $self->execute(cmd_options => $cmd_options);
|
||||
|
||||
return $raw_results->{LoadBalancers};
|
||||
}
|
||||
|
||||
sub read_vms_health_set_cmd {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return $self->{option_results}->{command_options} if (defined($self->{option_results}->{command_options}) && $self->{option_results}->{command_options} ne '');
|
||||
|
||||
my $cmd_options = 'api ReadVmsHealth';
|
||||
$cmd_options .= " --profile '$self->{option_results}->{profile}'" if (defined($self->{option_results}->{profile}) && $self->{option_results}->{profile} ne '');
|
||||
$cmd_options .= " --LoadBalancerName '$options{load_balancer_name}'";
|
||||
|
||||
return $cmd_options;
|
||||
}
|
||||
|
||||
sub read_vms_health {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $cmd_options = $self->read_vms_health_set_cmd(%options);
|
||||
my $raw_results = $self->execute(cmd_options => $cmd_options);
|
||||
|
||||
return $raw_results->{BackendVmHealth};
|
||||
}
|
||||
|
||||
sub read_vms_set_cmd {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return $self->{option_results}->{command_options} if (defined($self->{option_results}->{command_options}) && $self->{option_results}->{command_options} ne '');
|
||||
|
||||
my $cmd_options = 'api ReadVms';
|
||||
$cmd_options .= " --profile '$self->{option_results}->{profile}'" if (defined($self->{option_results}->{profile}) && $self->{option_results}->{profile} ne '');
|
||||
|
||||
return $cmd_options;
|
||||
}
|
||||
|
||||
sub read_vms {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $cmd_options = $self->read_vms_set_cmd(%options);
|
||||
my $raw_results = $self->execute(cmd_options => $cmd_options);
|
||||
|
||||
return $raw_results->{Vms};
|
||||
}
|
||||
|
||||
sub read_client_gateways_set_cmd {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return $self->{option_results}->{command_options} if (defined($self->{option_results}->{command_options}) && $self->{option_results}->{command_options} ne '');
|
||||
|
||||
my $cmd_options = 'api ReadClientGateways';
|
||||
$cmd_options .= " --profile '$self->{option_results}->{profile}'" if (defined($self->{option_results}->{profile}) && $self->{option_results}->{profile} ne '');
|
||||
|
||||
return $cmd_options;
|
||||
}
|
||||
|
||||
sub read_client_gateways {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $cmd_options = $self->read_client_gateways_set_cmd(%options);
|
||||
my $raw_results = $self->execute(cmd_options => $cmd_options);
|
||||
|
||||
return $raw_results->{ClientGateways};
|
||||
}
|
||||
|
||||
sub read_consumption_account_set_cmd {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return $self->{option_results}->{command_options} if (defined($self->{option_results}->{command_options}) && $self->{option_results}->{command_options} ne '');
|
||||
|
||||
my $cmd_options = 'api ReadConsumptionAccount';
|
||||
$cmd_options .= " --profile '$self->{option_results}->{profile}'" if (defined($self->{option_results}->{profile}) && $self->{option_results}->{profile} ne '');
|
||||
$cmd_options .= " --FromDate '$options{from_date}' --ToDate '$options{to_date}'";
|
||||
|
||||
return $cmd_options;
|
||||
}
|
||||
|
||||
sub read_consumption_account {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $cmd_options = $self->read_consumption_account_set_cmd(%options);
|
||||
my $raw_results = $self->execute(cmd_options => $cmd_options);
|
||||
|
||||
return $raw_results->{ConsumptionEntries};
|
||||
}
|
||||
|
||||
sub read_virtual_gateways_set_cmd {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return $self->{option_results}->{command_options} if (defined($self->{option_results}->{command_options}) && $self->{option_results}->{command_options} ne '');
|
||||
|
||||
my $cmd_options = 'api ReadVirtualGateways';
|
||||
$cmd_options .= " --profile '$self->{option_results}->{profile}'" if (defined($self->{option_results}->{profile}) && $self->{option_results}->{profile} ne '');
|
||||
|
||||
return $cmd_options;
|
||||
}
|
||||
|
||||
sub read_virtual_gateways {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $cmd_options = $self->read_virtual_gateways_set_cmd(%options);
|
||||
my $raw_results = $self->execute(cmd_options => $cmd_options);
|
||||
|
||||
return $raw_results->{VirtualGateways};
|
||||
}
|
||||
|
||||
sub read_vpn_connections_set_cmd {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return $self->{option_results}->{command_options} if (defined($self->{option_results}->{command_options}) && $self->{option_results}->{command_options} ne '');
|
||||
|
||||
my $cmd_options = 'api ReadVpnConnections';
|
||||
$cmd_options .= " --profile '$self->{option_results}->{profile}'" if (defined($self->{option_results}->{profile}) && $self->{option_results}->{profile} ne '');
|
||||
|
||||
return $cmd_options;
|
||||
}
|
||||
|
||||
sub read_vpn_connections {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $cmd_options = $self->read_vpn_connections_set_cmd(%options);
|
||||
my $raw_results = $self->execute(cmd_options => $cmd_options);
|
||||
|
||||
return $raw_results->{VpnConnections};
|
||||
}
|
||||
|
||||
sub read_volumes_set_cmd {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return $self->{option_results}->{command_options} if (defined($self->{option_results}->{command_options}) && $self->{option_results}->{command_options} ne '');
|
||||
|
||||
my $cmd_options = 'api ReadVolumes';
|
||||
$cmd_options .= " --profile '$self->{option_results}->{profile}'" if (defined($self->{option_results}->{profile}) && $self->{option_results}->{profile} ne '');
|
||||
|
||||
return $cmd_options;
|
||||
}
|
||||
|
||||
sub read_volumes {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $cmd_options = $self->read_volumes_set_cmd(%options);
|
||||
my $raw_results = $self->execute(cmd_options => $cmd_options);
|
||||
|
||||
return $raw_results->{Volumes};
|
||||
}
|
||||
|
||||
sub read_nets_set_cmd {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return $self->{option_results}->{command_options} if (defined($self->{option_results}->{command_options}) && $self->{option_results}->{command_options} ne '');
|
||||
|
||||
my $cmd_options = 'api ReadNets';
|
||||
$cmd_options .= " --profile '$self->{option_results}->{profile}'" if (defined($self->{option_results}->{profile}) && $self->{option_results}->{profile} ne '');
|
||||
|
||||
return $cmd_options;
|
||||
}
|
||||
|
||||
sub read_nets {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $cmd_options = $self->read_nets_set_cmd(%options);
|
||||
my $raw_results = $self->execute(cmd_options => $cmd_options);
|
||||
|
||||
return $raw_results->{Nets};
|
||||
}
|
||||
|
||||
sub read_quotas_set_cmd {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return $self->{option_results}->{command_options} if (defined($self->{option_results}->{command_options}) && $self->{option_results}->{command_options} ne '');
|
||||
|
||||
my $cmd_options = 'api ReadQuotas';
|
||||
$cmd_options .= " --profile '$self->{option_results}->{profile}'" if (defined($self->{option_results}->{profile}) && $self->{option_results}->{profile} ne '');
|
||||
|
||||
return $cmd_options;
|
||||
}
|
||||
|
||||
sub read_quotas {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $cmd_options = $self->read_quotas_set_cmd(%options);
|
||||
my $raw_results = $self->execute(cmd_options => $cmd_options);
|
||||
|
||||
return $raw_results->{QuotaTypes};
|
||||
}
|
||||
|
||||
sub read_subnets_set_cmd {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return $self->{option_results}->{command_options} if (defined($self->{option_results}->{command_options}) && $self->{option_results}->{command_options} ne '');
|
||||
|
||||
my $cmd_options = 'api ReadSubnets';
|
||||
$cmd_options .= " --profile '$self->{option_results}->{profile}'" if (defined($self->{option_results}->{profile}) && $self->{option_results}->{profile} ne '');
|
||||
|
||||
return $cmd_options;
|
||||
}
|
||||
|
||||
sub read_subnets {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $cmd_options = $self->read_subnets_set_cmd(%options);
|
||||
my $raw_results = $self->execute(cmd_options => $cmd_options);
|
||||
|
||||
return $raw_results->{Subnets};
|
||||
}
|
||||
|
||||
sub read_route_tables_set_cmd {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return $self->{option_results}->{command_options} if (defined($self->{option_results}->{command_options}) && $self->{option_results}->{command_options} ne '');
|
||||
|
||||
my $cmd_options = 'api ReadRouteTables';
|
||||
$cmd_options .= " --profile '$self->{option_results}->{profile}'" if (defined($self->{option_results}->{profile}) && $self->{option_results}->{profile} ne '');
|
||||
|
||||
return $cmd_options;
|
||||
}
|
||||
|
||||
sub read_route_tables {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $cmd_options = $self->read_route_tables_set_cmd(%options);
|
||||
my $raw_results = $self->execute(cmd_options => $cmd_options);
|
||||
|
||||
return $raw_results->{RouteTables};
|
||||
}
|
||||
|
||||
sub read_internet_services_set_cmd {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return $self->{option_results}->{command_options} if (defined($self->{option_results}->{command_options}) && $self->{option_results}->{command_options} ne '');
|
||||
|
||||
my $cmd_options = 'api ReadInternetServices';
|
||||
$cmd_options .= " --profile '$self->{option_results}->{profile}'" if (defined($self->{option_results}->{profile}) && $self->{option_results}->{profile} ne '');
|
||||
|
||||
return $cmd_options;
|
||||
}
|
||||
|
||||
sub read_internet_services {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $cmd_options = $self->read_internet_services_set_cmd(%options);
|
||||
my $raw_results = $self->execute(cmd_options => $cmd_options);
|
||||
|
||||
return $raw_results->{InternetServices};
|
||||
}
|
||||
|
||||
sub read_nat_services_set_cmd {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return $self->{option_results}->{command_options} if (defined($self->{option_results}->{command_options}) && $self->{option_results}->{command_options} ne '');
|
||||
|
||||
my $cmd_options = 'api ReadNatServices';
|
||||
$cmd_options .= " --profile '$self->{option_results}->{profile}'" if (defined($self->{option_results}->{profile}) && $self->{option_results}->{profile} ne '');
|
||||
|
||||
return $cmd_options;
|
||||
}
|
||||
|
||||
sub read_nat_services {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $cmd_options = $self->read_nat_services_set_cmd(%options);
|
||||
my $raw_results = $self->execute(cmd_options => $cmd_options);
|
||||
|
||||
return $raw_results->{NatServices};
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Outscale
|
||||
|
||||
=head1 OSCCLI OPTIONS
|
||||
|
||||
Outscale CLI
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--profile>
|
||||
|
||||
Set profile option.
|
||||
|
||||
=item B<--virtual-env>
|
||||
|
||||
Set python virtual environment (to be used if osc-cli is installed in python venv).
|
||||
|
||||
=item B<--timeout>
|
||||
|
||||
Set timeout in seconds (Default: 50).
|
||||
|
||||
=item B<--sudo>
|
||||
|
||||
Use 'sudo' to execute the command.
|
||||
|
||||
=item B<--command>
|
||||
|
||||
Command to get information (Default: 'osc-cli').
|
||||
Can be changed if you have output in a file.
|
||||
|
||||
=item B<--command-path>
|
||||
|
||||
Command path (Default: none).
|
||||
|
||||
=item B<--command-options>
|
||||
|
||||
Command options (Default: none).
|
||||
Only use for testing purpose, when you want to set ALL parameters of a command by yourself.
|
||||
|
||||
=item B<--proxyurl>
|
||||
|
||||
Proxy URL if any
|
||||
|
||||
=back
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
B<custom>.
|
||||
|
||||
=cut
|
|
@ -0,0 +1,204 @@
|
|||
#
|
||||
# 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::outscale::mode::accountconsumptions;
|
||||
|
||||
use base qw(centreon::plugins::templates::counter);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use DateTime;
|
||||
|
||||
sub consumption_long_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return sprintf(
|
||||
"checking account consumption '%s' [service: %s] [region: %s]",
|
||||
$options{instance_value}->{title},
|
||||
$options{instance_value}->{service},
|
||||
$options{instance_value}->{region}
|
||||
);
|
||||
}
|
||||
|
||||
sub prefix_consumption_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return sprintf(
|
||||
"account consumption '%s' [service: %s] [region: %s] ",
|
||||
$options{instance_value}->{title},
|
||||
$options{instance_value}->{service},
|
||||
$options{instance_value}->{region}
|
||||
);
|
||||
}
|
||||
|
||||
sub prefix_global_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return 'number of account consumptions ';
|
||||
}
|
||||
|
||||
sub set_counters {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{maps_counters_type} = [
|
||||
{ name => 'global', type => 0, cb_prefix_output => 'prefix_global_output' },
|
||||
{
|
||||
name => 'consumptions', type => 3, cb_prefix_output => 'prefix_consumption_output', cb_long_output => 'consumption_long_output', indent_long_output => ' ', message_multiple => 'All account consumptions are ok',
|
||||
group => [
|
||||
{ name => 'metrics', type => 0 }
|
||||
]
|
||||
}
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{global} = [
|
||||
{ label => 'account-consumptions-detected', display_ok => 0, nlabel => 'account.consumptions.detected.count', set => {
|
||||
key_values => [ { name => 'detected' } ],
|
||||
output_template => 'detected: %s',
|
||||
perfdatas => [
|
||||
{ template => '%s', min => 0 }
|
||||
]
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{metrics} = [
|
||||
{ label => 'account-consumption', nlabel => 'accounts.consumption.count', set => {
|
||||
key_values => [ { name => 'value' }, { name => 'title' }, { name => 'service' }, { name => 'region' } ],
|
||||
output_template => 'value: %.3f',
|
||||
closure_custom_perfdata => sub {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{output}->perfdata_add(
|
||||
nlabel => $self->{nlabel},
|
||||
instances => [$self->{result_values}->{title}, $self->{result_values}->{service}, $self->{result_values}->{region}],
|
||||
value => sprintf('%.3f', $self->{result_values}->{value}),
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel})
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
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-region:s' => { name => 'filter_region' },
|
||||
'filter-service:s' => { name => 'filter_service' },
|
||||
'filter-category:s' => { name => 'filter_category' },
|
||||
'filter-title:s' => { name => 'filter_title' },
|
||||
'timeframe:s' => { name => 'timeframe' }
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::check_options(%options);
|
||||
|
||||
if (!defined($self->{option_results}->{timeframe}) || $self->{option_results}->{timeframe} !~ /\d/) {
|
||||
$self->{option_results}->{timeframe} = 1;
|
||||
}
|
||||
}
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $dt = DateTime->now(time_zone => 'UTC');
|
||||
my $to_date = sprintf('%02d-%02d-%02d', $dt->year(), $dt->month(), $dt->day());
|
||||
$dt->subtract(days => $self->{option_results}->{timeframe});
|
||||
my $from_date = sprintf('%02d-%02d-%02d', $dt->year(), $dt->month(), $dt->day());
|
||||
|
||||
my $consumptions = $options{custom}->read_consumption_account(from_date => $from_date, to_date => $to_date);
|
||||
|
||||
$self->{global} = { detected => 0 };
|
||||
$self->{consumptions} = {};
|
||||
|
||||
my $i = 0;
|
||||
foreach (@$consumptions) {
|
||||
next if (defined($self->{option_results}->{filter_region}) && $self->{option_results}->{filter_region} ne '' &&
|
||||
$_->{SubregionName} !~ /$self->{option_results}->{filter_region}/);
|
||||
next if (defined($self->{option_results}->{filter_service}) && $self->{option_results}->{filter_service} ne '' &&
|
||||
$_->{Service} !~ /$self->{option_results}->{filter_service}/);
|
||||
next if (defined($self->{option_results}->{filter_category}) && $self->{option_results}->{filter_category} ne '' &&
|
||||
$_->{Category} !~ /$self->{option_results}->{filter_category}/);
|
||||
next if (defined($self->{option_results}->{filter_title}) && $self->{option_results}->{filter_title} ne '' &&
|
||||
$_->{Title} !~ /$self->{option_results}->{filter_title}/);
|
||||
|
||||
$self->{consumptions}->{$i} = {
|
||||
title => $_->{Title},
|
||||
service => $_->{Service},
|
||||
region => $_->{SubregionName},
|
||||
metrics => {
|
||||
title => $_->{Title},
|
||||
service => $_->{Service},
|
||||
region => $_->{SubregionName},
|
||||
value => $_->{Value}
|
||||
}
|
||||
};
|
||||
$i++;
|
||||
|
||||
$self->{global}->{detected}++;
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check account consumptions.
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--filter-title>
|
||||
|
||||
Filter account consumptions by title.
|
||||
|
||||
=item B<--filter-service>
|
||||
|
||||
Filter account consumptions by service.
|
||||
|
||||
=item B<--filter-category>
|
||||
|
||||
Filter account consumptions by category.
|
||||
|
||||
=item B<--filter-region>
|
||||
|
||||
Filter account consumptions by region.
|
||||
|
||||
=item B<--timeframe>
|
||||
|
||||
Set timeframe in days (Default: 1).
|
||||
|
||||
=item B<--warning-*> B<--critical-*>
|
||||
|
||||
Thresholds.
|
||||
Can be: 'account-consumptions-detected', 'account-consumption'.
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
|
@ -0,0 +1,198 @@
|
|||
#
|
||||
# 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::outscale::mode::clientgateways;
|
||||
|
||||
use base qw(centreon::plugins::templates::counter);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng);
|
||||
|
||||
sub prefix_cg_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return sprintf(
|
||||
"client gateway '%s' ",
|
||||
$options{instance_value}->{cgName}
|
||||
);
|
||||
}
|
||||
|
||||
sub prefix_global_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return 'number of client gateways ';
|
||||
}
|
||||
|
||||
sub set_counters {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{maps_counters_type} = [
|
||||
{ name => 'global', type => 0, cb_prefix_output => 'prefix_global_output' },
|
||||
{ name => 'cgs', type => 1, cb_prefix_output => 'prefix_cg_output', message_multiple => 'All client gateways are ok' }
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{global} = [
|
||||
{ label => 'cgs-detected', display_ok => 0, nlabel => 'client_gateways.detected.count', set => {
|
||||
key_values => [ { name => 'detected' } ],
|
||||
output_template => 'detected: %s',
|
||||
perfdatas => [
|
||||
{ template => '%s', min => 0 }
|
||||
]
|
||||
}
|
||||
},
|
||||
{ label => 'cgs-available', display_ok => 0, nlabel => 'client_gateways.available.count', set => {
|
||||
key_values => [ { name => 'available' } ],
|
||||
output_template => 'available: %s',
|
||||
perfdatas => [
|
||||
{ template => '%s', min => 0 }
|
||||
]
|
||||
}
|
||||
},
|
||||
{ label => 'cgs-pending', display_ok => 0, nlabel => 'client_gateways.pending.count', set => {
|
||||
key_values => [ { name => 'pending' } ],
|
||||
output_template => 'pending: %s',
|
||||
perfdatas => [
|
||||
{ template => '%s', min => 0 }
|
||||
]
|
||||
}
|
||||
},
|
||||
{ label => 'cgs-deleting', display_ok => 0, nlabel => 'client_gateways.deleting.count', set => {
|
||||
key_values => [ { name => 'deleting' } ],
|
||||
output_template => 'deleting: %s',
|
||||
perfdatas => [
|
||||
{ template => '%s', min => 0 }
|
||||
]
|
||||
}
|
||||
},
|
||||
{ label => 'cgs-deleted', display_ok => 0, nlabel => 'client_gateways.deleted.count', set => {
|
||||
key_values => [ { name => 'deleted' } ],
|
||||
output_template => 'deleted: %s',
|
||||
perfdatas => [
|
||||
{ template => '%s', min => 0 }
|
||||
]
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{cgs} = [
|
||||
{
|
||||
label => 'cg-status',
|
||||
type => 2,
|
||||
set => {
|
||||
key_values => [ { name => 'state' }, { name => 'cgName' } ],
|
||||
output_template => 'state: %s',
|
||||
closure_custom_perfdata => sub { return 0; },
|
||||
closure_custom_threshold_check => \&catalog_status_threshold_ng
|
||||
}
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
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-name:s' => { name => 'filter_name' },
|
||||
'cg-tag-name:s' => { name => 'cg_tag_name', default => 'name' }
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub get_cg_name {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
foreach my $tag (@{$options{tags}}) {
|
||||
return $tag->{Value} if ($tag->{Key} =~ /^$self->{option_results}->{cg_tag_name}$/i);
|
||||
}
|
||||
|
||||
return $options{id};
|
||||
}
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $cgs = $options{custom}->read_client_gateways();
|
||||
|
||||
$self->{global} = { detected => 0, available => 0, pending => 0, deleting => 0, deleted => 0 };
|
||||
$self->{cgs} = {};
|
||||
|
||||
foreach my $cg (@$cgs) {
|
||||
my $name = $self->get_cg_name(tags => $cg->{Tags}, id => $cg->{ClientGatewayId});
|
||||
|
||||
next if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' &&
|
||||
$name !~ /$self->{option_results}->{filter_name}/);
|
||||
|
||||
$self->{cgs}->{$name} = {
|
||||
cgName => $name,
|
||||
state => lc($cg->{State})
|
||||
};
|
||||
|
||||
$self->{global}->{ lc($cg->{State}) }++
|
||||
if (defined($self->{global}->{ lc($cg->{State}) }));
|
||||
$self->{global}->{detected}++;
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check client gateways.
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--filter-name>
|
||||
|
||||
Filter client gateways by name.
|
||||
|
||||
=item B<--cg-tag-name>
|
||||
|
||||
Client gateway tags to be used for the name (Default: 'name').
|
||||
|
||||
=item B<--unknown-cg-status>
|
||||
|
||||
Set unknown threshold for status.
|
||||
Can used special variables like: %{state}, %{cgName}
|
||||
|
||||
=item B<--warning-cg-status>
|
||||
|
||||
Set warning threshold for status.
|
||||
Can used special variables like: %{state}, %{cgName}
|
||||
|
||||
=item B<--critical-cg-status>
|
||||
|
||||
Set critical threshold for status.
|
||||
Can used special variables like: %{state}, %{cgName}
|
||||
|
||||
=item B<--warning-*> B<--critical-*>
|
||||
|
||||
Thresholds.
|
||||
Can be: 'cgs-detected', 'cgs-available', 'cgs-pending',
|
||||
'cgs-deleting', 'cgs-deleted'.
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
|
@ -0,0 +1,174 @@
|
|||
#
|
||||
# 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::outscale::mode::internetservices;
|
||||
|
||||
use base qw(centreon::plugins::templates::counter);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng);
|
||||
|
||||
sub prefix_service_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return sprintf(
|
||||
"internet service '%s' ",
|
||||
$options{instance_value}->{internetServiceName}
|
||||
);
|
||||
}
|
||||
|
||||
sub prefix_global_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return 'number of internet services ';
|
||||
}
|
||||
|
||||
sub set_counters {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{maps_counters_type} = [
|
||||
{ name => 'global', type => 0, cb_prefix_output => 'prefix_global_output' },
|
||||
{ name => 'services', type => 1, cb_prefix_output => 'prefix_service_output', message_multiple => 'All internet services are ok' }
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{global} = [];
|
||||
foreach ('detected', 'available') {
|
||||
push @{$self->{maps_counters}->{global}}, {
|
||||
label => 'internet-services-' . $_, display_ok => 0, nlabel => 'internet_services.' . $_ . '.count', set => {
|
||||
key_values => [ { name => $_ } ],
|
||||
output_template => $_ . ': %s',
|
||||
perfdatas => [
|
||||
{ template => '%s', min => 0 }
|
||||
]
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
$self->{maps_counters}->{services} = [
|
||||
{
|
||||
label => 'internet-service-status',
|
||||
type => 2,
|
||||
set => {
|
||||
key_values => [ { name => 'state' }, { name => 'internetServiceName' } ],
|
||||
output_template => 'state: %s',
|
||||
closure_custom_perfdata => sub { return 0; },
|
||||
closure_custom_threshold_check => \&catalog_status_threshold_ng
|
||||
}
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
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-id:s' => { name => 'filter_id' },
|
||||
'filter-name:s' => { name => 'filter_name' },
|
||||
'internet-service-tag-name:s' => { name => 'internet_service_tag_name', default => 'name' }
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub get_internet_service_name {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
foreach my $tag (@{$options{tags}}) {
|
||||
return $tag->{Value} if ($tag->{Key} =~ /^$self->{option_results}->{internet_service_tag_name}$/i);
|
||||
}
|
||||
|
||||
return $options{id};
|
||||
}
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $services = $options{custom}->read_internet_services();
|
||||
|
||||
$self->{global} = { detected => 0, available => 0 };
|
||||
$self->{services} = {};
|
||||
|
||||
foreach (@$services) {
|
||||
my $name = $self->get_internet_service_name(tags => $_->{Tags}, id => $_->{InternetServiceId});
|
||||
|
||||
next if (defined($self->{option_results}->{filter_id}) && $self->{option_results}->{filter_id} ne '' &&
|
||||
$_->{InternetServiceId} !~ /$self->{option_results}->{filter_id}/);
|
||||
next if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' &&
|
||||
$name !~ /$self->{option_results}->{filter_name}/);
|
||||
|
||||
$self->{services}->{ $_->{InternetServiceId} } = {
|
||||
internetServiceName => $name,
|
||||
state => lc($_->{State})
|
||||
};
|
||||
|
||||
$self->{global}->{ lc($_->{State}) }++
|
||||
if (defined($self->{global}->{ lc($_->{State}) }));
|
||||
$self->{global}->{detected}++;
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check internet services.
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--filter-id>
|
||||
|
||||
Filter internet services by id.
|
||||
|
||||
=item B<--filter-name>
|
||||
|
||||
Filter internet services by name.
|
||||
|
||||
=item B<--internet-service-tag-name>
|
||||
|
||||
Internet service tag to be used for the name (Default: 'name').
|
||||
|
||||
=item B<--unknown-internet-service-status>
|
||||
|
||||
Set unknown threshold for status.
|
||||
Can used special variables like: %{state}, %{internetServiceName}
|
||||
|
||||
=item B<--warning-internet-service-status>
|
||||
|
||||
Set warning threshold for status.
|
||||
Can used special variables like: %{state}, %{internetServiceName}
|
||||
|
||||
=item B<--critical-internet-service-status>
|
||||
|
||||
Set critical threshold for status.
|
||||
Can used special variables like: %{state}, %{internetServiceName}
|
||||
|
||||
=item B<--warning-*> B<--critical-*>
|
||||
|
||||
Thresholds.
|
||||
Can be: 'internet-services-detected', 'internet-services-available'.
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
|
@ -0,0 +1,122 @@
|
|||
#
|
||||
# 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::outscale::mode::listclientgateways;
|
||||
|
||||
use base qw(centreon::plugins::mode);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments => {
|
||||
'cg-tag-name:s' => { name => 'cg_tag_name', default => 'name' }
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::init(%options);
|
||||
}
|
||||
|
||||
my @labels = ('id', 'name', 'state');
|
||||
|
||||
sub get_cg_name {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
foreach my $tag (@{$options{tags}}) {
|
||||
return $tag->{Value} if ($tag->{Key} =~ /^$self->{option_results}->{cg_tag_name}$/i);
|
||||
}
|
||||
|
||||
return $options{id};
|
||||
}
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $cgs = $options{custom}->read_client_gateways();
|
||||
|
||||
my $results = {};
|
||||
foreach (@$cgs) {
|
||||
my $name = $self->get_cg_name(tags => $_->{Tags}, id => $_->{ClientGatewayId});
|
||||
|
||||
$results->{$name} = {
|
||||
id => $_->{ClientGatewayId},
|
||||
name => $name,
|
||||
state => lc($_->{State})
|
||||
};
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $results = $self->manage_selection(custom => $options{custom});
|
||||
foreach my $instance (sort keys %$results) {
|
||||
$self->{output}->output_add(long_msg =>
|
||||
join('', map("[$_: " . $results->{$instance}->{$_} . ']', @labels))
|
||||
);
|
||||
}
|
||||
|
||||
$self->{output}->output_add(
|
||||
severity => 'OK',
|
||||
short_msg => 'List client gateways:'
|
||||
);
|
||||
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
|
||||
$self->{output}->exit();
|
||||
}
|
||||
|
||||
sub disco_format {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{output}->add_disco_format(elements => [@labels]);
|
||||
}
|
||||
|
||||
sub disco_show {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $results = $self->manage_selection(custom => $options{custom});
|
||||
foreach (sort keys %$results) {
|
||||
$self->{output}->add_disco_entry(
|
||||
%{$results->{$_}}
|
||||
);
|
||||
}
|
||||
}
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
List client gateways.
|
||||
|
||||
=over 8
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
|
@ -0,0 +1,122 @@
|
|||
#
|
||||
# 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::outscale::mode::listinternetservices;
|
||||
|
||||
use base qw(centreon::plugins::mode);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments => {
|
||||
'internet-service-tag-name:s' => { name => 'internet_service_tag_name', default => 'name' }
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::init(%options);
|
||||
}
|
||||
|
||||
my @labels = ('id', 'name', 'state');
|
||||
|
||||
sub get_internet_service_name {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
foreach my $tag (@{$options{tags}}) {
|
||||
return $tag->{Value} if ($tag->{Key} =~ /^$self->{option_results}->{internet_service_tag_name}$/i);
|
||||
}
|
||||
|
||||
return $options{id};
|
||||
}
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $services = $options{custom}->read_internet_services();
|
||||
|
||||
my $results = {};
|
||||
foreach (@$services) {
|
||||
my $name = $self->get_internet_service_name(tags => $_->{Tags}, id => $_->{InternetServiceId});
|
||||
|
||||
$results->{ $_->{InternetServiceId} } = {
|
||||
id => $_->{InternetServiceId},
|
||||
name => $name,
|
||||
state => lc($_->{State})
|
||||
};
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $results = $self->manage_selection(custom => $options{custom});
|
||||
foreach my $instance (sort keys %$results) {
|
||||
$self->{output}->output_add(long_msg =>
|
||||
join('', map("[$_: " . $results->{$instance}->{$_} . ']', @labels))
|
||||
);
|
||||
}
|
||||
|
||||
$self->{output}->output_add(
|
||||
severity => 'OK',
|
||||
short_msg => 'List internet services:'
|
||||
);
|
||||
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
|
||||
$self->{output}->exit();
|
||||
}
|
||||
|
||||
sub disco_format {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{output}->add_disco_format(elements => [@labels]);
|
||||
}
|
||||
|
||||
sub disco_show {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $results = $self->manage_selection(custom => $options{custom});
|
||||
foreach (sort keys %$results) {
|
||||
$self->{output}->add_disco_entry(
|
||||
%{$results->{$_}}
|
||||
);
|
||||
}
|
||||
}
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
List internet services.
|
||||
|
||||
=over 8
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
|
@ -0,0 +1,107 @@
|
|||
#
|
||||
# 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::outscale::mode::listloadbalancers;
|
||||
|
||||
use base qw(centreon::plugins::mode);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments => {});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::init(%options);
|
||||
}
|
||||
|
||||
my @labels = ('name', 'type');
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $lbs = $options{custom}->load_balancer_read();
|
||||
|
||||
my $results = {};
|
||||
foreach (@$lbs) {
|
||||
$results->{ $_->{LoadBalancerName} } = {
|
||||
name => $_->{LoadBalancerName},
|
||||
type => $_->{LoadBalancerType}
|
||||
};
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $results = $self->manage_selection(custom => $options{custom});
|
||||
foreach my $instance (sort keys %$results) {
|
||||
$self->{output}->output_add(long_msg =>
|
||||
join('', map("[$_: " . $results->{$instance}->{$_} . ']', @labels))
|
||||
);
|
||||
}
|
||||
|
||||
$self->{output}->output_add(
|
||||
severity => 'OK',
|
||||
short_msg => 'List load balancers:'
|
||||
);
|
||||
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
|
||||
$self->{output}->exit();
|
||||
}
|
||||
|
||||
sub disco_format {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{output}->add_disco_format(elements => [@labels]);
|
||||
}
|
||||
|
||||
sub disco_show {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $results = $self->manage_selection(custom => $options{custom});
|
||||
foreach (sort keys %$results) {
|
||||
$self->{output}->add_disco_entry(
|
||||
%{$results->{$_}}
|
||||
);
|
||||
}
|
||||
}
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
List load balancers.
|
||||
|
||||
=over 8
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
|
@ -0,0 +1,122 @@
|
|||
#
|
||||
# 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::outscale::mode::listnatservices;
|
||||
|
||||
use base qw(centreon::plugins::mode);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments => {
|
||||
'nat-tag-name:s' => { name => 'nat_tag_name', default => 'name' }
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::init(%options);
|
||||
}
|
||||
|
||||
my @labels = ('id', 'name', 'state');
|
||||
|
||||
sub get_nat_name {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
foreach my $tag (@{$options{tags}}) {
|
||||
return $tag->{Value} if ($tag->{Key} =~ /^$self->{option_results}->{nat_tag_name}$/i);
|
||||
}
|
||||
|
||||
return $options{id};
|
||||
}
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $services = $options{custom}->read_nat_services();
|
||||
|
||||
my $results = {};
|
||||
foreach (@$services) {
|
||||
my $name = $self->get_nat_name(tags => $_->{Tags}, id => $_->{NatServiceId});
|
||||
|
||||
$results->{ $_->{NatServiceId} } = {
|
||||
id => $_->{NatServiceId},
|
||||
name => $name,
|
||||
state => lc($_->{State})
|
||||
};
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $results = $self->manage_selection(custom => $options{custom});
|
||||
foreach my $instance (sort keys %$results) {
|
||||
$self->{output}->output_add(long_msg =>
|
||||
join('', map("[$_: " . $results->{$instance}->{$_} . ']', @labels))
|
||||
);
|
||||
}
|
||||
|
||||
$self->{output}->output_add(
|
||||
severity => 'OK',
|
||||
short_msg => 'List nat services:'
|
||||
);
|
||||
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
|
||||
$self->{output}->exit();
|
||||
}
|
||||
|
||||
sub disco_format {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{output}->add_disco_format(elements => [@labels]);
|
||||
}
|
||||
|
||||
sub disco_show {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $results = $self->manage_selection(custom => $options{custom});
|
||||
foreach (sort keys %$results) {
|
||||
$self->{output}->add_disco_entry(
|
||||
%{$results->{$_}}
|
||||
);
|
||||
}
|
||||
}
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
List nat services.
|
||||
|
||||
=over 8
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
|
@ -0,0 +1,122 @@
|
|||
#
|
||||
# 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::outscale::mode::listnets;
|
||||
|
||||
use base qw(centreon::plugins::mode);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments => {
|
||||
'net-tag-name:s' => { name => 'net_tag_name', default => 'name' }
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::init(%options);
|
||||
}
|
||||
|
||||
my @labels = ('id', 'name', 'state');
|
||||
|
||||
sub get_net_name {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
foreach my $tag (@{$options{tags}}) {
|
||||
return $tag->{Value} if ($tag->{Key} =~ /^$self->{option_results}->{net_tag_name}$/i);
|
||||
}
|
||||
|
||||
return $options{id};
|
||||
}
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $nets = $options{custom}->read_nets();
|
||||
|
||||
my $results = {};
|
||||
foreach (@$nets) {
|
||||
my $name = $self->get_net_name(tags => $_->{Tags}, id => $_->{NetId});
|
||||
|
||||
$results->{$name} = {
|
||||
id => $_->{NetId},
|
||||
name => $name,
|
||||
state => lc($_->{State})
|
||||
};
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $results = $self->manage_selection(custom => $options{custom});
|
||||
foreach my $instance (sort keys %$results) {
|
||||
$self->{output}->output_add(long_msg =>
|
||||
join('', map("[$_: " . $results->{$instance}->{$_} . ']', @labels))
|
||||
);
|
||||
}
|
||||
|
||||
$self->{output}->output_add(
|
||||
severity => 'OK',
|
||||
short_msg => 'List nets:'
|
||||
);
|
||||
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
|
||||
$self->{output}->exit();
|
||||
}
|
||||
|
||||
sub disco_format {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{output}->add_disco_format(elements => [@labels]);
|
||||
}
|
||||
|
||||
sub disco_show {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $results = $self->manage_selection(custom => $options{custom});
|
||||
foreach (sort keys %$results) {
|
||||
$self->{output}->add_disco_entry(
|
||||
%{$results->{$_}}
|
||||
);
|
||||
}
|
||||
}
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
List nets.
|
||||
|
||||
=over 8
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
|
@ -0,0 +1,107 @@
|
|||
#
|
||||
# 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::outscale::mode::listquotas;
|
||||
|
||||
use base qw(centreon::plugins::mode);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments => {});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::init(%options);
|
||||
}
|
||||
|
||||
my @labels = ('name', 'type');
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $quotas = $options{custom}->read_quotas();
|
||||
|
||||
my $results = [];
|
||||
foreach my $quota (@$quotas) {
|
||||
foreach (@{$quota->{Quotas}}) {
|
||||
push @$results, {
|
||||
name => $_->{Name},
|
||||
type => $quota->{QuotaType}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $results = $self->manage_selection(custom => $options{custom});
|
||||
foreach my $entry (@$results) {
|
||||
$self->{output}->output_add(long_msg =>
|
||||
join('', map("[$_: " . $entry->{$_} . ']', @labels))
|
||||
);
|
||||
}
|
||||
|
||||
$self->{output}->output_add(
|
||||
severity => 'OK',
|
||||
short_msg => 'List quotas:'
|
||||
);
|
||||
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
|
||||
$self->{output}->exit();
|
||||
}
|
||||
|
||||
sub disco_format {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{output}->add_disco_format(elements => [@labels]);
|
||||
}
|
||||
|
||||
sub disco_show {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $results = $self->manage_selection(custom => $options{custom});
|
||||
foreach my $entry (@$results) {
|
||||
$self->{output}->add_disco_entry(%$entry);
|
||||
}
|
||||
}
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
List quotas.
|
||||
|
||||
=over 8
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
|
@ -0,0 +1,106 @@
|
|||
#
|
||||
# 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::outscale::mode::listroutetables;
|
||||
|
||||
use base qw(centreon::plugins::mode);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments => {});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::init(%options);
|
||||
}
|
||||
|
||||
my @labels = ('id');
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $tables = $options{custom}->read_route_tables();
|
||||
|
||||
my $results = {};
|
||||
foreach (@$tables) {
|
||||
$results->{ $_->{RouteTableId} } = {
|
||||
id => $_->{RouteTableId}
|
||||
};
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $results = $self->manage_selection(custom => $options{custom});
|
||||
foreach my $instance (sort keys %$results) {
|
||||
$self->{output}->output_add(long_msg =>
|
||||
join('', map("[$_: " . $results->{$instance}->{$_} . ']', @labels))
|
||||
);
|
||||
}
|
||||
|
||||
$self->{output}->output_add(
|
||||
severity => 'OK',
|
||||
short_msg => 'List route tables:'
|
||||
);
|
||||
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
|
||||
$self->{output}->exit();
|
||||
}
|
||||
|
||||
sub disco_format {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{output}->add_disco_format(elements => [@labels]);
|
||||
}
|
||||
|
||||
sub disco_show {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $results = $self->manage_selection(custom => $options{custom});
|
||||
foreach (sort keys %$results) {
|
||||
$self->{output}->add_disco_entry(
|
||||
%{$results->{$_}}
|
||||
);
|
||||
}
|
||||
}
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
List route tables.
|
||||
|
||||
=over 8
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
|
@ -0,0 +1,122 @@
|
|||
#
|
||||
# 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::outscale::mode::listsubnets;
|
||||
|
||||
use base qw(centreon::plugins::mode);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments => {
|
||||
'subnet-tag-name:s' => { name => 'subnet_tag_name', default => 'name' }
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::init(%options);
|
||||
}
|
||||
|
||||
my @labels = ('id', 'name', 'state');
|
||||
|
||||
sub get_subnet_name {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
foreach my $tag (@{$options{tags}}) {
|
||||
return $tag->{Value} if ($tag->{Key} =~ /^$self->{option_results}->{subnet_tag_name}$/i);
|
||||
}
|
||||
|
||||
return $options{id};
|
||||
}
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $subnets = $options{custom}->read_subnets();
|
||||
|
||||
my $results = {};
|
||||
foreach (@$subnets) {
|
||||
my $name = $self->get_subnet_name(tags => $_->{Tags}, id => $_->{SubnetId});
|
||||
|
||||
$results->{$name} = {
|
||||
id => $_->{SubnetId},
|
||||
name => $name,
|
||||
state => lc($_->{State})
|
||||
};
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $results = $self->manage_selection(custom => $options{custom});
|
||||
foreach my $instance (sort keys %$results) {
|
||||
$self->{output}->output_add(long_msg =>
|
||||
join('', map("[$_: " . $results->{$instance}->{$_} . ']', @labels))
|
||||
);
|
||||
}
|
||||
|
||||
$self->{output}->output_add(
|
||||
severity => 'OK',
|
||||
short_msg => 'List subnets:'
|
||||
);
|
||||
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
|
||||
$self->{output}->exit();
|
||||
}
|
||||
|
||||
sub disco_format {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{output}->add_disco_format(elements => [@labels]);
|
||||
}
|
||||
|
||||
sub disco_show {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $results = $self->manage_selection(custom => $options{custom});
|
||||
foreach (sort keys %$results) {
|
||||
$self->{output}->add_disco_entry(
|
||||
%{$results->{$_}}
|
||||
);
|
||||
}
|
||||
}
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
List subnets.
|
||||
|
||||
=over 8
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
|
@ -0,0 +1,122 @@
|
|||
#
|
||||
# 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::outscale::mode::listvirtualgateways;
|
||||
|
||||
use base qw(centreon::plugins::mode);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments => {
|
||||
'vg-tag-name:s' => { name => 'vg_tag_name', default => 'name' }
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::init(%options);
|
||||
}
|
||||
|
||||
my @labels = ('id', 'name', 'state');
|
||||
|
||||
sub get_vg_name {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
foreach my $tag (@{$options{tags}}) {
|
||||
return $tag->{Value} if ($tag->{Key} =~ /^$self->{option_results}->{vg_tag_name}$/i);
|
||||
}
|
||||
|
||||
return $options{id};
|
||||
}
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $vgs = $options{custom}->read_virtual_gateways();
|
||||
|
||||
my $results = {};
|
||||
foreach (@$vgs) {
|
||||
my $name = $self->get_vg_name(tags => $_->{Tags}, id => $_->{VirtualGatewayId});
|
||||
|
||||
$results->{$name} = {
|
||||
id => $_->{VirtualGatewayId},
|
||||
name => $name,
|
||||
state => lc($_->{State})
|
||||
};
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $results = $self->manage_selection(custom => $options{custom});
|
||||
foreach my $instance (sort keys %$results) {
|
||||
$self->{output}->output_add(long_msg =>
|
||||
join('', map("[$_: " . $results->{$instance}->{$_} . ']', @labels))
|
||||
);
|
||||
}
|
||||
|
||||
$self->{output}->output_add(
|
||||
severity => 'OK',
|
||||
short_msg => 'List virtual gateways:'
|
||||
);
|
||||
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
|
||||
$self->{output}->exit();
|
||||
}
|
||||
|
||||
sub disco_format {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{output}->add_disco_format(elements => [@labels]);
|
||||
}
|
||||
|
||||
sub disco_show {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $results = $self->manage_selection(custom => $options{custom});
|
||||
foreach (sort keys %$results) {
|
||||
$self->{output}->add_disco_entry(
|
||||
%{$results->{$_}}
|
||||
);
|
||||
}
|
||||
}
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
List virtual gateways.
|
||||
|
||||
=over 8
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
|
@ -0,0 +1,122 @@
|
|||
#
|
||||
# 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::outscale::mode::listvms;
|
||||
|
||||
use base qw(centreon::plugins::mode);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments => {
|
||||
'vm-tag-name:s' => { name => 'vm_tag_name', default => 'name' }
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::init(%options);
|
||||
}
|
||||
|
||||
my @labels = ('id', 'name', 'state');
|
||||
|
||||
sub get_vm_name {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
foreach my $tag (@{$options{tags}}) {
|
||||
return $tag->{Value} if ($tag->{Key} =~ /^$self->{option_results}->{vm_tag_name}$/i);
|
||||
}
|
||||
|
||||
return $options{id};
|
||||
}
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $vms = $options{custom}->read_vms();
|
||||
|
||||
my $results = {};
|
||||
foreach (@$vms) {
|
||||
my $name = $self->get_vm_name(tags => $_->{Tags}, id => $_->{VmId});
|
||||
|
||||
$results->{ $_->{VmId} } = {
|
||||
id => $_->{VmId},
|
||||
name => $name,
|
||||
state => lc($_->{State})
|
||||
};
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $results = $self->manage_selection(custom => $options{custom});
|
||||
foreach my $instance (sort keys %$results) {
|
||||
$self->{output}->output_add(long_msg =>
|
||||
join('', map("[$_: " . $results->{$instance}->{$_} . ']', @labels))
|
||||
);
|
||||
}
|
||||
|
||||
$self->{output}->output_add(
|
||||
severity => 'OK',
|
||||
short_msg => 'List virtual machines:'
|
||||
);
|
||||
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
|
||||
$self->{output}->exit();
|
||||
}
|
||||
|
||||
sub disco_format {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{output}->add_disco_format(elements => [@labels]);
|
||||
}
|
||||
|
||||
sub disco_show {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $results = $self->manage_selection(custom => $options{custom});
|
||||
foreach (sort keys %$results) {
|
||||
$self->{output}->add_disco_entry(
|
||||
%{$results->{$_}}
|
||||
);
|
||||
}
|
||||
}
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
List virtual machines.
|
||||
|
||||
=over 8
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
|
@ -0,0 +1,109 @@
|
|||
#
|
||||
# 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::outscale::mode::listvolumes;
|
||||
|
||||
use base qw(centreon::plugins::mode);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments => {});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::init(%options);
|
||||
}
|
||||
|
||||
my @labels = ('id', 'region', 'type', 'state');
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $volumes = $options{custom}->read_volumes();
|
||||
|
||||
my $results = {};
|
||||
foreach (@$volumes) {
|
||||
$results->{ $_->{VolumeId} } = {
|
||||
id => $_->{VolumeId},
|
||||
region => $_->{SubregionName},
|
||||
type => $_->{VolumeType},
|
||||
state => lc($_->{State})
|
||||
};
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $results = $self->manage_selection(custom => $options{custom});
|
||||
foreach my $instance (sort keys %$results) {
|
||||
$self->{output}->output_add(long_msg =>
|
||||
join('', map("[$_: " . $results->{$instance}->{$_} . ']', @labels))
|
||||
);
|
||||
}
|
||||
|
||||
$self->{output}->output_add(
|
||||
severity => 'OK',
|
||||
short_msg => 'List volumes:'
|
||||
);
|
||||
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
|
||||
$self->{output}->exit();
|
||||
}
|
||||
|
||||
sub disco_format {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{output}->add_disco_format(elements => [@labels]);
|
||||
}
|
||||
|
||||
sub disco_show {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $results = $self->manage_selection(custom => $options{custom});
|
||||
foreach (sort keys %$results) {
|
||||
$self->{output}->add_disco_entry(
|
||||
%{$results->{$_}}
|
||||
);
|
||||
}
|
||||
}
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
List volumes.
|
||||
|
||||
=over 8
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
|
@ -0,0 +1,122 @@
|
|||
#
|
||||
# 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::outscale::mode::listvpnconnections;
|
||||
|
||||
use base qw(centreon::plugins::mode);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments => {
|
||||
'vpn-tag-name:s' => { name => 'vpn_tag_name', default => 'name' }
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::init(%options);
|
||||
}
|
||||
|
||||
my @labels = ('id', 'name', 'state');
|
||||
|
||||
sub get_vpn_name {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
foreach my $tag (@{$options{tags}}) {
|
||||
return $tag->{Value} if ($tag->{Key} =~ /^$self->{option_results}->{vpn_tag_name}$/i);
|
||||
}
|
||||
|
||||
return $options{id};
|
||||
}
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $connections = $options{custom}->read_vpn_connections();
|
||||
|
||||
my $results = {};
|
||||
foreach (@$connections) {
|
||||
my $name = $self->get_vpn_name(tags => $_->{Tags}, id => $_->{VpnConnectionId});
|
||||
|
||||
$results->{$name} = {
|
||||
id => $_->{VpnConnectionId},
|
||||
name => $name,
|
||||
state => lc($_->{State})
|
||||
};
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $results = $self->manage_selection(custom => $options{custom});
|
||||
foreach my $instance (sort keys %$results) {
|
||||
$self->{output}->output_add(long_msg =>
|
||||
join('', map("[$_: " . $results->{$instance}->{$_} . ']', @labels))
|
||||
);
|
||||
}
|
||||
|
||||
$self->{output}->output_add(
|
||||
severity => 'OK',
|
||||
short_msg => 'List vpn connections:'
|
||||
);
|
||||
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
|
||||
$self->{output}->exit();
|
||||
}
|
||||
|
||||
sub disco_format {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{output}->add_disco_format(elements => [@labels]);
|
||||
}
|
||||
|
||||
sub disco_show {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $results = $self->manage_selection(custom => $options{custom});
|
||||
foreach (sort keys %$results) {
|
||||
$self->{output}->add_disco_entry(
|
||||
%{$results->{$_}}
|
||||
);
|
||||
}
|
||||
}
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
List vpn connections.
|
||||
|
||||
=over 8
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
|
@ -0,0 +1,225 @@
|
|||
#
|
||||
# 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::outscale::mode::loadbalancers;
|
||||
|
||||
use base qw(centreon::plugins::templates::counter);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng);
|
||||
|
||||
sub lb_long_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return sprintf(
|
||||
"checking load balancer '%s'",
|
||||
$options{instance_value}->{name}
|
||||
);
|
||||
}
|
||||
|
||||
sub prefix_lb_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return sprintf(
|
||||
"load balancer '%s' ",
|
||||
$options{instance_value}->{name}
|
||||
);
|
||||
}
|
||||
|
||||
sub prefix_global_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return 'Number of load balancers ';
|
||||
}
|
||||
|
||||
sub prefix_vm_metrics_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return 'number of virtual machines ';
|
||||
}
|
||||
|
||||
sub prefix_vm_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return "virtual machine '" . $options{instance_value}->{vmName} . "' ";
|
||||
}
|
||||
|
||||
sub set_counters {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{maps_counters_type} = [
|
||||
{ name => 'global', type => 0, cb_prefix_output => 'prefix_global_output' },
|
||||
{
|
||||
name => 'lbs', type => 3, cb_prefix_output => 'prefix_lb_output', cb_long_output => 'lb_long_output', indent_long_output => ' ', message_multiple => 'All load balancers are ok',
|
||||
group => [
|
||||
{ name => 'vm_metrics', type => 0, cb_prefix_output => 'prefix_vm_metrics_output' },
|
||||
{ name => 'vms', display_long => 1, cb_prefix_output => 'prefix_vm_output', message_multiple => 'all virtual machines are ok', type => 1, skipped_code => { -10 => 1 } }
|
||||
]
|
||||
}
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{global} = [
|
||||
{ label => 'load-balancers-detected', display_ok => 0, nlabel => 'load_balancers.detected.count', set => {
|
||||
key_values => [ { name => 'detected' } ],
|
||||
output_template => 'detected: %s',
|
||||
perfdatas => [
|
||||
{ template => '%s', min => 0 }
|
||||
]
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{vm_metrics} = [
|
||||
{ label => 'load-balancer-vms-up', nlabel => 'load_balancer.virtual_machines.up.count', set => {
|
||||
key_values => [ { name => 'up' } ],
|
||||
output_template => 'up: %s',
|
||||
perfdatas => [
|
||||
{ template => '%s', min => 0, label_extra_instance => 1 }
|
||||
]
|
||||
}
|
||||
},
|
||||
{ label => 'load-balancer-vms-down', nlabel => 'load_balancer.virtual_machines.down.count', set => {
|
||||
key_values => [ { name => 'down' } ],
|
||||
output_template => 'down: %s',
|
||||
perfdatas => [
|
||||
{ template => '%s', min => 0, label_extra_instance => 1 }
|
||||
]
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{vms} = [
|
||||
{
|
||||
label => 'vm-status',
|
||||
type => 2,
|
||||
set => {
|
||||
key_values => [ { name => 'state' }, { name => 'vmName' } ],
|
||||
output_template => 'state: %s',
|
||||
closure_custom_perfdata => sub { return 0; },
|
||||
closure_custom_threshold_check => \&catalog_status_threshold_ng
|
||||
}
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
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-name:s' => { name => 'filter_name' },
|
||||
'vm-tag-name:s' => { name => 'vm_tag_name', default => 'name' }
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub get_vm_name {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
foreach my $vm (@{$options{vms}}) {
|
||||
next if ($vm->{VmId} ne $options{vm_id});
|
||||
|
||||
foreach my $tag (@{$vm->{Tags}}) {
|
||||
return $tag->{Value} if ($tag->{Key} =~ /^$self->{option_results}->{vm_tag_name}$/i);
|
||||
}
|
||||
}
|
||||
|
||||
return $options{vm_id};
|
||||
}
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $lbs = $options{custom}->load_balancer_read();
|
||||
my $vms = $options{custom}->read_vms();
|
||||
|
||||
$self->{global} = { detected => 0 };
|
||||
$self->{lbs} = {};
|
||||
|
||||
foreach my $lb (@$lbs) {
|
||||
next if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' &&
|
||||
$lb->{LoadBalancerName} !~ /$self->{option_results}->{filter_name}/);
|
||||
|
||||
$self->{global}->{detected}++;
|
||||
|
||||
$self->{lbs}->{ $lb->{LoadBalancerName} } = {
|
||||
name => $lb->{LoadBalancerName},
|
||||
vm_metrics => { up => 0, down => 0 },
|
||||
vms => {}
|
||||
};
|
||||
|
||||
my $members = $options{custom}->read_vms_health(load_balancer_name => $lb->{LoadBalancerName});
|
||||
foreach (@$members) {
|
||||
my $name = $self->get_vm_name(vms => $vms, vm_id => $_->{VmId});
|
||||
|
||||
$self->{lbs}->{ $lb->{LoadBalancerName} }->{vms}->{ $_->{VmId} } = {
|
||||
vmName => $name,
|
||||
state => lc($_->{State})
|
||||
};
|
||||
$self->{lbs}->{ $lb->{LoadBalancerName} }->{vm_metrics}->{ lc($_->{State}) }++
|
||||
if (defined($self->{lbs}->{ $lb->{LoadBalancerName} }->{vm_metrics}->{ lc($_->{State}) }));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check load balancers.
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--filter-name>
|
||||
|
||||
Filter load balancers by name.
|
||||
|
||||
=item B<--vm-tag-name>
|
||||
|
||||
Virtual machine tags to used for the name (Default: 'name').
|
||||
|
||||
=item B<--unknown-vm-status>
|
||||
|
||||
Set unknown threshold for status.
|
||||
Can used special variables like: %{state}, %{vmName}
|
||||
|
||||
=item B<--warning-vm-status>
|
||||
|
||||
Set warning threshold for status.
|
||||
Can used special variables like: %{state}, %{vmName}
|
||||
|
||||
=item B<--critical-vm-status>
|
||||
|
||||
Set critical threshold for status.
|
||||
Can used special variables like: %{state}, %{vmName}
|
||||
|
||||
=item B<--warning-*> B<--critical-*>
|
||||
|
||||
Thresholds.
|
||||
Can be: 'load-balancers-detected', 'load-balancer-vms-up', ''load-balancer-vms-down'.
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
|
@ -0,0 +1,175 @@
|
|||
#
|
||||
# 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::outscale::mode::natservices;
|
||||
|
||||
use base qw(centreon::plugins::templates::counter);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng);
|
||||
|
||||
sub prefix_service_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return sprintf(
|
||||
"nat service '%s' ",
|
||||
$options{instance_value}->{natName}
|
||||
);
|
||||
}
|
||||
|
||||
sub prefix_global_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return 'number of nat services ';
|
||||
}
|
||||
|
||||
sub set_counters {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{maps_counters_type} = [
|
||||
{ name => 'global', type => 0, cb_prefix_output => 'prefix_global_output' },
|
||||
{ name => 'services', type => 1, cb_prefix_output => 'prefix_service_output', message_multiple => 'All nat services are ok' }
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{global} = [];
|
||||
foreach ('detected', 'pending', 'available', 'deleting', 'deleted') {
|
||||
push @{$self->{maps_counters}->{global}}, {
|
||||
label => 'nat-services-' . $_, display_ok => 0, nlabel => 'nat_services.' . $_ . '.count', set => {
|
||||
key_values => [ { name => $_ } ],
|
||||
output_template => $_ . ': %s',
|
||||
perfdatas => [
|
||||
{ template => '%s', min => 0 }
|
||||
]
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
$self->{maps_counters}->{services} = [
|
||||
{
|
||||
label => 'nat-service-status',
|
||||
type => 2,
|
||||
set => {
|
||||
key_values => [ { name => 'state' }, { name => 'natName' } ],
|
||||
output_template => 'state: %s',
|
||||
closure_custom_perfdata => sub { return 0; },
|
||||
closure_custom_threshold_check => \&catalog_status_threshold_ng
|
||||
}
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
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-id:s' => { name => 'filter_id' },
|
||||
'filter-name:s' => { name => 'filter_name' },
|
||||
'nat-tag-name:s' => { name => 'nat_tag_name', default => 'name' }
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub get_nat_name {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
foreach my $tag (@{$options{tags}}) {
|
||||
return $tag->{Value} if ($tag->{Key} =~ /^$self->{option_results}->{nat_tag_name}$/i);
|
||||
}
|
||||
|
||||
return $options{id};
|
||||
}
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $services = $options{custom}->read_nat_services();
|
||||
|
||||
$self->{global} = { detected => 0, pending => 0, available => 0, deleting => 0, deleted => 0 };
|
||||
$self->{services} = {};
|
||||
|
||||
foreach (@$services) {
|
||||
my $name = $self->get_nat_name(tags => $_->{Tags}, id => $_->{NatServiceId});
|
||||
|
||||
next if (defined($self->{option_results}->{filter_id}) && $self->{option_results}->{filter_id} ne '' &&
|
||||
$_->{NatServiceId} !~ /$self->{option_results}->{filter_id}/);
|
||||
next if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' &&
|
||||
$name !~ /$self->{option_results}->{filter_name}/);
|
||||
|
||||
$self->{services}->{ $_->{NatServiceId} } = {
|
||||
natName => $name,
|
||||
state => lc($_->{State})
|
||||
};
|
||||
|
||||
$self->{global}->{ lc($_->{State}) }++
|
||||
if (defined($self->{global}->{ lc($_->{State}) }));
|
||||
$self->{global}->{detected}++;
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check nat services.
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--filter-id>
|
||||
|
||||
Filter nat services by id.
|
||||
|
||||
=item B<--filter-name>
|
||||
|
||||
Filter nat services by name.
|
||||
|
||||
=item B<--nat-tag-name>
|
||||
|
||||
Nat service tag to be used for the name (Default: 'name').
|
||||
|
||||
=item B<--unknown-nat-service-status>
|
||||
|
||||
Set unknown threshold for status.
|
||||
Can used special variables like: %{state}, %{natName}
|
||||
|
||||
=item B<--warning-nat-service-status>
|
||||
|
||||
Set warning threshold for status.
|
||||
Can used special variables like: %{state}, %{natName}
|
||||
|
||||
=item B<--critical-nat-service-status>
|
||||
|
||||
Set critical threshold for status.
|
||||
Can used special variables like: %{state}, %{natName}
|
||||
|
||||
=item B<--warning-*> B<--critical-*>
|
||||
|
||||
Thresholds.
|
||||
Can be: 'nat-services-detected', 'nat-services-pending', 'nat-services-available',
|
||||
'nat-services-deleting', 'nat-services-deleted'.
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
|
@ -0,0 +1,168 @@
|
|||
#
|
||||
# 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::outscale::mode::nets;
|
||||
|
||||
use base qw(centreon::plugins::templates::counter);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng);
|
||||
|
||||
sub prefix_net_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return sprintf(
|
||||
"net '%s' ",
|
||||
$options{instance_value}->{netName}
|
||||
);
|
||||
}
|
||||
|
||||
sub prefix_global_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return 'number of nets ';
|
||||
}
|
||||
|
||||
sub set_counters {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{maps_counters_type} = [
|
||||
{ name => 'global', type => 0, cb_prefix_output => 'prefix_global_output' },
|
||||
{ name => 'nets', type => 1, cb_prefix_output => 'prefix_net_output', message_multiple => 'All nets are ok' }
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{global} = [];
|
||||
foreach ('detected', 'pending', 'available', 'deleted') {
|
||||
push @{$self->{maps_counters}->{global}}, {
|
||||
label => 'nets-' . $_, display_ok => 0, nlabel => 'nets.' . $_ . '.count', set => {
|
||||
key_values => [ { name => $_ } ],
|
||||
output_template => $_ . ': %s',
|
||||
perfdatas => [
|
||||
{ template => '%s', min => 0 }
|
||||
]
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
$self->{maps_counters}->{nets} = [
|
||||
{
|
||||
label => 'net-status',
|
||||
type => 2,
|
||||
set => {
|
||||
key_values => [ { name => 'state' }, { name => 'netName' } ],
|
||||
output_template => 'state: %s',
|
||||
closure_custom_perfdata => sub { return 0; },
|
||||
closure_custom_threshold_check => \&catalog_status_threshold_ng
|
||||
}
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
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-name:s' => { name => 'filter_name' },
|
||||
'net-tag-name:s' => { name => 'net_tag_name', default => 'name' }
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub get_net_name {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
foreach my $tag (@{$options{tags}}) {
|
||||
return $tag->{Value} if ($tag->{Key} =~ /^$self->{option_results}->{net_tag_name}$/i);
|
||||
}
|
||||
|
||||
return $options{id};
|
||||
}
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $nets = $options{custom}->read_nets();
|
||||
|
||||
$self->{global} = { detected => 0, available => 0, pending => 0, deleted => 0 };
|
||||
$self->{nets} = {};
|
||||
|
||||
foreach my $net (@$nets) {
|
||||
my $name = $self->get_net_name(tags => $net->{Tags}, id => $net->{NetId});
|
||||
|
||||
next if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' &&
|
||||
$name !~ /$self->{option_results}->{filter_name}/);
|
||||
|
||||
$self->{nets}->{$name} = {
|
||||
netName => $name,
|
||||
state => lc($net->{State})
|
||||
};
|
||||
|
||||
$self->{global}->{ lc($net->{State}) }++
|
||||
if (defined($self->{global}->{ lc($net->{State}) }));
|
||||
$self->{global}->{detected}++;
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check nets.
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--filter-name>
|
||||
|
||||
Filter nets by name.
|
||||
|
||||
=item B<--net-tag-name>
|
||||
|
||||
Nets tag to be used for the name (Default: 'name').
|
||||
|
||||
=item B<--unknown-net-status>
|
||||
|
||||
Set unknown threshold for status.
|
||||
Can used special variables like: %{state}, %{netName}
|
||||
|
||||
=item B<--warning-net-status>
|
||||
|
||||
Set warning threshold for status.
|
||||
Can used special variables like: %{state}, %{netName}
|
||||
|
||||
=item B<--critical-net-status>
|
||||
|
||||
Set critical threshold for status.
|
||||
Can used special variables like: %{state}, %{netName}
|
||||
|
||||
=item B<--warning-*> B<--critical-*>
|
||||
|
||||
Thresholds.
|
||||
Can be: 'nets-detected', 'nets-available', 'nets-pending',
|
||||
'nets-deleted'.
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
|
@ -0,0 +1,200 @@
|
|||
#
|
||||
# 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::outscale::mode::quotas;
|
||||
|
||||
use base qw(centreon::plugins::templates::counter);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub custom_quota_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return sprintf(
|
||||
'total: %s used: %s (%.2f%%) free: %s (%.2f%%)',
|
||||
$self->{result_values}->{total},
|
||||
$self->{result_values}->{used},
|
||||
$self->{result_values}->{prct_used},
|
||||
$self->{result_values}->{free},
|
||||
$self->{result_values}->{prct_free}
|
||||
);
|
||||
}
|
||||
|
||||
sub prefix_quota_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return sprintf(
|
||||
"quota '%s' [type: %s] ",
|
||||
$options{instance_value}->{name},
|
||||
$options{instance_value}->{type}
|
||||
);
|
||||
}
|
||||
|
||||
sub set_counters {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{maps_counters_type} = [
|
||||
{ name => 'quotas', type => 1, cb_prefix_output => 'prefix_quota_output', message_multiple => 'All quotas are ok' }
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{quotas} = [
|
||||
{ label => 'quota-usage', nlabel => 'quota.usage.count', set => {
|
||||
key_values => [ { name => 'used' }, { name => 'free' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' }, { name => 'name' }, { name => 'type' } ],
|
||||
closure_custom_output => $self->can('custom_quota_output'),
|
||||
closure_custom_perfdata => sub {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{output}->perfdata_add(
|
||||
nlabel => $self->{nlabel},
|
||||
instances => [$self->{result_values}->{type}, $self->{result_values}->{name}],
|
||||
value => $self->{result_values}->{used},
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel}),
|
||||
min => 0,
|
||||
max => $self->{result_values}->{total}
|
||||
);
|
||||
}
|
||||
}
|
||||
},
|
||||
{ label => 'quota-usage-free', display_ok => 0, nlabel => 'quota.free.count', set => {
|
||||
key_values => [ { name => 'free' }, { name => 'used' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' }, { name => 'name' }, { name => 'type' } ],
|
||||
closure_custom_output => $self->can('custom_quota_output'),
|
||||
closure_custom_perfdata => sub {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{output}->perfdata_add(
|
||||
nlabel => $self->{nlabel},
|
||||
instances => [$self->{result_values}->{type}, $self->{result_values}->{name}],
|
||||
value => $self->{result_values}->{free},
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel}),
|
||||
min => 0,
|
||||
max => $self->{result_values}->{total}
|
||||
);
|
||||
}
|
||||
}
|
||||
},
|
||||
{ label => 'quota-usage-prct', display_ok => 0, nlabel => 'quota.usage.percentage', set => {
|
||||
key_values => [ { name => 'prct_used' }, { name => 'used' }, { name => 'free' }, { name => 'prct_free' }, { name => 'total' }, { name => 'name' }, { name => 'type' } ],
|
||||
closure_custom_output => $self->can('custom_quota_output'),
|
||||
closure_custom_perfdata => sub {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{output}->perfdata_add(
|
||||
nlabel => $self->{nlabel},
|
||||
unit => '%',
|
||||
instances => [$self->{result_values}->{type}, $self->{result_values}->{name}],
|
||||
value => sprintf('%.2f', $self->{result_values}->{prct_used}),
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel}),
|
||||
min => 0,
|
||||
max => 100
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
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-name:s' => { name => 'filter_name' },
|
||||
'filter-type:s' => { name => 'filter_type' }
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $quotas = $options{custom}->read_quotas();
|
||||
|
||||
my $i = 0;
|
||||
$self->{quotas} = {};
|
||||
foreach my $quota (@$quotas) {
|
||||
next if (defined($self->{option_results}->{filter_type}) && $self->{option_results}->{filter_type} ne '' &&
|
||||
$quota->{QuotaType} !~ /$self->{option_results}->{filter_type}/);
|
||||
foreach (@{$quota->{Quotas}}) {
|
||||
next if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' &&
|
||||
$_->{Name} !~ /$self->{option_results}->{filter_name}/);
|
||||
next if ($_->{MaxValue} <= 0);
|
||||
|
||||
$self->{quotas}->{$i} = {
|
||||
name => $_->{Name},
|
||||
type => $quota->{QuotaType},
|
||||
total => $_->{MaxValue},
|
||||
used => $_->{UsedValue},
|
||||
free => $_->{MaxValue} - $_->{UsedValue},
|
||||
prct_used => $_->{UsedValue} * 100 / $_->{MaxValue},
|
||||
prct_free => 100 - ($_->{UsedValue} * 100 / $_->{MaxValue})
|
||||
};
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check quotas.
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--filter-name>
|
||||
|
||||
Filter nets by name.
|
||||
|
||||
=item B<--net-tag-name>
|
||||
|
||||
Nets tag to be used for the name (Default: 'name').
|
||||
|
||||
=item B<--unknown-net-status>
|
||||
|
||||
Set unknown threshold for status.
|
||||
Can used special variables like: %{state}, %{netName}
|
||||
|
||||
=item B<--warning-net-status>
|
||||
|
||||
Set warning threshold for status.
|
||||
Can used special variables like: %{state}, %{netName}
|
||||
|
||||
=item B<--critical-net-status>
|
||||
|
||||
Set critical threshold for status.
|
||||
Can used special variables like: %{state}, %{netName}
|
||||
|
||||
=item B<--warning-*> B<--critical-*>
|
||||
|
||||
Thresholds.
|
||||
Can be: 'nets-detected', 'nets-available', 'nets-pending',
|
||||
'nets-deleted'.
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
|
@ -0,0 +1,127 @@
|
|||
#
|
||||
# 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::outscale::mode::routetables;
|
||||
|
||||
use base qw(centreon::plugins::templates::counter);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub prefix_table_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return sprintf(
|
||||
"route table '%s' ",
|
||||
$options{instance}
|
||||
);
|
||||
}
|
||||
|
||||
sub prefix_global_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return 'number of route tables ';
|
||||
}
|
||||
|
||||
sub set_counters {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{maps_counters_type} = [
|
||||
{ name => 'global', type => 0, cb_prefix_output => 'prefix_global_output' },
|
||||
{ name => 'tables', type => 1, cb_prefix_output => 'prefix_table_output', message_multiple => 'All route tables are ok' }
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{global} = [
|
||||
{ label => 'route-tables-detected', display_ok => 0, nlabel => 'route_tables.detected.count', set => {
|
||||
key_values => [ { name => 'detected' } ],
|
||||
output_template => 'detected: %s',
|
||||
perfdatas => [
|
||||
{ template => '%s', min => 0 }
|
||||
]
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{tables} = [
|
||||
{ label => 'route-tables-routes', nlabel => 'route_tables.routes.count', set => {
|
||||
key_values => [ { name => 'num_routes' } ],
|
||||
output_template => 'number of routes: %s',
|
||||
perfdatas => [
|
||||
{ template => '%s', min => 0, label_extra_instance => 1 }
|
||||
]
|
||||
}
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
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-route-table-id:s' => { name => 'filter_route_table_id' }
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $tables = $options{custom}->read_route_tables();
|
||||
|
||||
$self->{global} = { detected => 0 };
|
||||
$self->{tables} = {};
|
||||
|
||||
foreach (@$tables) {
|
||||
next if (defined($self->{option_results}->{filter_route_table_id}) && $self->{option_results}->{filter_route_table_id} ne '' &&
|
||||
$_->{RouteTableId} !~ /$self->{option_results}->{filter_route_table_id}/);
|
||||
|
||||
$self->{tables}->{ $_->{RouteTableId} } = {
|
||||
num_routes => scalar(@{$_->{Routes}}),
|
||||
};
|
||||
|
||||
$self->{global}->{detected}++;
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check route tables.
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--filter-route-table-id>
|
||||
|
||||
Filter route tables by id.
|
||||
|
||||
=item B<--warning-*> B<--critical-*>
|
||||
|
||||
Thresholds.
|
||||
Can be: 'route-tables-detected', 'route-tables-routes'.
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
|
@ -0,0 +1,213 @@
|
|||
#
|
||||
# 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::outscale::mode::subnets;
|
||||
|
||||
use base qw(centreon::plugins::templates::counter);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng);
|
||||
|
||||
sub custom_subnet_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return sprintf(
|
||||
'total: %s used: %s (%.2f%%) free: %s (%.2f%%)',
|
||||
$self->{result_values}->{total},
|
||||
$self->{result_values}->{used},
|
||||
$self->{result_values}->{prct_used},
|
||||
$self->{result_values}->{free},
|
||||
$self->{result_values}->{prct_free}
|
||||
);
|
||||
}
|
||||
|
||||
sub subnet_long_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return sprintf(
|
||||
"checking subnet '%s'",
|
||||
$options{instance_value}->{name}
|
||||
);
|
||||
}
|
||||
|
||||
sub prefix_subnet_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return sprintf(
|
||||
"subnet '%s' ",
|
||||
$options{instance_value}->{name}
|
||||
);
|
||||
}
|
||||
|
||||
sub prefix_global_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return 'number of subnets ';
|
||||
}
|
||||
|
||||
sub set_counters {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{maps_counters_type} = [
|
||||
{ name => 'global', type => 0, cb_prefix_output => 'prefix_global_output' },
|
||||
{
|
||||
name => 'subnets', type => 3, cb_prefix_output => 'prefix_subnet_output', cb_long_output => 'subnet_long_output', indent_long_output => ' ', message_multiple => 'All subnets are ok',
|
||||
group => [
|
||||
{ name => 'status', type => 0 },
|
||||
{ name => 'metrics', type => 0 }
|
||||
]
|
||||
}
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{global} = [];
|
||||
foreach ('detected', 'pending', 'available', 'deleted') {
|
||||
push @{$self->{maps_counters}->{global}}, {
|
||||
label => 'subnets-' . $_, display_ok => 0, nlabel => 'subnets.' . $_ . '.count', set => {
|
||||
key_values => [ { name => $_ } ],
|
||||
output_template => $_ . ': %s',
|
||||
perfdatas => [
|
||||
{ template => '%s', min => 0 }
|
||||
]
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
$self->{maps_counters}->{status} = [
|
||||
{
|
||||
label => 'subnet-status',
|
||||
type => 2,
|
||||
set => {
|
||||
key_values => [ { name => 'state' }, { name => 'subnetName' } ],
|
||||
output_template => 'state: %s',
|
||||
closure_custom_perfdata => sub { return 0; },
|
||||
closure_custom_threshold_check => \&catalog_status_threshold_ng
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{metrics} = [
|
||||
{ label => 'subnet-addresses-usage-free', nlabel => 'subnet.addresses.free.count', set => {
|
||||
key_values => [ { name => 'freeAddresses' }, { name => 'subnetName'} ],
|
||||
output_template => 'number of addresses free: %s',
|
||||
perfdatas => [
|
||||
{ template => '%d', min => 0, label_extra_instance => 1, instance_use => 'subnetName' }
|
||||
]
|
||||
}
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
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-name:s' => { name => 'filter_name' },
|
||||
'subnet-tag-name:s' => { name => 'subnet_tag_name', default => 'name' }
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub get_subnet_name {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
foreach my $tag (@{$options{tags}}) {
|
||||
return $tag->{Value} if ($tag->{Key} =~ /^$self->{option_results}->{subnet_tag_name}$/i);
|
||||
}
|
||||
|
||||
return $options{id};
|
||||
}
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $subnets = $options{custom}->read_subnets();
|
||||
|
||||
$self->{global} = { available => 0, pending => 0, deleted => 0 };
|
||||
$self->{subnets} = {};
|
||||
foreach (@$subnets) {
|
||||
my $name = $self->get_subnet_name(tags => $_->{Tags}, id => $_->{SubnetId});
|
||||
|
||||
next if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' &&
|
||||
$name !~ /$self->{option_results}->{filter_name}/);
|
||||
|
||||
$self->{subnets}->{ $_->{SubnetId} } = {
|
||||
name => $name,
|
||||
status => {
|
||||
subnetName => $name,
|
||||
state => lc($_->{State})
|
||||
},
|
||||
metrics => {
|
||||
subnetName => $name,
|
||||
freeAddresses => $_->{AvailableIpsCount}
|
||||
}
|
||||
};
|
||||
|
||||
$self->{global}->{ lc($_->{State}) }++
|
||||
if (defined($self->{global}->{ lc($_->{State}) }));
|
||||
$self->{global}->{detected}++;
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check subnets.
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--filter-name>
|
||||
|
||||
Filter subnets by name.
|
||||
|
||||
=item B<--subnet-tag-name>
|
||||
|
||||
Subnet tags to be used for the name (Default: 'name').
|
||||
|
||||
=item B<--unknown-subnet-status>
|
||||
|
||||
Set unknown threshold for status.
|
||||
Can used special variables like: %{state}, %{subnetName}
|
||||
|
||||
=item B<--warning-subnet-status>
|
||||
|
||||
Set warning threshold for status.
|
||||
Can used special variables like: %{state}, %{subnetName}
|
||||
|
||||
=item B<--critical-subnet-status>
|
||||
|
||||
Set critical threshold for status.
|
||||
Can used special variables like: %{state}, %{subnetName}
|
||||
|
||||
=item B<--warning-*> B<--critical-*>
|
||||
|
||||
Thresholds.
|
||||
Can be: 'subnets-detected', 'subnets-available', 'subnets-pending',
|
||||
'subnets-deleted'.
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
|
@ -0,0 +1,198 @@
|
|||
#
|
||||
# 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::outscale::mode::virtualgateways;
|
||||
|
||||
use base qw(centreon::plugins::templates::counter);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng);
|
||||
|
||||
sub prefix_vg_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return sprintf(
|
||||
"virtual gateway '%s' ",
|
||||
$options{instance_value}->{vgName}
|
||||
);
|
||||
}
|
||||
|
||||
sub prefix_global_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return 'number of virtual gateways ';
|
||||
}
|
||||
|
||||
sub set_counters {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{maps_counters_type} = [
|
||||
{ name => 'global', type => 0, cb_prefix_output => 'prefix_global_output' },
|
||||
{ name => 'vgs', type => 1, cb_prefix_output => 'prefix_vg_output', message_multiple => 'All virtual gateways are ok' }
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{global} = [
|
||||
{ label => 'vgs-detected', display_ok => 0, nlabel => 'virtual_gateways.detected.count', set => {
|
||||
key_values => [ { name => 'detected' } ],
|
||||
output_template => 'detected: %s',
|
||||
perfdatas => [
|
||||
{ template => '%s', min => 0 }
|
||||
]
|
||||
}
|
||||
},
|
||||
{ label => 'vgs-available', display_ok => 0, nlabel => 'virtual_gateways.available.count', set => {
|
||||
key_values => [ { name => 'available' } ],
|
||||
output_template => 'available: %s',
|
||||
perfdatas => [
|
||||
{ template => '%s', min => 0 }
|
||||
]
|
||||
}
|
||||
},
|
||||
{ label => 'vgs-pending', display_ok => 0, nlabel => 'virtual_gateways.pending.count', set => {
|
||||
key_values => [ { name => 'pending' } ],
|
||||
output_template => 'pending: %s',
|
||||
perfdatas => [
|
||||
{ template => '%s', min => 0 }
|
||||
]
|
||||
}
|
||||
},
|
||||
{ label => 'vgs-deleting', display_ok => 0, nlabel => 'virtual_gateways.deleting.count', set => {
|
||||
key_values => [ { name => 'deleting' } ],
|
||||
output_template => 'deleting: %s',
|
||||
perfdatas => [
|
||||
{ template => '%s', min => 0 }
|
||||
]
|
||||
}
|
||||
},
|
||||
{ label => 'vgs-deleted', display_ok => 0, nlabel => 'virtual_gateways.deleted.count', set => {
|
||||
key_values => [ { name => 'deleted' } ],
|
||||
output_template => 'deleted: %s',
|
||||
perfdatas => [
|
||||
{ template => '%s', min => 0 }
|
||||
]
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{vgs} = [
|
||||
{
|
||||
label => 'vg-status',
|
||||
type => 2,
|
||||
set => {
|
||||
key_values => [ { name => 'state' }, { name => 'vgName' } ],
|
||||
output_template => 'state: %s',
|
||||
closure_custom_perfdata => sub { return 0; },
|
||||
closure_custom_threshold_check => \&catalog_status_threshold_ng
|
||||
}
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
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-name:s' => { name => 'filter_name' },
|
||||
'vg-tag-name:s' => { name => 'vg_tag_name', default => 'name' }
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub get_vg_name {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
foreach my $tag (@{$options{tags}}) {
|
||||
return $tag->{Value} if ($tag->{Key} =~ /^$self->{option_results}->{vg_tag_name}$/i);
|
||||
}
|
||||
|
||||
return $options{id};
|
||||
}
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $vgs = $options{custom}->read_virtual_gateways();
|
||||
|
||||
$self->{global} = { detected => 0, available => 0, pending => 0, deleting => 0, deleted => 0 };
|
||||
$self->{vgs} = {};
|
||||
|
||||
foreach my $vg (@$vgs) {
|
||||
my $name = $self->get_vg_name(tags => $vg->{Tags}, id => $vg->{VirtualGatewayId});
|
||||
|
||||
next if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' &&
|
||||
$name !~ /$self->{option_results}->{filter_name}/);
|
||||
|
||||
$self->{vgs}->{$name} = {
|
||||
vgName => $name,
|
||||
state => lc($vg->{State})
|
||||
};
|
||||
|
||||
$self->{global}->{ lc($vg->{State}) }++
|
||||
if (defined($self->{global}->{ lc($vg->{State}) }));
|
||||
$self->{global}->{detected}++;
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check virtual gateways.
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--filter-name>
|
||||
|
||||
Filter virtual gateways by name.
|
||||
|
||||
=item B<--vg-tag-name>
|
||||
|
||||
Virtual gateway tag to be used for the name (Default: 'name').
|
||||
|
||||
=item B<--unknown-vg-status>
|
||||
|
||||
Set unknown threshold for status.
|
||||
Can used special variables like: %{state}, %{vgName}
|
||||
|
||||
=item B<--warning-vg-status>
|
||||
|
||||
Set warning threshold for status.
|
||||
Can used special variables like: %{state}, %{vgName}
|
||||
|
||||
=item B<--critical-vg-status>
|
||||
|
||||
Set critical threshold for status.
|
||||
Can used special variables like: %{state}, %{vgName}
|
||||
|
||||
=item B<--warning-*> B<--critical-*>
|
||||
|
||||
Thresholds.
|
||||
Can be: 'vgs-detected', 'vgs-available', 'vgs-pending',
|
||||
'vgs-deleting', 'vgs-deleted'.
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
|
@ -0,0 +1,175 @@
|
|||
#
|
||||
# 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::outscale::mode::vms;
|
||||
|
||||
use base qw(centreon::plugins::templates::counter);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng);
|
||||
|
||||
sub prefix_vm_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return sprintf(
|
||||
"virtual machine '%s' ",
|
||||
$options{instance_value}->{vmName}
|
||||
);
|
||||
}
|
||||
|
||||
sub prefix_global_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return 'number of virtual machines ';
|
||||
}
|
||||
|
||||
sub set_counters {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{maps_counters_type} = [
|
||||
{ name => 'global', type => 0, cb_prefix_output => 'prefix_global_output' },
|
||||
{ name => 'vms', type => 1, cb_prefix_output => 'prefix_vm_output', message_multiple => 'All virtual machines are ok' }
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{global} = [];
|
||||
foreach ('detected', 'pending', 'running', 'stopping', 'stopped', 'shutting-down', 'terminated', 'quarantine') {
|
||||
push @{$self->{maps_counters}->{global}}, {
|
||||
label => 'vms-' . $_, display_ok => 0, nlabel => 'virtual_machines.' . $_ . '.count', set => {
|
||||
key_values => [ { name => $_ } ],
|
||||
output_template => $_ . ': %s',
|
||||
perfdatas => [
|
||||
{ template => '%s', min => 0 }
|
||||
]
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
$self->{maps_counters}->{vms} = [
|
||||
{
|
||||
label => 'vm-status',
|
||||
type => 2,
|
||||
set => {
|
||||
key_values => [ { name => 'state' }, { name => 'vmName' } ],
|
||||
output_template => 'state: %s',
|
||||
closure_custom_perfdata => sub { return 0; },
|
||||
closure_custom_threshold_check => \&catalog_status_threshold_ng
|
||||
}
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
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-id:s' => { name => 'filter_id' },
|
||||
'filter-name:s' => { name => 'filter_name' },
|
||||
'vm-tag-name:s' => { name => 'vm_tag_name', default => 'name' }
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub get_vm_name {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
foreach my $tag (@{$options{tags}}) {
|
||||
return $tag->{Value} if ($tag->{Key} =~ /^$self->{option_results}->{vm_tag_name}$/i);
|
||||
}
|
||||
|
||||
return $options{id};
|
||||
}
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $vms = $options{custom}->read_vms();
|
||||
|
||||
$self->{global} = { detected => 0, pending => 0, running => 0, stopping => 0, stopped => 0, 'shutting-down' => 0, terminated => 0, quarantine => 0 };
|
||||
$self->{vms} = {};
|
||||
|
||||
foreach (@$vms) {
|
||||
my $name = $self->get_vm_name(tags => $_->{Tags}, id => $_->{VmId});
|
||||
|
||||
next if (defined($self->{option_results}->{filter_id}) && $self->{option_results}->{filter_id} ne '' &&
|
||||
$_->{VmId} !~ /$self->{option_results}->{filter_id}/);
|
||||
next if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' &&
|
||||
$name !~ /$self->{option_results}->{filter_name}/);
|
||||
|
||||
$self->{vms}->{ $_->{VmId} } = {
|
||||
vmName => $name,
|
||||
state => lc($_->{State})
|
||||
};
|
||||
|
||||
$self->{global}->{ lc($_->{State}) }++
|
||||
if (defined($self->{global}->{ lc($_->{State}) }));
|
||||
$self->{global}->{detected}++;
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check virtual machines.
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--filter-id>
|
||||
|
||||
Filter virtual machines by id.
|
||||
|
||||
=item B<--filter-name>
|
||||
|
||||
Filter virtual machines by name.
|
||||
|
||||
=item B<--vm-tag-name>
|
||||
|
||||
Virtual machine tag to be used for the name (Default: 'name').
|
||||
|
||||
=item B<--unknown-vm-status>
|
||||
|
||||
Set unknown threshold for status.
|
||||
Can used special variables like: %{state}, %{vmName}
|
||||
|
||||
=item B<--warning-vm-status>
|
||||
|
||||
Set warning threshold for status.
|
||||
Can used special variables like: %{state}, %{vmName}
|
||||
|
||||
=item B<--critical-vm-status>
|
||||
|
||||
Set critical threshold for status.
|
||||
Can used special variables like: %{state}, %{vmName}
|
||||
|
||||
=item B<--warning-*> B<--critical-*>
|
||||
|
||||
Thresholds.
|
||||
Can be: 'vms-detected', 'vms-pending', 'vms-running', 'vms-stopping',
|
||||
'vms-stopped', 'vms-shutting-down', 'vms-terminated', 'vms-quarantine'.
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
|
@ -0,0 +1,218 @@
|
|||
#
|
||||
# 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::outscale::mode::volumes;
|
||||
|
||||
use base qw(centreon::plugins::templates::counter);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng);
|
||||
|
||||
sub volume_long_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return sprintf(
|
||||
"checking volume '%s'",
|
||||
$options{instance_value}->{id}
|
||||
);
|
||||
}
|
||||
|
||||
sub prefix_volume_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return sprintf(
|
||||
"volume '%s' ",
|
||||
$options{instance_value}->{id}
|
||||
);
|
||||
}
|
||||
|
||||
sub prefix_global_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return 'number of volumes ';
|
||||
}
|
||||
|
||||
sub prefix_vm_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return "virtual machine '" . $options{instance_value}->{vmName} . "' ";
|
||||
}
|
||||
|
||||
sub set_counters {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{maps_counters_type} = [
|
||||
{ name => 'global', type => 0, cb_prefix_output => 'prefix_global_output' },
|
||||
{
|
||||
name => 'volumes', type => 3, cb_prefix_output => 'prefix_volume_output', cb_long_output => 'volume_long_output', indent_long_output => ' ', message_multiple => 'All volumes are ok',
|
||||
group => [
|
||||
{ name => 'status', type => 0 },
|
||||
{ name => 'vms', display_long => 1, cb_prefix_output => 'prefix_vm_output', message_multiple => 'all virtual machines are ok', type => 1, skipped_code => { -10 => 1 } }
|
||||
]
|
||||
}
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{global} = [];
|
||||
foreach ('detected', 'creating', 'available', 'in-use', 'updating', 'deleting', 'error') {
|
||||
push @{$self->{maps_counters}->{global}}, {
|
||||
label => 'volumes-' . $_, display_ok => 0, nlabel => 'volumes.' . $_ . '.count', set => {
|
||||
key_values => [ { name => $_ } ],
|
||||
output_template => $_ . ': %s',
|
||||
perfdatas => [
|
||||
{ template => '%s', min => 0 }
|
||||
]
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
$self->{maps_counters}->{status} = [
|
||||
{
|
||||
label => 'volume-status',
|
||||
type => 2,
|
||||
set => {
|
||||
key_values => [ { name => 'state' }, { name => 'volumeId' } ],
|
||||
output_template => 'state: %s',
|
||||
closure_custom_perfdata => sub { return 0; },
|
||||
closure_custom_threshold_check => \&catalog_status_threshold_ng
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{vms} = [
|
||||
{
|
||||
label => 'vm-status',
|
||||
type => 2,
|
||||
set => {
|
||||
key_values => [ { name => 'state' }, { name => 'vmName' } ],
|
||||
output_template => 'volume state: %s',
|
||||
closure_custom_perfdata => sub { return 0; },
|
||||
closure_custom_threshold_check => \&catalog_status_threshold_ng
|
||||
}
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
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-id:s' => { name => 'filter_id' },
|
||||
'vm-tag-name:s' => { name => 'vm_tag_name', default => 'name' }
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub get_vm_name {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
foreach my $vm (@{$options{vms}}) {
|
||||
next if ($vm->{VmId} ne $options{vm_id});
|
||||
|
||||
foreach my $tag (@{$vm->{Tags}}) {
|
||||
return $tag->{Value} if ($tag->{Key} =~ /^$self->{option_results}->{vm_tag_name}$/i);
|
||||
}
|
||||
}
|
||||
|
||||
return $options{vm_id};
|
||||
}
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $volumes = $options{custom}->read_volumes();
|
||||
my $vms = $options{custom}->read_vms();
|
||||
|
||||
$self->{global} = { detected => 0, creating => 0, available => 0, 'in-use' => 0, updating => 0, deleting => 0, error => 0 };
|
||||
$self->{volumes} = {};
|
||||
|
||||
foreach my $volume (@$volumes) {
|
||||
next if (defined($self->{option_results}->{filter_id}) && $self->{option_results}->{filter_id} ne '' &&
|
||||
$volume->{VolumeId} !~ /$self->{option_results}->{filter_id}/);
|
||||
|
||||
$self->{volumes}->{ $volume->{VolumeId} } = {
|
||||
id => $volume->{VolumeId},
|
||||
status => {
|
||||
volumeId => $volume->{VolumeId},
|
||||
state => lc($volume->{State})
|
||||
},
|
||||
vms => {}
|
||||
};
|
||||
|
||||
$self->{global}->{ lc($volume->{State}) }++
|
||||
if (defined($self->{global}->{ lc($volume->{State}) }));
|
||||
$self->{global}->{detected}++;
|
||||
|
||||
foreach (@{$volume->{LinkedVolumes}}) {
|
||||
my $name = $self->get_vm_name(vms => $vms, vm_id => $_->{VmId});
|
||||
|
||||
$self->{volumes}->{ $volume->{VolumeId} }->{vms}->{ $_->{VmId} } = {
|
||||
vmName => $name,
|
||||
state => lc($_->{State})
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check volumes.
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--filter-id>
|
||||
|
||||
Filter volumes by id.
|
||||
|
||||
=item B<--vm-tag-name>
|
||||
|
||||
Virtual machine tags to used for the name (Default: 'name').
|
||||
|
||||
=item B<--unknown-volume-status>
|
||||
|
||||
Set unknown threshold for status.
|
||||
Can used special variables like: %{state}, %{volumeId}
|
||||
|
||||
=item B<--warning-volume-status>
|
||||
|
||||
Set warning threshold for status.
|
||||
Can used special variables like: %{state}, %{volumeId}
|
||||
|
||||
=item B<--critical-volume-status>
|
||||
|
||||
Set critical threshold for status.
|
||||
Can used special variables like: %{state}, %{volumeId}
|
||||
|
||||
=item B<--warning-*> B<--critical-*>
|
||||
|
||||
Thresholds.
|
||||
Can be: 'volumes-detected', 'volumes-creating', 'volumes-available',
|
||||
'volumes-in-use', 'volumes-updating', 'volumes-deleting', 'volumes-error'.
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
|
@ -0,0 +1,215 @@
|
|||
#
|
||||
# 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::outscale::mode::vpnconnections;
|
||||
|
||||
use base qw(centreon::plugins::templates::counter);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng);
|
||||
|
||||
sub vpn_long_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return sprintf(
|
||||
"checking vpn connection '%s'",
|
||||
$options{instance_value}->{name}
|
||||
);
|
||||
}
|
||||
|
||||
sub prefix_vpn_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return sprintf(
|
||||
"vpn connection '%s' ",
|
||||
$options{instance_value}->{name}
|
||||
);
|
||||
}
|
||||
|
||||
sub prefix_global_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return 'number of vpn connections ';
|
||||
}
|
||||
|
||||
sub set_counters {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{maps_counters_type} = [
|
||||
{ name => 'global', type => 0, cb_prefix_output => 'prefix_global_output' },
|
||||
{
|
||||
name => 'connections', type => 3, cb_prefix_output => 'prefix_vpn_output', cb_long_output => 'vpn_long_output', indent_long_output => ' ', message_multiple => 'All vpn connections are ok',
|
||||
group => [
|
||||
{ name => 'status', type => 0 }
|
||||
]
|
||||
}
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{global} = [
|
||||
{ label => 'vpn-connections-detected', display_ok => 0, nlabel => 'vpn_connections.detected.count', set => {
|
||||
key_values => [ { name => 'detected' } ],
|
||||
output_template => 'detected: %s',
|
||||
perfdatas => [
|
||||
{ template => '%s', min => 0 }
|
||||
]
|
||||
}
|
||||
},
|
||||
{ label => 'vpn-connections-available', display_ok => 0, nlabel => 'vpn_connections.available.count', set => {
|
||||
key_values => [ { name => 'available' } ],
|
||||
output_template => 'available: %s',
|
||||
perfdatas => [
|
||||
{ template => '%s', min => 0 }
|
||||
]
|
||||
}
|
||||
},
|
||||
{ label => 'vpn-connections-pending', display_ok => 0, nlabel => 'vpn_connections.pending.count', set => {
|
||||
key_values => [ { name => 'pending' } ],
|
||||
output_template => 'pending: %s',
|
||||
perfdatas => [
|
||||
{ template => '%s', min => 0 }
|
||||
]
|
||||
}
|
||||
},
|
||||
{ label => 'vpn-connections-deleting', display_ok => 0, nlabel => 'vpn_connections.deleting.count', set => {
|
||||
key_values => [ { name => 'deleting' } ],
|
||||
output_template => 'deleting: %s',
|
||||
perfdatas => [
|
||||
{ template => '%s', min => 0 }
|
||||
]
|
||||
}
|
||||
},
|
||||
{ label => 'vpn-connections-deleted', display_ok => 0, nlabel => 'vpn_connections.deleted.count', set => {
|
||||
key_values => [ { name => 'deleted' } ],
|
||||
output_template => 'deleted: %s',
|
||||
perfdatas => [
|
||||
{ template => '%s', min => 0 }
|
||||
]
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{status} = [
|
||||
{
|
||||
label => 'vpn-connection-status',
|
||||
type => 2,
|
||||
set => {
|
||||
key_values => [ { name => 'state' }, { name => 'vpnName' } ],
|
||||
output_template => 'state: %s',
|
||||
closure_custom_perfdata => sub { return 0; },
|
||||
closure_custom_threshold_check => \&catalog_status_threshold_ng
|
||||
}
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
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-name:s' => { name => 'filter_name' },
|
||||
'vpn-tag-name:s' => { name => 'vpn_tag_name', default => 'name' }
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub get_vpn_name {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
foreach my $tag (@{$options{tags}}) {
|
||||
return $tag->{Value} if ($tag->{Key} =~ /^$self->{option_results}->{vpn_tag_name}$/i);
|
||||
}
|
||||
|
||||
return $options{id};
|
||||
}
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $connections = $options{custom}->read_vpn_connections();
|
||||
|
||||
$self->{global} = { detected => 0, available => 0, pending => 0, deleting => 0, deleted => 0 };
|
||||
$self->{connections} = {};
|
||||
|
||||
foreach my $connection (@$connections) {
|
||||
my $name = $self->get_vpn_name(tags => $connection->{Tags}, id => $connection->{VpnConnectionId});
|
||||
|
||||
next if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' &&
|
||||
$name !~ /$self->{option_results}->{filter_name}/);
|
||||
|
||||
$self->{connections}->{$name} = {
|
||||
name => $name,
|
||||
status => {
|
||||
vpnName => $name,
|
||||
state => lc($connection->{State})
|
||||
}
|
||||
};
|
||||
|
||||
$self->{global}->{ lc($connection->{State}) }++
|
||||
if (defined($self->{global}->{ lc($connection->{State}) }));
|
||||
$self->{global}->{detected}++;
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check vpn connections.
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--filter-name>
|
||||
|
||||
Filter virtual connections by name.
|
||||
|
||||
=item B<--vpn-tag-name>
|
||||
|
||||
Vpn connection tag to be used for the name (Default: 'name').
|
||||
|
||||
=item B<--unknown-vpn-connection-status>
|
||||
|
||||
Set unknown threshold for status.
|
||||
Can used special variables like: %{state}, %{vpnName}
|
||||
|
||||
=item B<--warning-vpn-connection-status>
|
||||
|
||||
Set warning threshold for status.
|
||||
Can used special variables like: %{state}, %{vpnName}
|
||||
|
||||
=item B<--critical-vpn-connection-status>
|
||||
|
||||
Set critical threshold for status.
|
||||
Can used special variables like: %{state}, %{vpnName}
|
||||
|
||||
=item B<--warning-*> B<--critical-*>
|
||||
|
||||
Thresholds.
|
||||
Can be: 'vpn-connections-detected', 'vpn-connections-available', 'vpn-connections-pending',
|
||||
'vpn-connections-deleting', 'vpn-connections-deleted'.
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
|
@ -0,0 +1,73 @@
|
|||
#
|
||||
# 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::outscale::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->{modes} = {
|
||||
'account-consumptions' => 'cloud::outscale::mode::accountconsumptions',
|
||||
'client-gateways' => 'cloud::outscale::mode::clientgateways',
|
||||
'internet-services' => 'cloud::outscale::mode::internetservices',
|
||||
'list-client-gateways' => 'cloud::outscale::mode::listclientgateways',
|
||||
'list-internet-services' => 'cloud::outscale::mode::listinternetservices',
|
||||
'list-load-balancers' => 'cloud::outscale::mode::listloadbalancers',
|
||||
'list-nat-services' => 'cloud::outscale::mode::listnatservices',
|
||||
'list-nets' => 'cloud::outscale::mode::listnets',
|
||||
'list-quotas' => 'cloud::outscale::mode::listquotas',
|
||||
'list-route-tables' => 'cloud::outscale::mode::listroutetables',
|
||||
'list-subnets' => 'cloud::outscale::mode::listsubnets',
|
||||
'list-virtual-gateways' => 'cloud::outscale::mode::listvirtualgateways',
|
||||
'list-volumes' => 'cloud::outscale::mode::listvolumes',
|
||||
'list-vms' => 'cloud::outscale::mode::listvms',
|
||||
'list-vpn-connections' => 'cloud::outscale::mode::listvpnconnections',
|
||||
'load-balancers' => 'cloud::outscale::mode::loadbalancers',
|
||||
'nat-services' => 'cloud::outscale::mode::natservices',
|
||||
'nets' => 'cloud::outscale::mode::nets',
|
||||
'quotas' => 'cloud::outscale::mode::quotas',
|
||||
'route-tables' => 'cloud::outscale::mode::routetables',
|
||||
'subnets' => 'cloud::outscale::mode::subnets',
|
||||
'virtual-gateways' => 'cloud::outscale::mode::virtualgateways',
|
||||
'volumes' => 'cloud::outscale::mode::volumes',
|
||||
'vms' => 'cloud::outscale::mode::vms',
|
||||
'vpn-connections' => 'cloud::outscale::mode::vpnconnections'
|
||||
};
|
||||
|
||||
$self->{custom_modes}->{http} = 'cloud::outscale::custom::http';
|
||||
$self->{custom_modes}->{osccli} = 'cloud::outscale::custom::osccli';
|
||||
return $self;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 PLUGIN DESCRIPTION
|
||||
|
||||
Check Outscale.
|
||||
|
||||
=cut
|
Loading…
Reference in New Issue