centreon / centreon-plugins

Collection of standard plugins to discover and gather cloud-to-edge metrics and status across your whole IT infrastructure.
https://www.centreon.com
Apache License 2.0
312 stars 275 forks source link

Bug with azure::database::mariadb #4549

Closed Start81 closed 1 year ago

Start81 commented 1 year ago

Hello I found a bug when try this connector with centreon : sudo -u centreon ./centreon_azure_database_mariadb_api.pl --plugin=cloud::azure::database::mariadb::plugin --resource=mydb --resource-group=Myressourcegroup --subscription='SUBID' --tenant='TenantID' --client-id='clientID' --client-secret=Secret --custommode=api --mode=cpu

this return : Use of uninitialized value $options{"resource_type"} in concatenation (.) or string at ./centreon_azure_database_mariadb_api.pl line 8854. UNKNOWN: Management endpoint API returns error code 'InvalidResourceType' (add --debug option for detailed message)

error can be differend when using --resource=

I debug the script and join a working version: There is two error in every mode in fonction check_options

I replace this code :

      my $resource_type = $self->{option_results}->{resource_type};
      if ($resource =~ /^\/subscriptions\/.*\/resourceGroups\/(.*)\/providers\/Microsoft\.DBforMariaDB\/(.*)\/(.*)$/) {
          $resource_group = $1;
          $resource_type = 'servers';
          $resource = $3;
      }

by ``

       my $resource_type = "servers";
      if ($resource =~ /^\/subscriptions\/.*\/resourceGroups\/(.*)\/providers\/Microsoft\.DBForMariaDB\/servers\/(.*)$/) {
          $resource_group = $1;
          $resource = $2;
      }

I hope this can help . Regards. DESMAREST JULIEN centreon_azure_database_mariadb_api.zip

garnier-quentin commented 1 year ago

thanks for the issue: https://github.com/centreon/centreon-plugins/pull/4550