diff --git a/centreon-plugins/cloud/azure/database/mysql/mode/connections.pm b/centreon-plugins/cloud/azure/database/mysql/mode/connections.pm new file mode 100644 index 000000000..48d0e6a28 --- /dev/null +++ b/centreon-plugins/cloud/azure/database/mysql/mode/connections.pm @@ -0,0 +1,188 @@ +# +# Copyright 2021 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::mysql::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' => 'azmysql.connections.active.count', + 'unit' => '', + 'min' => '0' + }, + 'connections_failed' => { + 'output' => 'Failed Connections', + 'label' => 'connections-failed', + 'nlabel' => 'azmysql.connections.failed.count', + 'unit' => '', + 'min' => '0' + }, + 'aborted_connections' => { + 'output' => 'Aborted Connections', + 'label' => 'connections-aborted', + 'nlabel' => 'azmysql.connections.aborted.count', + 'unit' => '', + 'min' => '0' + }, + 'total_connections' => { + 'output' => 'Total Connections', + 'label' => 'connections-total', + 'nlabel' => 'azmysql.connections.total.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' }, + 'resource-type:s' => { name => 'resource_type' } + }); + + 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 with --resource-group option or --resource .'); + $self->{output}->option_exit(); + } + + if (!defined($self->{option_results}->{resource_type}) || $self->{option_results}->{resource_type} eq '') { + $self->{output}->add_option_msg(short_msg => 'Need to specify --resource-type option'); + $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\.DBforMySQL\/(.*)\/(.*)$/) { + $resource_group = $1; + $resource_type = $2; + $resource = $3; + } + + $self->{az_resource} = $resource; + $self->{az_resource_group} = $resource_group; + $self->{az_resource_type} = $resource_type; + $self->{az_resource_namespace} = 'Microsoft.DBforMySQL'; + $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' ], + 'flexibleServers' => [ 'active_connections', 'aborted_connections', 'total_connections' ] + }; + + 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 %{$self->{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 MySQL connections status. + +Example: + +Using resource name : + +perl centreon_plugins.pl --plugin=cloud::azure::database::mysql::plugin --mode=connections --custommode=api +--resource= --resource-group= --aggregation='total' +--warning-connections-active='1000' --critical-connections-active='2000' + +Using resource id : + +perl centreon_plugins.pl --plugin=cloud::azure::integration::servicebus::plugin --mode=connections --custommode=api +--resource='/subscriptions//resourceGroups//providers/Microsoft.DBforMySQL/servers/' +--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<--resource-type> + +Set resource type (Default: 'servers'). Can be 'servers', 'flexibleServers'. + +=item B<--warning-*> + +Warning threshold where '*' can be: +'connections-active', 'connections-failed', 'connections-aborted', +'connections-total'. + +=item B<--critical-*> + +Critical threshold where '*' can be: +'connections-active', 'connections-failed', 'connections-aborted', +'connections-total'. + +=back + +=cut diff --git a/centreon-plugins/cloud/azure/database/mysql/mode/cpu.pm b/centreon-plugins/cloud/azure/database/mysql/mode/cpu.pm new file mode 100644 index 000000000..943e41a4b --- /dev/null +++ b/centreon-plugins/cloud/azure/database/mysql/mode/cpu.pm @@ -0,0 +1,154 @@ +# +# Copyright 2021 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::mysql::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' => 'azmysql.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' }, + 'resource-type:s' => { name => 'resource_type' } + }); + + 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 with --resource-group option or --resource .'); + $self->{output}->option_exit(); + } + + if (!defined($self->{option_results}->{resource_type}) || $self->{option_results}->{resource_type} eq '') { + $self->{output}->add_option_msg(short_msg => 'Need to specify --resource-type option'); + $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\.DBforMySQL\/(.*)\/(.*)$/) { + $resource_group = $1; + $resource_type = $2; + $resource = $3; + } + + $self->{az_resource} = $resource; + $self->{az_resource_group} = $resource_group; + $self->{az_resource_type} = $resource_type; + $self->{az_resource_namespace} = 'Microsoft.DBforMySQL'; + $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 MySQL CPU usage. + +Example: + +Using resource name : + +perl centreon_plugins.pl --plugin=cloud::azure::database::mysql::plugin --mode=cpu --custommode=api +--resource= --resource-group= --aggregation='average' +--warning-cpu-usage='80' --critical-cpu-usage='90' + +Using resource id : + +perl centreon_plugins.pl --plugin=cloud::azure::integration::servicebus::plugin --mode=cpu --custommode=api +--resource='/subscriptions//resourceGroups//providers/Microsoft.DBforMySQL/servers/' +--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<--resource-type> + +Set resource type (Default: 'servers'). Can be 'servers', 'flexibleServers'. + +=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 diff --git a/centreon-plugins/cloud/azure/database/mysql/mode/discovery.pm b/centreon-plugins/cloud/azure/database/mysql/mode/discovery.pm new file mode 100644 index 000000000..e44579303 --- /dev/null +++ b/centreon-plugins/cloud/azure/database/mysql/mode/discovery.pm @@ -0,0 +1,144 @@ +# +# Copyright 2021 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::mysql::mode::discovery; + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; +use JSON::XS; + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + + $options{options}->add_options(arguments => { + 'namespace:s' => { name => 'namespace' }, + 'type:s' => { name => 'type' }, + 'resource-group:s' => { name => 'resource_group' }, + 'location:s' => { name => 'location' }, + 'prettify' => { name => 'prettify' }, + }); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::init(%options); + + $self->{namespace} = $self->{option_results}->{namespace}; + $self->{type} = $self->{option_results}->{type}; + $self->{location} = $self->{option_results}->{location}; + $self->{resource_group} = $self->{option_results}->{resource_group}; +} + +sub run { + my ($self, %options) = @_; + + my @disco_data; + my $disco_stats; + + $disco_stats->{start_time} = time(); + + my $resources = $options{custom}->azure_list_resources( + namespace => $self->{namespace}, + resource_type => $self->{type}, + location => $self->{location}, + resource_group => $self->{resource_group} + ); + + $disco_stats->{end_time} = time(); + $disco_stats->{duration} = $disco_stats->{end_time} - $disco_stats->{start_time}; + + foreach my $resource (@{$resources}) { + next if ($resource->{type} !~ /Microsoft\.DBforMySQL/); + $resource->{type} =~ s/Microsoft\.DBforMySQL\///; + my $resource_group = ''; + $resource_group = $resource->{resourceGroup} if (defined($resource->{resourceGroup})); + $resource_group = $1 if ($resource_group eq '' && defined($resource->{id}) && $resource->{id} =~ /resourceGroups\/(.*)\/providers/); + $resource->{resourceGroup} = $resource_group; + + foreach my $entry (keys %{$resource}) { + next if (ref($resource->{$entry}) ne "HASH"); + my @array; + foreach my $key (keys %{$resource->{$entry}}) { + push @array, { key => $key, value => $resource->{$entry}->{$key} }; + } + $resource->{$entry} = \@array; + } + push @disco_data, $resource; + } + + $disco_stats->{discovered_items} = @disco_data; + $disco_stats->{results} = \@disco_data; + + my $encoded_data; + eval { + if (defined($self->{option_results}->{prettify})) { + $encoded_data = JSON::XS->new->utf8->pretty->encode($disco_stats); + } else { + $encoded_data = JSON::XS->new->utf8->encode($disco_stats); + } + }; + if ($@) { + $encoded_data = '{"code":"encode_error","message":"Cannot encode discovered data into JSON format"}'; + } + + $self->{output}->output_add(short_msg => $encoded_data); + $self->{output}->display(nolabel => 1, force_ignore_perfdata => 1); + $self->{output}->exit(); +} + +1; + +__END__ + +=head1 MODE + +Resources discovery. + +=over 8 + +=item B<--namespace> + +Specify resources namespace. + +=item B<--type> + +Specify resources type. + +=item B<--resource-group> + +Specify resources resource group. + +=item B<--location> + +Specify resources location. + +=item B<--prettify> + +Prettify JSON output. + +=back + +=cut \ No newline at end of file diff --git a/centreon-plugins/cloud/azure/database/mysql/mode/ioconsumption.pm b/centreon-plugins/cloud/azure/database/mysql/mode/ioconsumption.pm new file mode 100644 index 000000000..0dd1fdc2f --- /dev/null +++ b/centreon-plugins/cloud/azure/database/mysql/mode/ioconsumption.pm @@ -0,0 +1,155 @@ +# +# Copyright 2021 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::mysql::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' => 'azmysql.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' }, + 'resource-type:s' => { name => 'resource_type' } + }); + + 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 with --resource-group option or --resource .'); + $self->{output}->option_exit(); + } + + if (!defined($self->{option_results}->{resource_type}) || $self->{option_results}->{resource_type} eq '') { + $self->{output}->add_option_msg(short_msg => 'Need to specify --resource-type option'); + $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\.DBforMySQL\/(.*)\/(.*)$/) { + $resource_group = $1; + $resource_type = $2; + $resource = $3; + } + + $self->{az_resource} = $resource; + $self->{az_resource_group} = $resource_group; + $self->{az_resource_type} = $resource_type; + $self->{az_resource_namespace} = 'Microsoft.DBforMySQL'; + $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 MySQL IO comsuption usage. + +Example: + +Using resource name : + +perl centreon_plugins.pl --plugin=cloud::azure::database::mysql::plugin --mode=io-consumption --custommode=api +--resource= --resource-group= --aggregation='maximum' +--warning-ioconsumption-usage='80' --critical-ioconsumption-usage='90' + +Using resource id : + +perl centreon_plugins.pl --plugin=cloud::azure::integration::servicebus::plugin --mode=io-consumption --custommode=api +--resource='/subscriptions//resourceGroups//providers/Microsoft.DBforMySQL/servers/' +--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<--resource-type> + +Set resource type (Default: 'servers'). Can be 'servers', 'flexibleServers'. + +=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 diff --git a/centreon-plugins/cloud/azure/database/mysql/mode/memory.pm b/centreon-plugins/cloud/azure/database/mysql/mode/memory.pm new file mode 100644 index 000000000..5e560505d --- /dev/null +++ b/centreon-plugins/cloud/azure/database/mysql/mode/memory.pm @@ -0,0 +1,155 @@ +# +# Copyright 2021 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::mysql::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' => 'azmysql.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' }, + 'resource-type:s' => { name => 'resource_type' } + }); + + 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 with --resource-group option or --resource .'); + $self->{output}->option_exit(); + } + + if (!defined($self->{option_results}->{resource_type}) || $self->{option_results}->{resource_type} eq '') { + $self->{output}->add_option_msg(short_msg => 'Need to specify --resource-type option'); + $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\.DBforMySQL\/(.*)\/(.*)$/) { + $resource_group = $1; + $resource_type = $2; + $resource = $3; + } + + $self->{az_resource} = $resource; + $self->{az_resource_group} = $resource_group; + $self->{az_resource_type} = $resource_type; + $self->{az_resource_namespace} = 'Microsoft.DBforMySQL'; + $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 MySQL memory usage. + +Example: + +Using resource name : + +perl centreon_plugins.pl --plugin=cloud::azure::database::mysql::plugin --mode=memory --custommode=api +--resource= --resource-group= --aggregation='average' +--warning-memory-usage='80' --critical-memory-usage='90' + +Using resource id : + +perl centreon_plugins.pl --plugin=cloud::azure::integration::servicebus::plugin --mode=memory --custommode=api +--resource='/subscriptions//resourceGroups//providers/Microsoft.DBforMySQL/servers/' +--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<--resource-type> + +Set resource type (Default: 'servers'). Can be 'servers', 'flexibleServers'. + +=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 diff --git a/centreon-plugins/cloud/azure/database/mysql/mode/queries.pm b/centreon-plugins/cloud/azure/database/mysql/mode/queries.pm new file mode 100644 index 000000000..65350c956 --- /dev/null +++ b/centreon-plugins/cloud/azure/database/mysql/mode/queries.pm @@ -0,0 +1,141 @@ +# +# Copyright 2021 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::mysql::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' => 'azmysql.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 with --resource-group option or --resource .'); + $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\.DBforMySQL\/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.DBforMySQL'; + $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 MySQL network usage. + +Example: + +Using resource name : + +perl centreon_plugins.pl --plugin=cloud::azure::database::mysql::plugin --mode=queries --custommode=api +--resource= --resource-group= --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//resourceGroups//providers/Microsoft.DBforMySQL/servers/' +--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 diff --git a/centreon-plugins/cloud/azure/database/mysql/mode/replication.pm b/centreon-plugins/cloud/azure/database/mysql/mode/replication.pm new file mode 100644 index 000000000..ea1c89602 --- /dev/null +++ b/centreon-plugins/cloud/azure/database/mysql/mode/replication.pm @@ -0,0 +1,172 @@ +# +# Copyright 2021 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::mysql::mode::replication; + +use base qw(cloud::azure::custom::mode); + +use strict; +use warnings; + +sub get_metrics_mapping { + my ($self, %options) = @_; + + my $metrics_mapping = { + 'replication_lag' => { + 'output' => 'Replication Lag In Seconds', + 'label' => 'replication-lag', + 'nlabel' => 'azmysql.replication.lag.seconds', + 'unit' => 's', + 'min' => '0' + }, + 'seconds_behind_master' => { + 'output' => 'Replication lag in seconds', + 'label' => 'replication-lag-count', + 'nlabel' => 'azmysql.replication.lag.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' }, + 'resource-type:s' => { name => 'resource_type' } + }); + + 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 with --resource-group option or --resource .'); + $self->{output}->option_exit(); + } + + if (!defined($self->{option_results}->{resource_type}) || $self->{option_results}->{resource_type} eq '') { + $self->{output}->add_option_msg(short_msg => 'Need to specify --resource-type option'); + $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\.DBforMySQL\/(.*)\/(.*)$/) { + $resource_group = $1; + $resource_type = $2; + $resource = $3; + } + + $self->{az_resource} = $resource; + $self->{az_resource_group} = $resource_group; + $self->{az_resource_type} = $resource_type; + $self->{az_resource_namespace} = 'Microsoft.DBforMySQL'; + $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' ], + 'flexibleServers' => [ 'replication_lag' ] + }; + + 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 %{$self->{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 MySQL replication status. + +Example: + +Using resource name : + +perl centreon_plugins.pl --plugin=cloud::azure::database::mysql::plugin --mode=connections --custommode=api +--resource= --resource-group= --aggregation='maximum' +--warning-replication-lag='1000' --critical-replication-lag='2000' + +Using resource id : + +perl centreon_plugins.pl --plugin=cloud::azure::integration::servicebus::plugin --mode=connections --custommode=api +--resource='/subscriptions//resourceGroups//providers/Microsoft.DBforMySQL/servers/' +--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<--resource-type> + +Set resource type (Default: 'servers'). Can be 'servers', 'flexibleServers'. + +=item B<--warning-*> + +Warning threshold where '*' can be: +'replication-lag', 'replication-lag-count'. + +=item B<--critical-*> + +Critical threshold where '*' can be: +'replication-lag', 'replication-lag-count'. + +=back + +=cut diff --git a/centreon-plugins/cloud/azure/database/mysql/mode/storage.pm b/centreon-plugins/cloud/azure/database/mysql/mode/storage.pm new file mode 100644 index 000000000..adf639d37 --- /dev/null +++ b/centreon-plugins/cloud/azure/database/mysql/mode/storage.pm @@ -0,0 +1,211 @@ +# +# Copyright 2021 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::mysql::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' => 'azmysql.storage.backup.usage.bytes', + 'unit' => 'B', + 'min' => '0' + }, + 'serverlog_storage_limit' => { + 'output' => 'Server Log storage limit', + 'label' => 'serverlog-limit', + 'nlabel' => 'azmysql.storage.serverlog.limit.bytes', + 'unit' => 'B', + 'min' => '0' + }, + 'serverlog_storage_percent' => { + 'output' => 'Server Log storage percent', + 'label' => 'serverlog-percent', + 'nlabel' => 'azmysql.storage.serverlog.usage.percentage', + 'unit' => '%', + 'min' => '0' + }, + 'serverlog_storage_usage' => { + 'output' => 'Server Log storage used', + 'label' => 'servelog-usage', + 'nlabel' => 'azmysql.storage.serverlog.usage.bytes', + 'unit' => 'B', + 'min' => '0' + }, + 'storage_limit' => { + 'output' => 'Storage Limit', + 'label' => 'storage-limit', + 'nlabel' => 'azmysql.storage.limit.bytes', + 'unit' => 'B', + 'min' => '0' + }, + 'storage_percent' => { + 'output' => 'Storage Percent', + 'label' => 'storage-percent', + 'nlabel' => 'azmysql.storage.usage.percentage', + 'unit' => '%', + 'min' => '0' + }, + 'storage_used' => { + 'output' => 'Storage Used', + 'label' => 'storage-used', + 'nlabel' => 'azmysql.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' }, + 'resource-type:s' => { name => 'resource_type' } + }); + + 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 with --resource-group option or --resource .'); + $self->{output}->option_exit(); + } + + if (!defined($self->{option_results}->{resource_type}) || $self->{option_results}->{resource_type} eq '') { + $self->{output}->add_option_msg(short_msg => 'Need to specify --resource-type option'); + $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\.DBforMySQL\/(.*)\/(.*)$/) { + $resource_group = $1; + $resource_type = $2; + $resource = $3; + } + + $self->{az_resource} = $resource; + $self->{az_resource_group} = $resource_group; + $self->{az_resource_type} = $resource_type; + $self->{az_resource_namespace} = 'Microsoft.DBforMySQL'; + $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' => [ 'backup_storage_used', 'serverlog_storage_limit', 'serverlog_storage_percent', + 'serverlog_storage_usage', 'storage_limit', 'storage_percent', 'storage_used' + ], + 'flexibleServers' => [ 'backup_storage_used', '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 %{$self->{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 MySQL storage usage. + +Example: + +Using resource name : + +perl centreon_plugins.pl --plugin=cloud::azure::database::mysql::plugin --mode=storage --custommode=api +--resource= --resource-group= --aggregation='maximum' +--warning-storage_used='1000' --critical-storage_used='2000' + +Using resource id : + +perl centreon_plugins.pl --plugin=cloud::azure::integration::servicebus::plugin --mode=storage --custommode=api +--resource='/subscriptions//resourceGroups//providers/Microsoft.DBforMySQL/servers/' +--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<--resource-type> + +Set resource type (Default: 'servers'). Can be 'servers', 'flexibleServers'. + +=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 diff --git a/centreon-plugins/cloud/azure/database/mysql/mode/traffic.pm b/centreon-plugins/cloud/azure/database/mysql/mode/traffic.pm new file mode 100644 index 000000000..f005da20c --- /dev/null +++ b/centreon-plugins/cloud/azure/database/mysql/mode/traffic.pm @@ -0,0 +1,161 @@ +# +# Copyright 2021 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::mysql::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' => 'azmysql.traffic.out.bytes', + 'unit' => 'B', + 'min' => '0', + }, + 'network_bytes_ingress' => { + 'output' => 'Network In', + 'label' => 'traffic-in', + 'nlabel' => 'azmysql.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' }, + 'resource-type:s' => { name => 'resource_type' } + }); + + 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 with --resource-group option or --resource .'); + $self->{output}->option_exit(); + } + + if (!defined($self->{option_results}->{resource_type}) || $self->{option_results}->{resource_type} eq '') { + $self->{output}->add_option_msg(short_msg => 'Need to specify --resource-type option'); + $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\.DBforMySQL\/(.*)\/(.*)$/) { + $resource_group = $1; + $resource_type = $2; + $resource = $3; + } + + $self->{az_resource} = $resource; + $self->{az_resource_group} = $resource_group; + $self->{az_resource_type} = $resource_type; + $self->{az_resource_namespace} = 'Microsoft.DBforMySQL'; + $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 MySQL network usage. + +Example: + +Using resource name : + +perl centreon_plugins.pl --plugin=cloud::azure::database::mysql::plugin --mode=traffic --custommode=api +--resource= --resource-group= --aggregation='average' +--warning-traffic-out='80' --critical-traffic-out='90' + +Using resource id : + +perl centreon_plugins.pl --plugin=cloud::azure::integration::servicebus::plugin --mode=traffic --custommode=api +--resource='/subscriptions//resourceGroups//providers/Microsoft.DBforMySQL/servers/' +--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<--resource-type> + +Set resource type (Default: 'servers'). Can be 'servers', 'flexibleServers'. + +=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 diff --git a/centreon-plugins/cloud/azure/database/mysql/plugin.pm b/centreon-plugins/cloud/azure/database/mysql/plugin.pm new file mode 100644 index 000000000..204fa695e --- /dev/null +++ b/centreon-plugins/cloud/azure/database/mysql/plugin.pm @@ -0,0 +1,68 @@ +# +# Copyright 2021 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::mysql::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::mysql::mode::connections', + 'cpu' => 'cloud::azure::database::mysql::mode::cpu', + 'discovery' => 'cloud::azure::database::mysql::mode::discovery', + 'io-consumption' => 'cloud::azure::database::mysql::mode::ioconsumption', + 'memory' => 'cloud::azure::database::mysql::mode::memory', + 'queries' => 'cloud::azure::database::mysql::mode::queries', + 'replication' => 'cloud::azure::database::mysql::mode::replication', + 'storage' => 'cloud::azure::database::mysql::mode::storage', + 'traffic' => 'cloud::azure::database::mysql::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 MySQL resources. + +=cut