From c900e87e98d3fa290801331f7cd6ba23ea840961 Mon Sep 17 00:00:00 2001 From: sduret Date: Fri, 11 Sep 2026 09:34:33 +0200 Subject: [PATCH 1/2] add --server option for health mode --- .../azure/database/sqldatabase/mode/health.pm | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/cloud/azure/database/sqldatabase/mode/health.pm b/src/cloud/azure/database/sqldatabase/mode/health.pm index 6cf1783866..8535d1f033 100644 --- a/src/cloud/azure/database/sqldatabase/mode/health.pm +++ b/src/cloud/azure/database/sqldatabase/mode/health.pm @@ -25,10 +25,33 @@ use base qw(cloud::azure::management::monitor::mode::health); use strict; use warnings; +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + + $options{options}->add_options(arguments => { + 'server:s' => { name => 'server' } + }); + + return $self; +} + sub check_options { my ($self, %options) = @_; $self->SUPER::check_options(%options); + my $resource = $self->{option_results}->{resource}; + my $server = $self->{option_results}->{server}; + if ($resource !~ /^\/subscriptions\/.*\/resourceGroups\/.*\/providers\/Microsoft\.Sql\/servers\/.*\/databases\/.*$/) { + if (!defined($server) || $server eq '') { + $self->{output}->add_option_msg(short_msg => 'Need to specify either --resource with --resource-group and --server option OR --resource .'); + $self->{output}->option_exit(); + } + + $self->{az_resource_type} = 'servers/' . $server . '/databases'; + } + $self->{az_resource_namespace} = 'Microsoft.Sql' if (!defined($self->{az_resource_namespace}) || $self->{az_resource_namespace} eq ''); $self->{az_resource_type} = 'servers/databases' if (!defined($self->{az_resource_type}) || $self->{az_resource_type} eq ''); } @@ -52,6 +75,10 @@ Set resource name or ID (required). Set resource group (required if resource's name is used). +=item B<--server> + +Set server name (required if resource's name is used). + =item B<--warning-status> Define the conditions to match for the status to be WARNING (default: ''). From 0ac006cfb6d554c840e4de362ad61bba8494bbdb Mon Sep 17 00:00:00 2001 From: thibaults-centreon Date: Fri, 16 Oct 2026 16:31:20 +0200 Subject: [PATCH 2/2] keep resource-type workaround working in health mode --- src/cloud/azure/database/sqldatabase/mode/health.pm | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/cloud/azure/database/sqldatabase/mode/health.pm b/src/cloud/azure/database/sqldatabase/mode/health.pm index 8535d1f033..568c81a773 100644 --- a/src/cloud/azure/database/sqldatabase/mode/health.pm +++ b/src/cloud/azure/database/sqldatabase/mode/health.pm @@ -1,5 +1,5 @@ # -# Copyright 2024 Centreon (http://www.centreon.com/) +# Copyright 2026-Present Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -14,7 +14,7 @@ # 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 +# See the License for the specific language governing permissions and # limitations under the License. # @@ -44,12 +44,12 @@ sub check_options { my $resource = $self->{option_results}->{resource}; my $server = $self->{option_results}->{server}; if ($resource !~ /^\/subscriptions\/.*\/resourceGroups\/.*\/providers\/Microsoft\.Sql\/servers\/.*\/databases\/.*$/) { - if (!defined($server) || $server eq '') { + if (defined($server) && $server ne '') { + $self->{az_resource_type} = 'servers/' . $server . '/databases'; + } elsif (!defined($self->{az_resource_type}) || $self->{az_resource_type} eq '') { $self->{output}->add_option_msg(short_msg => 'Need to specify either --resource with --resource-group and --server option OR --resource .'); $self->{output}->option_exit(); } - - $self->{az_resource_type} = 'servers/' . $server . '/databases'; } $self->{az_resource_namespace} = 'Microsoft.Sql' if (!defined($self->{az_resource_namespace}) || $self->{az_resource_namespace} eq '');