Skip to main content
Discussion ongoing

Passing credentials through MySQL/MariaDB service templates to override host's credential macros

Related products:Infra Monitoring - Configuration
  • June 11, 2026
  • 3 replies
  • 16 views

Forum|alt.badge.img+8

Hello.

 

The MySQL/MariaDB connector stores the credentials in the monitored host's macros.

 

The problem is that if I need to have a service that connects to the server of that monitored host but with another user, there is no way to override the "default" credentials from the host's macros.

 

We have several MySQL servers with several databases and users in each that we need to monitor.

 

So for now, you need to create a new monitored host (for the same server) with those credentials or use a modified command based on the one provided by the connector.

 

Could it be possible to add that functionality (overriding the credential stored in the host) to the service templates for the MySQL/MariaDB connector? That also be consistent with how other connectors work, which allow to override macro's values stored in the host with its own macros or passed as options in the EXTRAOPTIONS macro (for example, hostname, protocol, port...).

 

The connector allows to specify a database and port to connect to; it would seem normal it also allows to set the credentials if needed.

 

Regards.

3 replies

lpinsivy
Centreonian
Forum|alt.badge.img+21
  • Centreonian
  • June 12, 2026

Hi ​@emeck,

The definition of macros on hosts or on services depends on the definition of the control command.

Here the App-DB-MySQL-Connection-Time command have the following definition:

$CENTREONPLUGINS$/centreon_mysql.pl --plugin=database::mysql::plugin --host=$HOSTADDRESS$ --username='$_HOSTMYSQLUSERNAME$' --password='$_HOSTMYSQLPASSWORD$' --port='$_HOSTMYSQLPORT$' $_HOSTMYSQLEXTRAOPTIONS$ --mode=connection-time --warning='$_SERVICEWARNING$' --critical='$_SERVICECRITICAL$' $_SERVICEEXTRAOPTIONS$

The MYSQLUSERNAME, MYSQLPASSWORD, MYSQLPORT should be defined on a host or host template.

If you want to overwrite the username and password, you must duplicate the commande, and change $_HOSTMYSQLUSERNAME$ and $_HOSTMYSQLPASSWORD$ by $_SERVICEMYSQLUSERNAME$ and $_SERVICEMYSQLPASSWORD$. Then select this command in your service and define MYSQLUSERNAME, MYSQLPASSWORD macros


lpinsivy
Centreonian
Forum|alt.badge.img+21
  • Centreonian
  • June 12, 2026
Updated idea statusNewDiscussion ongoing

Forum|alt.badge.img+8
  • Author
  • Steward ***
  • June 29, 2026

Hi ​@lpinsivy 

Yes, I have modified the command to accept username and password from the service, not the host.

But I was hoping that it can be used as a default username/password in the host and that the service could override those if necessary.

We need to monitor several database servers where we cannot create users so we need to use the credentials provided by the clients. Grouping them in one monitored host because they are in the same database server or are related databases seems something logical that the connector could support.

Regards.