mirror of
https://github.com/centreon/centreon-plugins.git
synced 2025-07-25 06:35:38 +02:00
(plugin) cloud::azure::database::mariadb - add new plugin (#3559)
* Added Azure MariaDB checks * Changed documentation and metric labels to MariaDB * Removed flexibleServers option and not working checks * + use latest discovery code formatting * + align output/metric with on-prem mariadb Co-authored-by: Johannes Engler <johannes.engler@de.clara.net> Co-authored-by: Simon Bomm <sbomm@centreon.com>
This commit is contained in:
parent
230f99a385
commit
972be8349f
@ -0,0 +1,161 @@
|
||||
#
|
||||
# Copyright 2022 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::azure::database::mariadb::mode::connections;
|
||||
|
||||
use base qw(cloud::azure::custom::mode);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub get_metrics_mapping {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $metrics_mapping = {
|
||||
'active_connections' => {
|
||||
'output' => 'Active Connections',
|
||||
'label' => 'connections-active',
|
||||
'nlabel' => 'azmariadb.connections.active.count',
|
||||
'unit' => '',
|
||||
'min' => '0'
|
||||
},
|
||||
'connections_failed' => {
|
||||
'output' => 'Failed Connections',
|
||||
'label' => 'connections-failed',
|
||||
'nlabel' => 'azmariadb.connections.failed.count',
|
||||
'unit' => '',
|
||||
'min' => '0'
|
||||
}
|
||||
};
|
||||
|
||||
return $metrics_mapping;
|
||||
}
|
||||
|
||||
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-metric:s' => { name => 'filter_metric' },
|
||||
'resource:s' => { name => 'resource' },
|
||||
'resource-group:s' => { name => 'resource_group' },
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::check_options(%options);
|
||||
|
||||
if (!defined($self->{option_results}->{resource}) || $self->{option_results}->{resource} eq '') {
|
||||
$self->{output}->add_option_msg(short_msg => 'Need to specify either --resource <name> with --resource-group option or --resource <id>.');
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
my $resource = $self->{option_results}->{resource};
|
||||
my $resource_group = defined($self->{option_results}->{resource_group}) ? $self->{option_results}->{resource_group} : '';
|
||||
my $resource_type = $self->{option_results}->{resource_type};
|
||||
if ($resource =~ /^\/subscriptions\/.*\/resourceGroups\/(.*)\/providers\/Microsoft\.DBforMariaDB\/(.*)\/(.*)$/) {
|
||||
$resource_group = $1;
|
||||
$resource_type = 'servers';
|
||||
$resource = $3;
|
||||
}
|
||||
|
||||
$self->{az_resource} = $resource;
|
||||
$self->{az_resource_group} = $resource_group;
|
||||
$self->{az_resource_type} = 'servers';
|
||||
$self->{az_resource_namespace} = 'Microsoft.DBforMariaDB';
|
||||
$self->{az_timeframe} = defined($self->{option_results}->{timeframe}) ? $self->{option_results}->{timeframe} : 900;
|
||||
$self->{az_interval} = defined($self->{option_results}->{interval}) ? $self->{option_results}->{interval} : 'PT5M';
|
||||
$self->{az_aggregations} = ['Total'];
|
||||
if (defined($self->{option_results}->{aggregation})) {
|
||||
$self->{az_aggregations} = [];
|
||||
foreach my $stat (@{$self->{option_results}->{aggregation}}) {
|
||||
if ($stat ne '') {
|
||||
push @{$self->{az_aggregations}}, ucfirst(lc($stat));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
my $resource_mapping = {
|
||||
'servers' => [ 'active_connections', 'connections_failed' ],
|
||||
};
|
||||
|
||||
my $metrics_mapping_transformed;
|
||||
foreach my $metric_type (@{$resource_mapping->{$resource_type}}) {
|
||||
$metrics_mapping_transformed->{$metric_type} = $self->{metrics_mapping}->{$metric_type};
|
||||
}
|
||||
|
||||
foreach my $metric (keys %{$metrics_mapping_transformed}) {
|
||||
next if (defined($self->{option_results}->{filter_metric}) && $self->{option_results}->{filter_metric} ne ''
|
||||
&& $metric !~ /$self->{option_results}->{filter_metric}/);
|
||||
push @{$self->{az_metrics}}, $metric;
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check Azure Database for MariaDB connections status.
|
||||
|
||||
Example:
|
||||
|
||||
Using resource name :
|
||||
|
||||
perl centreon_plugins.pl --plugin=cloud::azure::database::mariadb::plugin --mode=connections --custommode=api
|
||||
--resource=<db_id> --resource-group=<resourcegroup_id> --aggregation='total'
|
||||
--warning-connections-active='1000' --critical-connections-active='2000'
|
||||
|
||||
Using resource id :
|
||||
|
||||
perl centreon_plugins.pl --plugin=cloud::azure::database::mariadb::plugin --mode=connections --custommode=api
|
||||
--resource='/subscriptions/<subscription_id>/resourceGroups/<resourcegroup_id>/providers/Microsoft.DBforMariaDB/servers/<db_id>'
|
||||
--aggregation='total' --warning-connections-active='1000' --critical-connections-active='2000'
|
||||
|
||||
Default aggregation: 'total' / 'average', 'minimum' and 'maximum' are valid.
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--resource>
|
||||
|
||||
Set resource name or id (Required).
|
||||
|
||||
=item B<--resource-group>
|
||||
|
||||
Set resource group (Required if resource's name is used).
|
||||
|
||||
=item B<--warning-*>
|
||||
|
||||
Warning threshold where '*' can be:
|
||||
'connections-active', 'connections-failed'.
|
||||
|
||||
=item B<--critical-*>
|
||||
|
||||
Critical threshold where '*' can be:
|
||||
'connections-active', 'connections-failed'.
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
144
centreon-plugins/cloud/azure/database/mariadb/mode/cpu.pm
Normal file
144
centreon-plugins/cloud/azure/database/mariadb/mode/cpu.pm
Normal file
@ -0,0 +1,144 @@
|
||||
#
|
||||
# Copyright 2022 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::azure::database::mariadb::mode::cpu;
|
||||
|
||||
use base qw(cloud::azure::custom::mode);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub get_metrics_mapping {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $metrics_mapping = {
|
||||
'cpu_percent' => {
|
||||
'output' => 'CPU percent',
|
||||
'label' => 'cpu-usage',
|
||||
'nlabel' => 'azmariadb.cpu.utilization.percentage',
|
||||
'unit' => '%',
|
||||
'min' => '0',
|
||||
'max' => '100'
|
||||
}
|
||||
};
|
||||
|
||||
return $metrics_mapping;
|
||||
}
|
||||
|
||||
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-metric:s' => { name => 'filter_metric' },
|
||||
'resource:s' => { name => 'resource' },
|
||||
'resource-group:s' => { name => 'resource_group' },
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::check_options(%options);
|
||||
|
||||
if (!defined($self->{option_results}->{resource}) || $self->{option_results}->{resource} eq '') {
|
||||
$self->{output}->add_option_msg(short_msg => 'Need to specify either --resource <name> with --resource-group option or --resource <id>.');
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
my $resource = $self->{option_results}->{resource};
|
||||
my $resource_group = defined($self->{option_results}->{resource_group}) ? $self->{option_results}->{resource_group} : '';
|
||||
my $resource_type = $self->{option_results}->{resource_type};
|
||||
if ($resource =~ /^\/subscriptions\/.*\/resourceGroups\/(.*)\/providers\/Microsoft\.DBforMariaDB\/(.*)\/(.*)$/) {
|
||||
$resource_group = $1;
|
||||
$resource_type = 'servers';
|
||||
$resource = $3;
|
||||
}
|
||||
|
||||
$self->{az_resource} = $resource;
|
||||
$self->{az_resource_group} = $resource_group;
|
||||
$self->{az_resource_type} = $resource_type;
|
||||
$self->{az_resource_namespace} = 'Microsoft.DBforMariaDB';
|
||||
$self->{az_timeframe} = defined($self->{option_results}->{timeframe}) ? $self->{option_results}->{timeframe} : 900;
|
||||
$self->{az_interval} = defined($self->{option_results}->{interval}) ? $self->{option_results}->{interval} : 'PT5M';
|
||||
$self->{az_aggregations} = ['Average'];
|
||||
if (defined($self->{option_results}->{aggregation})) {
|
||||
$self->{az_aggregations} = [];
|
||||
foreach my $stat (@{$self->{option_results}->{aggregation}}) {
|
||||
if ($stat ne '') {
|
||||
push @{$self->{az_aggregations}}, ucfirst(lc($stat));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach my $metric (keys %{$self->{metrics_mapping}}) {
|
||||
next if (defined($self->{option_results}->{filter_metric}) && $self->{option_results}->{filter_metric} ne ''
|
||||
&& $metric !~ /$self->{option_results}->{filter_metric}/);
|
||||
push @{$self->{az_metrics}}, $metric;
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check Azure Database for MariaDB CPU usage.
|
||||
|
||||
Example:
|
||||
|
||||
Using resource name :
|
||||
|
||||
perl centreon_plugins.pl --plugin=cloud::azure::database::mariadb::plugin --mode=cpu --custommode=api
|
||||
--resource=<db_id> --resource-group=<resourcegroup_id> --aggregation='average'
|
||||
--warning-cpu-usage='80' --critical-cpu-usage='90'
|
||||
|
||||
Using resource id :
|
||||
|
||||
perl centreon_plugins.pl --plugin=cloud::azure::database::mariadb::plugin --mode=cpu --custommode=api
|
||||
--resource='/subscriptions/<subscription_id>/resourceGroups/<resourcegroup_id>/providers/Microsoft.DBforMariaDB/servers/<db_id>'
|
||||
--aggregation='average' --warning-cpu-usage='80' --critical-cpu-usage='90'
|
||||
|
||||
Default aggregation: 'average' / 'total', 'minimum' and 'maximum' are valid.
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--resource>
|
||||
|
||||
Set resource name or id (Required).
|
||||
|
||||
=item B<--resource-group>
|
||||
|
||||
Set resource group (Required if resource's name is used).
|
||||
|
||||
=item B<--warning-cpu-usage>
|
||||
|
||||
Set warning threshold for CPU utilization percentage.
|
||||
|
||||
=item B<--critical-cpu-usage>
|
||||
|
||||
Set critical threshold for CPU utilization percentage.
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
@ -0,0 +1,56 @@
|
||||
#
|
||||
# Copyright 2022 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::azure::database::mariadb::mode::discovery;
|
||||
|
||||
use base qw(cloud::azure::management::monitor::mode::discovery);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::check_options(%options);
|
||||
|
||||
$self->{namespace} = 'Microsoft.DBforMariaDB';
|
||||
$self->{type} = 'servers';
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Azure MariaDB Resources discovery.
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--location>
|
||||
|
||||
Specify resources location.
|
||||
|
||||
=item B<--prettify>
|
||||
|
||||
Prettify JSON output.
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
@ -0,0 +1,145 @@
|
||||
#
|
||||
# Copyright 2022 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::azure::database::mariadb::mode::ioconsumption;
|
||||
|
||||
use base qw(cloud::azure::custom::mode);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub get_metrics_mapping {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $metrics_mapping = {
|
||||
'io_consumption_percent' => {
|
||||
'output' => 'IO Percent',
|
||||
'label' => 'ioconsumption-usage',
|
||||
'nlabel' => 'azmariadb.ioconsumption.usage.percentage',
|
||||
'unit' => '%',
|
||||
'min' => '0',
|
||||
'max' => '100'
|
||||
}
|
||||
};
|
||||
|
||||
return $metrics_mapping;
|
||||
}
|
||||
|
||||
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-metric:s' => { name => 'filter_metric' },
|
||||
'resource:s' => { name => 'resource' },
|
||||
'resource-group:s' => { name => 'resource_group' },
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::check_options(%options);
|
||||
|
||||
if (!defined($self->{option_results}->{resource}) || $self->{option_results}->{resource} eq '') {
|
||||
$self->{output}->add_option_msg(short_msg => 'Need to specify either --resource <name> with --resource-group option or --resource <id>.');
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
my $resource = $self->{option_results}->{resource};
|
||||
my $resource_group = defined($self->{option_results}->{resource_group}) ? $self->{option_results}->{resource_group} : '';
|
||||
my $resource_type = $self->{option_results}->{resource_type};
|
||||
if ($resource =~ /^\/subscriptions\/.*\/resourceGroups\/(.*)\/providers\/Microsoft\.DBforMariaDB\/(.*)\/(.*)$/) {
|
||||
$resource_group = $1;
|
||||
$resource_type = 'servers';
|
||||
$resource = $3;
|
||||
}
|
||||
|
||||
$self->{az_resource} = $resource;
|
||||
$self->{az_resource_group} = $resource_group;
|
||||
$self->{az_resource_type} = $resource_type;
|
||||
$self->{az_resource_namespace} = 'Microsoft.DBforMariaDB';
|
||||
$self->{az_timeframe} = defined($self->{option_results}->{timeframe}) ? $self->{option_results}->{timeframe} : 900;
|
||||
$self->{az_interval} = defined($self->{option_results}->{interval}) ? $self->{option_results}->{interval} : 'PT5M';
|
||||
$self->{az_aggregations} = ['Maximum'];
|
||||
if (defined($self->{option_results}->{aggregation})) {
|
||||
$self->{az_aggregations} = [];
|
||||
foreach my $stat (@{$self->{option_results}->{aggregation}}) {
|
||||
if ($stat ne '') {
|
||||
push @{$self->{az_aggregations}}, ucfirst(lc($stat));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach my $metric (keys %{$self->{metrics_mapping}}) {
|
||||
next if (defined($self->{option_results}->{filter_metric}) && $self->{option_results}->{filter_metric} ne ''
|
||||
&& $metric !~ /$self->{option_results}->{filter_metric}/);
|
||||
push @{$self->{az_metrics}}, $metric;
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check Azure Database for MariaDB IO comsuption usage.
|
||||
|
||||
Example:
|
||||
|
||||
Using resource name :
|
||||
|
||||
perl centreon_plugins.pl --plugin=cloud::azure::database::mariadb::plugin --mode=io-consumption --custommode=api
|
||||
--resource=<db_id> --resource-group=<resourcegroup_id> --aggregation='maximum'
|
||||
--warning-ioconsumption-usage='80' --critical-ioconsumption-usage='90'
|
||||
|
||||
Using resource id :
|
||||
|
||||
perl centreon_plugins.pl --plugin=cloud::azure::database::mariadb::plugin --mode=io-consumption --custommode=api
|
||||
--resource='/subscriptions/<subscription_id>/resourceGroups/<resourcegroup_id>/providers/Microsoft.DBforMariaDB/servers/<db_id>'
|
||||
--aggregation='maximum' --warning-ioconsumption-usage='80' --critical-ioconsumption-usage='90'
|
||||
|
||||
Default aggregation: 'average' / 'total', 'minimum' and 'maximum' are valid.
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--resource>
|
||||
|
||||
Set resource name or id (Required).
|
||||
|
||||
=item B<--resource-group>
|
||||
|
||||
Set resource group (Required if resource's name is used).
|
||||
|
||||
=item B<--warning-ioconsumption-usage>
|
||||
|
||||
Set warning threshold for IO comsuption usage.
|
||||
|
||||
|
||||
=item B<--critical-ioconsumption-usage>
|
||||
|
||||
Set critical threshold for IO comsuption usage.
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
145
centreon-plugins/cloud/azure/database/mariadb/mode/memory.pm
Normal file
145
centreon-plugins/cloud/azure/database/mariadb/mode/memory.pm
Normal file
@ -0,0 +1,145 @@
|
||||
#
|
||||
# Copyright 2022 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::azure::database::mariadb::mode::memory;
|
||||
|
||||
use base qw(cloud::azure::custom::mode);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub get_metrics_mapping {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $metrics_mapping = {
|
||||
'memory_percent' => {
|
||||
'output' => 'Memory percent',
|
||||
'label' => 'memory-usage',
|
||||
'nlabel' => 'azmariadb.memory.usage.percentage',
|
||||
'unit' => '%',
|
||||
'min' => '0',
|
||||
'max' => '100'
|
||||
}
|
||||
};
|
||||
|
||||
return $metrics_mapping;
|
||||
}
|
||||
|
||||
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-metric:s' => { name => 'filter_metric' },
|
||||
'resource:s' => { name => 'resource' },
|
||||
'resource-group:s' => { name => 'resource_group' },
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::check_options(%options);
|
||||
|
||||
if (!defined($self->{option_results}->{resource}) || $self->{option_results}->{resource} eq '') {
|
||||
$self->{output}->add_option_msg(short_msg => 'Need to specify either --resource <name> with --resource-group option or --resource <id>.');
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
my $resource = $self->{option_results}->{resource};
|
||||
my $resource_group = defined($self->{option_results}->{resource_group}) ? $self->{option_results}->{resource_group} : '';
|
||||
my $resource_type = $self->{option_results}->{resource_type};
|
||||
if ($resource =~ /^\/subscriptions\/.*\/resourceGroups\/(.*)\/providers\/Microsoft\.DBforMariaDB\/(.*)\/(.*)$/) {
|
||||
$resource_group = $1;
|
||||
$resource_type = 'servers';
|
||||
$resource = $3;
|
||||
}
|
||||
|
||||
$self->{az_resource} = $resource;
|
||||
$self->{az_resource_group} = $resource_group;
|
||||
$self->{az_resource_type} = $resource_type;
|
||||
$self->{az_resource_namespace} = 'Microsoft.DBforMariaDB';
|
||||
$self->{az_timeframe} = defined($self->{option_results}->{timeframe}) ? $self->{option_results}->{timeframe} : 900;
|
||||
$self->{az_interval} = defined($self->{option_results}->{interval}) ? $self->{option_results}->{interval} : 'PT5M';
|
||||
$self->{az_aggregations} = ['Average'];
|
||||
if (defined($self->{option_results}->{aggregation})) {
|
||||
$self->{az_aggregations} = [];
|
||||
foreach my $stat (@{$self->{option_results}->{aggregation}}) {
|
||||
if ($stat ne '') {
|
||||
push @{$self->{az_aggregations}}, ucfirst(lc($stat));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach my $metric (keys %{$self->{metrics_mapping}}) {
|
||||
next if (defined($self->{option_results}->{filter_metric}) && $self->{option_results}->{filter_metric} ne ''
|
||||
&& $metric !~ /$self->{option_results}->{filter_metric}/);
|
||||
push @{$self->{az_metrics}}, $metric;
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check Azure Database for MariaDB memory usage.
|
||||
|
||||
Example:
|
||||
|
||||
Using resource name :
|
||||
|
||||
perl centreon_plugins.pl --plugin=cloud::azure::database::mariadb::plugin --mode=memory --custommode=api
|
||||
--resource=<db_id> --resource-group=<resourcegroup_id> --aggregation='average'
|
||||
--warning-memory-usage='80' --critical-memory-usage='90'
|
||||
|
||||
Using resource id :
|
||||
|
||||
perl centreon_plugins.pl --plugin=cloud::azure::database::mariadb::plugin --mode=memory --custommode=api
|
||||
--resource='/subscriptions/<subscription_id>/resourceGroups/<resourcegroup_id>/providers/Microsoft.DBforMariaDB/servers/<db_id>'
|
||||
--aggregation='average' --warning-memory-usage='80' --critical-memory-usage='90'
|
||||
|
||||
Default aggregation: 'average' / 'total', 'minimum' and 'maximum' are valid.
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--resource>
|
||||
|
||||
Set resource name or id (Required).
|
||||
|
||||
=item B<--resource-group>
|
||||
|
||||
Set resource group (Required if resource's name is used).
|
||||
|
||||
=item B<--warning-memory-usage>
|
||||
|
||||
Set warning threshold for memory utilization percentage.
|
||||
|
||||
|
||||
=item B<--critical-memory-usage>
|
||||
|
||||
Set critical threshold for memory utilization percentage.
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
141
centreon-plugins/cloud/azure/database/mariadb/mode/queries.pm
Normal file
141
centreon-plugins/cloud/azure/database/mariadb/mode/queries.pm
Normal file
@ -0,0 +1,141 @@
|
||||
#
|
||||
# Copyright 2022 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::azure::database::mariadb::mode::queries;
|
||||
|
||||
use base qw(cloud::azure::custom::mode);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub get_metrics_mapping {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $metrics_mapping = {
|
||||
'queries' => {
|
||||
'output' => 'Queries',
|
||||
'label' => 'queries',
|
||||
'nlabel' => 'azmariadb.queries.count',
|
||||
'unit' => '',
|
||||
'min' => '0',
|
||||
}
|
||||
};
|
||||
|
||||
return $metrics_mapping;
|
||||
}
|
||||
|
||||
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-metric:s' => { name => 'filter_metric' },
|
||||
'resource:s' => { name => 'resource' },
|
||||
'resource-group:s' => { name => 'resource_group' },
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::check_options(%options);
|
||||
|
||||
if (!defined($self->{option_results}->{resource}) || $self->{option_results}->{resource} eq '') {
|
||||
$self->{output}->add_option_msg(short_msg => 'Need to specify either --resource <name> with --resource-group option or --resource <id>.');
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
my $resource = $self->{option_results}->{resource};
|
||||
my $resource_group = defined($self->{option_results}->{resource_group}) ? $self->{option_results}->{resource_group} : '';
|
||||
my $resource_type = $self->{option_results}->{resource_type};
|
||||
if ($resource =~ /^\/subscriptions\/.*\/resourceGroups\/(.*)\/providers\/Microsoft\.DBforMariaDB\/flexibleServers\/(.*)$/) {
|
||||
$resource_group = $1;
|
||||
$resource = $2;
|
||||
}
|
||||
|
||||
$self->{az_resource} = $resource;
|
||||
$self->{az_resource_group} = $resource_group;
|
||||
$self->{az_resource_type} = 'flexibleServers';
|
||||
$self->{az_resource_namespace} = 'Microsoft.DBforMariaDB';
|
||||
$self->{az_timeframe} = defined($self->{option_results}->{timeframe}) ? $self->{option_results}->{timeframe} : 900;
|
||||
$self->{az_interval} = defined($self->{option_results}->{interval}) ? $self->{option_results}->{interval} : 'PT5M';
|
||||
$self->{az_aggregations} = ['Total'];
|
||||
if (defined($self->{option_results}->{aggregation})) {
|
||||
$self->{az_aggregations} = [];
|
||||
foreach my $stat (@{$self->{option_results}->{aggregation}}) {
|
||||
if ($stat ne '') {
|
||||
push @{$self->{az_aggregations}}, ucfirst(lc($stat));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach my $metric (keys %{$self->{metrics_mapping}}) {
|
||||
next if (defined($self->{option_results}->{filter_metric}) && $self->{option_results}->{filter_metric} ne ''
|
||||
&& $metric !~ /$self->{option_results}->{filter_metric}/);
|
||||
push @{$self->{az_metrics}}, $metric;
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check Azure Database for MariaDB network usage.
|
||||
|
||||
Example:
|
||||
|
||||
Using resource name :
|
||||
|
||||
perl centreon_plugins.pl --plugin=cloud::azure::database::mariadb::plugin --mode=queries --custommode=api
|
||||
--resource=<db_id> --resource-group=<resourcegroup_id> --aggregation='total'
|
||||
--warning-queries='80' --critical-queries='90'
|
||||
|
||||
Using resource id :
|
||||
|
||||
perl centreon_plugins.pl --plugin=cloud::azure::integration::servicebus::plugin --mode=queries --custommode=api
|
||||
--resource='/subscriptions/<subscription_id>/resourceGroups/<resourcegroup_id>/providers/Microsoft.DBforMariaDB/servers/<db_id>'
|
||||
--aggregation='total' --warning-queries='80' --critical-queries='90'
|
||||
|
||||
Default aggregation: 'total' / 'average', 'minimum' and 'maximum' are valid.
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--resource>
|
||||
|
||||
Set resource name or id (Required).
|
||||
|
||||
=item B<--resource-group>
|
||||
|
||||
Set resource group (Required if resource's name is used).
|
||||
|
||||
=item B<--warning-queries>
|
||||
|
||||
Set warning threshold for queries count.
|
||||
|
||||
=item B<--critical-queries>
|
||||
|
||||
Set critical threshold for queries count.
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
@ -0,0 +1,154 @@
|
||||
#
|
||||
# Copyright 2022 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::azure::database::mariadb::mode::replication;
|
||||
|
||||
use base qw(cloud::azure::custom::mode);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub get_metrics_mapping {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $metrics_mapping = {
|
||||
'seconds_behind_master' => {
|
||||
'output' => 'Seconds behind master',
|
||||
'label' => 'slave-latency-seconds',
|
||||
'nlabel' => 'azmariadb.slave.latency.seconds',
|
||||
'unit' => '',
|
||||
'min' => '0'
|
||||
}
|
||||
};
|
||||
|
||||
return $metrics_mapping;
|
||||
}
|
||||
|
||||
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-metric:s' => { name => 'filter_metric' },
|
||||
'resource:s' => { name => 'resource' },
|
||||
'resource-group:s' => { name => 'resource_group' },
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::check_options(%options);
|
||||
|
||||
if (!defined($self->{option_results}->{resource}) || $self->{option_results}->{resource} eq '') {
|
||||
$self->{output}->add_option_msg(short_msg => 'Need to specify either --resource <name> with --resource-group option or --resource <id>.');
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
my $resource = $self->{option_results}->{resource};
|
||||
my $resource_group = defined($self->{option_results}->{resource_group}) ? $self->{option_results}->{resource_group} : '';
|
||||
my $resource_type = $self->{option_results}->{resource_type};
|
||||
if ($resource =~ /^\/subscriptions\/.*\/resourceGroups\/(.*)\/providers\/Microsoft\.DBforMariaDB\/(.*)\/(.*)$/) {
|
||||
$resource_group = $1;
|
||||
$resource_type = 'servers';
|
||||
$resource = $3;
|
||||
}
|
||||
|
||||
$self->{az_resource} = $resource;
|
||||
$self->{az_resource_group} = $resource_group;
|
||||
$self->{az_resource_type} = $resource_type;
|
||||
$self->{az_resource_namespace} = 'Microsoft.DBforMariaDB';
|
||||
$self->{az_timeframe} = defined($self->{option_results}->{timeframe}) ? $self->{option_results}->{timeframe} : 900;
|
||||
$self->{az_interval} = defined($self->{option_results}->{interval}) ? $self->{option_results}->{interval} : 'PT5M';
|
||||
$self->{az_aggregations} = ['Maximum'];
|
||||
if (defined($self->{option_results}->{aggregation})) {
|
||||
$self->{az_aggregations} = [];
|
||||
foreach my $stat (@{$self->{option_results}->{aggregation}}) {
|
||||
if ($stat ne '') {
|
||||
push @{$self->{az_aggregations}}, ucfirst(lc($stat));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
my $resource_mapping = {
|
||||
'servers' => [ 'seconds_behind_master' ],
|
||||
};
|
||||
|
||||
my $metrics_mapping_transformed;
|
||||
foreach my $metric_type (@{$resource_mapping->{$resource_type}}) {
|
||||
$metrics_mapping_transformed->{$metric_type} = $self->{metrics_mapping}->{$metric_type};
|
||||
}
|
||||
|
||||
foreach my $metric (keys %{$metrics_mapping_transformed}) {
|
||||
next if (defined($self->{option_results}->{filter_metric}) && $self->{option_results}->{filter_metric} ne ''
|
||||
&& $metric !~ /$self->{option_results}->{filter_metric}/);
|
||||
push @{$self->{az_metrics}}, $metric;
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check Azure Database for MariaDB replication status.
|
||||
|
||||
Example:
|
||||
|
||||
Using resource name :
|
||||
|
||||
perl centreon_plugins.pl --plugin=cloud::azure::database::mariadb::plugin --mode=connections --custommode=api
|
||||
--resource=<db_id> --resource-group=<resourcegroup_id> --aggregation='maximum'
|
||||
--warning-replication-lag='1000' --critical-replication-lag='2000'
|
||||
|
||||
Using resource id :
|
||||
|
||||
perl centreon_plugins.pl --plugin=cloud::azure::database::mariadb::plugin --mode=connections --custommode=api
|
||||
--resource='/subscriptions/<subscription_id>/resourceGroups/<resourcegroup_id>/providers/Microsoft.DBforMariaDB/servers/<db_id>'
|
||||
--aggregation='maximum' --warning-replication-lag='1000' --critical-replication-lag='2000'
|
||||
|
||||
Default aggregation: 'maximum' / 'average', 'minimum' and 'total' are valid.
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--resource>
|
||||
|
||||
Set resource name or id (Required).
|
||||
|
||||
=item B<--resource-group>
|
||||
|
||||
Set resource group (Required if resource's name is used).
|
||||
|
||||
=item B<--warning-*>
|
||||
|
||||
Warning threshold where '*' can be:
|
||||
'replication-lag-count'.
|
||||
|
||||
=item B<--critical-*>
|
||||
|
||||
Critical threshold where '*' can be:
|
||||
'replication-lag-count'.
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
200
centreon-plugins/cloud/azure/database/mariadb/mode/storage.pm
Normal file
200
centreon-plugins/cloud/azure/database/mariadb/mode/storage.pm
Normal file
@ -0,0 +1,200 @@
|
||||
#
|
||||
# Copyright 2022 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::azure::database::mariadb::mode::storage;
|
||||
|
||||
use base qw(cloud::azure::custom::mode);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub get_metrics_mapping {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $metrics_mapping = {
|
||||
'backup_storage_used' => {
|
||||
'output' => 'Backup Storage used',
|
||||
'label' => 'storage-backup',
|
||||
'nlabel' => 'azmariadb.storage.backup.usage.bytes',
|
||||
'unit' => 'B',
|
||||
'min' => '0'
|
||||
},
|
||||
'serverlog_storage_limit' => {
|
||||
'output' => 'Server Log storage limit',
|
||||
'label' => 'serverlog-limit',
|
||||
'nlabel' => 'azmariadb.storage.serverlog.limit.bytes',
|
||||
'unit' => 'B',
|
||||
'min' => '0'
|
||||
},
|
||||
'serverlog_storage_percent' => {
|
||||
'output' => 'Server Log storage percent',
|
||||
'label' => 'serverlog-percent',
|
||||
'nlabel' => 'azmariadb.storage.serverlog.usage.percentage',
|
||||
'unit' => '%',
|
||||
'min' => '0'
|
||||
},
|
||||
'serverlog_storage_usage' => {
|
||||
'output' => 'Server Log storage used',
|
||||
'label' => 'servelog-usage',
|
||||
'nlabel' => 'azmariadb.storage.serverlog.usage.bytes',
|
||||
'unit' => 'B',
|
||||
'min' => '0'
|
||||
},
|
||||
'storage_limit' => {
|
||||
'output' => 'Storage Limit',
|
||||
'label' => 'storage-limit',
|
||||
'nlabel' => 'azmariadb.storage.limit.bytes',
|
||||
'unit' => 'B',
|
||||
'min' => '0'
|
||||
},
|
||||
'storage_percent' => {
|
||||
'output' => 'Storage Percent',
|
||||
'label' => 'storage-percent',
|
||||
'nlabel' => 'azmariadb.storage.usage.percentage',
|
||||
'unit' => '%',
|
||||
'min' => '0'
|
||||
},
|
||||
'storage_used' => {
|
||||
'output' => 'Storage Used',
|
||||
'label' => 'storage-used',
|
||||
'nlabel' => 'azmariadb.storage.usage.bytes',
|
||||
'unit' => 'B',
|
||||
'min' => '0'
|
||||
}
|
||||
};
|
||||
|
||||
return $metrics_mapping;
|
||||
}
|
||||
|
||||
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-metric:s' => { name => 'filter_metric' },
|
||||
'resource:s' => { name => 'resource' },
|
||||
'resource-group:s' => { name => 'resource_group' },
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::check_options(%options);
|
||||
|
||||
if (!defined($self->{option_results}->{resource}) || $self->{option_results}->{resource} eq '') {
|
||||
$self->{output}->add_option_msg(short_msg => 'Need to specify either --resource <name> with --resource-group option or --resource <id>.');
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
my $resource = $self->{option_results}->{resource};
|
||||
my $resource_group = defined($self->{option_results}->{resource_group}) ? $self->{option_results}->{resource_group} : '';
|
||||
my $resource_type = $self->{option_results}->{resource_type};
|
||||
if ($resource =~ /^\/subscriptions\/.*\/resourceGroups\/(.*)\/providers\/Microsoft\.DBforMariaDB\/(.*)\/(.*)$/) {
|
||||
$resource_group = $1;
|
||||
$resource_type = 'servers';
|
||||
$resource = $3;
|
||||
}
|
||||
|
||||
$self->{az_resource} = $resource;
|
||||
$self->{az_resource_group} = $resource_group;
|
||||
$self->{az_resource_type} = $resource_type;
|
||||
$self->{az_resource_namespace} = 'Microsoft.DBforMariaDB';
|
||||
$self->{az_timeframe} = defined($self->{option_results}->{timeframe}) ? $self->{option_results}->{timeframe} : 900;
|
||||
$self->{az_interval} = defined($self->{option_results}->{interval}) ? $self->{option_results}->{interval} : 'PT15M';
|
||||
$self->{az_aggregations} = ['Maximum'];
|
||||
if (defined($self->{option_results}->{aggregation})) {
|
||||
$self->{az_aggregations} = [];
|
||||
foreach my $stat (@{$self->{option_results}->{aggregation}}) {
|
||||
if ($stat ne '') {
|
||||
push @{$self->{az_aggregations}}, ucfirst(lc($stat));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
my $resource_mapping = {
|
||||
'servers' => [ 'backup_storage_used', 'serverlog_storage_limit', 'serverlog_storage_percent',
|
||||
'serverlog_storage_usage', 'storage_limit', 'storage_percent', 'storage_used'
|
||||
],
|
||||
};
|
||||
|
||||
my $metrics_mapping_transformed;
|
||||
foreach my $metric_type (@{$resource_mapping->{$resource_type}}) {
|
||||
$metrics_mapping_transformed->{$metric_type} = $self->{metrics_mapping}->{$metric_type};
|
||||
}
|
||||
|
||||
foreach my $metric (keys %{$metrics_mapping_transformed}) {
|
||||
next if (defined($self->{option_results}->{filter_metric}) && $self->{option_results}->{filter_metric} ne ''
|
||||
&& $metric !~ /$self->{option_results}->{filter_metric}/);
|
||||
push @{$self->{az_metrics}}, $metric;
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check Azure Database for MariaDB storage usage.
|
||||
|
||||
Example:
|
||||
|
||||
Using resource name :
|
||||
|
||||
perl centreon_plugins.pl --plugin=cloud::azure::database::mariadb::plugin --mode=storage --custommode=api
|
||||
--resource=<db_id> --resource-group=<resourcegroup_id> --aggregation='maximum'
|
||||
--warning-storage-used='1000' --critical-storage-used='2000'
|
||||
|
||||
Using resource id :
|
||||
|
||||
perl centreon-plugins.pl --plugin=cloud::azure::database::mariadb::plugin --mode=storage --custommode=api
|
||||
--resource='/subscriptions/<subscription-id>/resourceGroups/<resourcegroup-id>/providers/Microsoft.DBforMariaDB/servers/<db-id>'
|
||||
--aggregation='maximum' --warning-storage-used='1000' --critical-storage-used='2000'
|
||||
|
||||
Default aggregation: 'maximum' / 'average', 'minimum' and 'total' are valid.
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--resource>
|
||||
|
||||
Set resource name or id (Required).
|
||||
|
||||
=item B<--resource-group>
|
||||
|
||||
Set resource group (Required if resource's name is used).
|
||||
|
||||
=item B<--warning-*>
|
||||
|
||||
Warning threshold where '*' can be:
|
||||
'storage-backup', 'serverlog-limit', 'serverlog-percent', 'servelog-usage',
|
||||
'storage-limit', 'storage-percent', 'storage-used'.
|
||||
|
||||
=item B<--critical-*>
|
||||
|
||||
Critical threshold where '*' can be:
|
||||
'storage-backup', 'serverlog-limit', 'serverlog-percent', 'servelog-usage',
|
||||
'storage-limit', 'storage-percent', 'storage-used'.
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
151
centreon-plugins/cloud/azure/database/mariadb/mode/traffic.pm
Normal file
151
centreon-plugins/cloud/azure/database/mariadb/mode/traffic.pm
Normal file
@ -0,0 +1,151 @@
|
||||
#
|
||||
# Copyright 2022 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::azure::database::mariadb::mode::traffic;
|
||||
|
||||
use base qw(cloud::azure::custom::mode);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub get_metrics_mapping {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $metrics_mapping = {
|
||||
'network_bytes_egress' => {
|
||||
'output' => 'Network Out',
|
||||
'label' => 'traffic-out',
|
||||
'nlabel' => 'azmariadb.traffic.out.bytes',
|
||||
'unit' => 'B',
|
||||
'min' => '0',
|
||||
},
|
||||
'network_bytes_ingress' => {
|
||||
'output' => 'Network In',
|
||||
'label' => 'traffic-in',
|
||||
'nlabel' => 'azmariadb.traffic.in.bytes',
|
||||
'unit' => 'B',
|
||||
'min' => '0',
|
||||
}
|
||||
};
|
||||
|
||||
return $metrics_mapping;
|
||||
}
|
||||
|
||||
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-metric:s' => { name => 'filter_metric' },
|
||||
'resource:s' => { name => 'resource' },
|
||||
'resource-group:s' => { name => 'resource_group' },
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::check_options(%options);
|
||||
|
||||
if (!defined($self->{option_results}->{resource}) || $self->{option_results}->{resource} eq '') {
|
||||
$self->{output}->add_option_msg(short_msg => 'Need to specify either --resource <name> with --resource-group option or --resource <id>.');
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
my $resource = $self->{option_results}->{resource};
|
||||
my $resource_group = defined($self->{option_results}->{resource_group}) ? $self->{option_results}->{resource_group} : '';
|
||||
my $resource_type = $self->{option_results}->{resource_type};
|
||||
if ($resource =~ /^\/subscriptions\/.*\/resourceGroups\/(.*)\/providers\/Microsoft\.DBforMariaDB\/(.*)\/(.*)$/) {
|
||||
$resource_group = $1;
|
||||
$resource_type = 'servers';
|
||||
$resource = $3;
|
||||
}
|
||||
|
||||
$self->{az_resource} = $resource;
|
||||
$self->{az_resource_group} = $resource_group;
|
||||
$self->{az_resource_type} = $resource_type;
|
||||
$self->{az_resource_namespace} = 'Microsoft.DBforMariaDB';
|
||||
$self->{az_timeframe} = defined($self->{option_results}->{timeframe}) ? $self->{option_results}->{timeframe} : 900;
|
||||
$self->{az_interval} = defined($self->{option_results}->{interval}) ? $self->{option_results}->{interval} : 'PT5M';
|
||||
$self->{az_aggregations} = ['Average'];
|
||||
if (defined($self->{option_results}->{aggregation})) {
|
||||
$self->{az_aggregations} = [];
|
||||
foreach my $stat (@{$self->{option_results}->{aggregation}}) {
|
||||
if ($stat ne '') {
|
||||
push @{$self->{az_aggregations}}, ucfirst(lc($stat));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach my $metric (keys %{$self->{metrics_mapping}}) {
|
||||
next if (defined($self->{option_results}->{filter_metric}) && $self->{option_results}->{filter_metric} ne ''
|
||||
&& $metric !~ /$self->{option_results}->{filter_metric}/);
|
||||
push @{$self->{az_metrics}}, $metric;
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check Azure Database for MariaDB network usage.
|
||||
|
||||
Example:
|
||||
|
||||
Using resource name :
|
||||
|
||||
perl centreon_plugins.pl --plugin=cloud::azure::database::mariadb::plugin --mode=traffic --custommode=api
|
||||
--resource=<db_id> --resource-group=<resourcegroup_id> --aggregation='average'
|
||||
--warning-traffic-out='80' --critical-traffic-out='90'
|
||||
|
||||
Using resource id :
|
||||
|
||||
perl centreon_plugins.pl --plugin=cloud::azure::database::mariadb::plugin --mode=traffic --custommode=api
|
||||
--resource='/subscriptions/<subscription_id>/resourceGroups/<resourcegroup_id>/providers/Microsoft.DBforMariaDB/servers/<db_id>'
|
||||
--aggregation='average' --warning-traffic-out='80' --critical-traffic-out='90'
|
||||
|
||||
Default aggregation: 'average' / 'total', 'minimum' and 'maximum' are valid.
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--resource>
|
||||
|
||||
Set resource name or id (Required).
|
||||
|
||||
=item B<--resource-group>
|
||||
|
||||
Set resource group (Required if resource's name is used).
|
||||
|
||||
=item B<--warning-*>
|
||||
|
||||
Warning threshold where '*' can be: 'traffic-out', 'traffic-in'.
|
||||
|
||||
|
||||
=item B<--critical-*>
|
||||
|
||||
Critical threshold where '*' can be: 'traffic-out', 'traffic-in'.
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
67
centreon-plugins/cloud/azure/database/mariadb/plugin.pm
Normal file
67
centreon-plugins/cloud/azure/database/mariadb/plugin.pm
Normal file
@ -0,0 +1,67 @@
|
||||
#
|
||||
# Copyright 2022 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::azure::database::mariadb::plugin;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use base qw(centreon::plugins::script_custom);
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new( package => __PACKAGE__, %options );
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '0.1';
|
||||
$self->{modes} = {
|
||||
'connections' => 'cloud::azure::database::mariadb::mode::connections',
|
||||
'cpu' => 'cloud::azure::database::mariadb::mode::cpu',
|
||||
'discovery' => 'cloud::azure::database::mariadb::mode::discovery',
|
||||
'io-consumption' => 'cloud::azure::database::mariadb::mode::ioconsumption',
|
||||
'memory' => 'cloud::azure::database::mariadb::mode::memory',
|
||||
'replication' => 'cloud::azure::database::mariadb::mode::replication',
|
||||
'storage' => 'cloud::azure::database::mariadb::mode::storage',
|
||||
'traffic' => 'cloud::azure::database::mariadb::mode::traffic'
|
||||
};
|
||||
|
||||
$self->{custom_modes}->{azcli} = 'cloud::azure::custom::azcli';
|
||||
$self->{custom_modes}->{api} = 'cloud::azure::custom::api';
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub init {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{options}->add_options(arguments => {
|
||||
'api-version:s' => { name => 'api_version', default => '2018-01-01' },
|
||||
});
|
||||
|
||||
$self->SUPER::init(%options);
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 PLUGIN DESCRIPTION
|
||||
|
||||
Check Microsoft Azure Database for MariaDB resources.
|
||||
|
||||
=cut
|
Loading…
x
Reference in New Issue
Block a user