From 7f1ecee9fdd03aa2d471dedfa42dc2c186e0c5ed Mon Sep 17 00:00:00 2001 From: qgarnier Date: Mon, 10 Jul 2023 10:43:30 +0200 Subject: [PATCH] (plugin) cloud::azure::database::mariadb - fix undefined value (#4550) --- .../azure/database/mariadb/mode/connections.pm | 11 +++++------ src/cloud/azure/database/mariadb/mode/cpu.pm | 9 ++++----- .../azure/database/mariadb/mode/ioconsumption.pm | 9 ++++----- src/cloud/azure/database/mariadb/mode/memory.pm | 9 ++++----- .../azure/database/mariadb/mode/replication.pm | 11 +++++------ src/cloud/azure/database/mariadb/mode/storage.pm | 16 ++++++++-------- src/cloud/azure/database/mariadb/mode/traffic.pm | 13 ++++++------- 7 files changed, 36 insertions(+), 42 deletions(-) diff --git a/src/cloud/azure/database/mariadb/mode/connections.pm b/src/cloud/azure/database/mariadb/mode/connections.pm index fccaed4bb..66af4fbb8 100644 --- a/src/cloud/azure/database/mariadb/mode/connections.pm +++ b/src/cloud/azure/database/mariadb/mode/connections.pm @@ -56,7 +56,7 @@ sub new { $options{options}->add_options(arguments => { 'filter-metric:s' => { name => 'filter_metric' }, 'resource:s' => { name => 'resource' }, - 'resource-group:s' => { name => 'resource_group' }, + 'resource-group:s' => { name => 'resource_group' } }); return $self; @@ -73,11 +73,10 @@ sub check_options { 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\/(.*)\/(.*)$/) { + my $resource_type = 'servers'; + if ($resource =~ /^\/subscriptions\/.*\/resourceGroups\/(.*)\/providers\/Microsoft\.DBforMariaDB\/servers\/(.*)$/) { $resource_group = $1; - $resource_type = 'servers'; - $resource = $3; + $resource = $2; } $self->{az_resource} = $resource; @@ -97,7 +96,7 @@ sub check_options { } my $resource_mapping = { - 'servers' => [ 'active_connections', 'connections_failed' ], + 'servers' => [ 'active_connections', 'connections_failed' ] }; my $metrics_mapping_transformed; diff --git a/src/cloud/azure/database/mariadb/mode/cpu.pm b/src/cloud/azure/database/mariadb/mode/cpu.pm index 4317fba9d..809663b31 100644 --- a/src/cloud/azure/database/mariadb/mode/cpu.pm +++ b/src/cloud/azure/database/mariadb/mode/cpu.pm @@ -50,7 +50,7 @@ sub new { $options{options}->add_options(arguments => { 'filter-metric:s' => { name => 'filter_metric' }, 'resource:s' => { name => 'resource' }, - 'resource-group:s' => { name => 'resource_group' }, + 'resource-group:s' => { name => 'resource_group' } }); return $self; @@ -67,11 +67,10 @@ sub check_options { 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\/(.*)\/(.*)$/) { + my $resource_type = 'servers'; + if ($resource =~ /^\/subscriptions\/.*\/resourceGroups\/(.*)\/providers\/Microsoft\.DBforMariaDB\/servers\/(.*)$/) { $resource_group = $1; - $resource_type = 'servers'; - $resource = $3; + $resource = $2; } $self->{az_resource} = $resource; diff --git a/src/cloud/azure/database/mariadb/mode/ioconsumption.pm b/src/cloud/azure/database/mariadb/mode/ioconsumption.pm index 59a7bb947..c61001c3f 100644 --- a/src/cloud/azure/database/mariadb/mode/ioconsumption.pm +++ b/src/cloud/azure/database/mariadb/mode/ioconsumption.pm @@ -50,7 +50,7 @@ sub new { $options{options}->add_options(arguments => { 'filter-metric:s' => { name => 'filter_metric' }, 'resource:s' => { name => 'resource' }, - 'resource-group:s' => { name => 'resource_group' }, + 'resource-group:s' => { name => 'resource_group' } }); return $self; @@ -67,11 +67,10 @@ sub check_options { 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\/(.*)\/(.*)$/) { + my $resource_type = 'servers'; + if ($resource =~ /^\/subscriptions\/.*\/resourceGroups\/(.*)\/providers\/Microsoft\.DBforMariaDB\/servers\/(.*)$/) { $resource_group = $1; - $resource_type = 'servers'; - $resource = $3; + $resource = $2; } $self->{az_resource} = $resource; diff --git a/src/cloud/azure/database/mariadb/mode/memory.pm b/src/cloud/azure/database/mariadb/mode/memory.pm index 82c392866..aa63bd2bb 100644 --- a/src/cloud/azure/database/mariadb/mode/memory.pm +++ b/src/cloud/azure/database/mariadb/mode/memory.pm @@ -50,7 +50,7 @@ sub new { $options{options}->add_options(arguments => { 'filter-metric:s' => { name => 'filter_metric' }, 'resource:s' => { name => 'resource' }, - 'resource-group:s' => { name => 'resource_group' }, + 'resource-group:s' => { name => 'resource_group' } }); return $self; @@ -67,11 +67,10 @@ sub check_options { 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\/(.*)\/(.*)$/) { + my $resource_type = 'servers'; + if ($resource =~ /^\/subscriptions\/.*\/resourceGroups\/(.*)\/providers\/Microsoft\.DBforMariaDB\/servers\/(.*)$/) { $resource_group = $1; - $resource_type = 'servers'; - $resource = $3; + $resource = $2; } $self->{az_resource} = $resource; diff --git a/src/cloud/azure/database/mariadb/mode/replication.pm b/src/cloud/azure/database/mariadb/mode/replication.pm index 30abda265..247522afb 100644 --- a/src/cloud/azure/database/mariadb/mode/replication.pm +++ b/src/cloud/azure/database/mariadb/mode/replication.pm @@ -49,7 +49,7 @@ sub new { $options{options}->add_options(arguments => { 'filter-metric:s' => { name => 'filter_metric' }, 'resource:s' => { name => 'resource' }, - 'resource-group:s' => { name => 'resource_group' }, + 'resource-group:s' => { name => 'resource_group' } }); return $self; @@ -66,11 +66,10 @@ sub check_options { 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\/(.*)\/(.*)$/) { + my $resource_type = 'servers'; + if ($resource =~ /^\/subscriptions\/.*\/resourceGroups\/(.*)\/providers\/Microsoft\.DBforMariaDB\/servers\/(.*)$/) { $resource_group = $1; - $resource_type = 'servers'; - $resource = $3; + $resource = $2; } $self->{az_resource} = $resource; @@ -90,7 +89,7 @@ sub check_options { } my $resource_mapping = { - 'servers' => [ 'seconds_behind_master' ], + 'servers' => [ 'seconds_behind_master' ] }; my $metrics_mapping_transformed; diff --git a/src/cloud/azure/database/mariadb/mode/storage.pm b/src/cloud/azure/database/mariadb/mode/storage.pm index 0dbeb6378..b9e5f675a 100644 --- a/src/cloud/azure/database/mariadb/mode/storage.pm +++ b/src/cloud/azure/database/mariadb/mode/storage.pm @@ -91,7 +91,7 @@ sub new { $options{options}->add_options(arguments => { 'filter-metric:s' => { name => 'filter_metric' }, 'resource:s' => { name => 'resource' }, - 'resource-group:s' => { name => 'resource_group' }, + 'resource-group:s' => { name => 'resource_group' } }); return $self; @@ -108,11 +108,10 @@ sub check_options { 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\/(.*)\/(.*)$/) { + my $resource_type = 'servers'; + if ($resource =~ /^\/subscriptions\/.*\/resourceGroups\/(.*)\/providers\/Microsoft\.DBforMariaDB\/servers\/(.*)$/) { $resource_group = $1; - $resource_type = 'servers'; - $resource = $3; + $resource = $2; } $self->{az_resource} = $resource; @@ -132,9 +131,10 @@ sub check_options { } my $resource_mapping = { - 'servers' => [ 'backup_storage_used', 'serverlog_storage_limit', 'serverlog_storage_percent', - 'serverlog_storage_usage', 'storage_limit', 'storage_percent', 'storage_used' - ], + 'servers' => [ + 'backup_storage_used', 'serverlog_storage_limit', 'serverlog_storage_percent', + 'serverlog_storage_usage', 'storage_limit', 'storage_percent', 'storage_used' + ] }; my $metrics_mapping_transformed; diff --git a/src/cloud/azure/database/mariadb/mode/traffic.pm b/src/cloud/azure/database/mariadb/mode/traffic.pm index d97181b89..0443a7393 100644 --- a/src/cloud/azure/database/mariadb/mode/traffic.pm +++ b/src/cloud/azure/database/mariadb/mode/traffic.pm @@ -34,14 +34,14 @@ sub get_metrics_mapping { 'label' => 'traffic-out', 'nlabel' => 'azmariadb.traffic.out.bytes', 'unit' => 'B', - 'min' => '0', + 'min' => '0' }, 'network_bytes_ingress' => { 'output' => 'Network In', 'label' => 'traffic-in', 'nlabel' => 'azmariadb.traffic.in.bytes', 'unit' => 'B', - 'min' => '0', + 'min' => '0' } }; @@ -56,7 +56,7 @@ sub new { $options{options}->add_options(arguments => { 'filter-metric:s' => { name => 'filter_metric' }, 'resource:s' => { name => 'resource' }, - 'resource-group:s' => { name => 'resource_group' }, + 'resource-group:s' => { name => 'resource_group' } }); return $self; @@ -73,11 +73,10 @@ sub check_options { 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\/(.*)\/(.*)$/) { + my $resource_type = 'servers'; + if ($resource =~ /^\/subscriptions\/.*\/resourceGroups\/(.*)\/providers\/Microsoft\.DBforMariaDB\/servers\/(.*)$/) { $resource_group = $1; - $resource_type = 'servers'; - $resource = $3; + $resource = $2; } $self->{az_resource} = $resource;