Inventory Dabase Mysql #75
Description
Activity
By default, the agent attempts to inventory databases using the default credentials (
root/root) — shame on any administrators who might have left these unchanged 😄 .For environments where passwords have been updated, you must either use the Database Inventory plugin or run the agent via the CLI with the
--credentialoption. More details can be found here: https://glpi-agent.readthedocs.io/en/version-1.15/man/glpi-agent.html.I am not certain whether database inventory is supported through remote inventory.
@g-bougard, could you please confirm or clarify this?
Best regards
ok,
{"message":"remoteinventory task not supported","disabled":["remoteinventory"],"expiration":"24","status":"ok","tasks":{"collect":{"version":"1.5.3","server":"glpiinventory"},"deploy":{"version":"1.5.3","server":"glpiinventory"},"esx":{"version":"1.5.3","server":"glpiinventory"},"inventory":{"server":"glpi","version":"10.0.19","params":[{"category":"database","use":["mysql"],"params_id":2,"delay":1}]},"netdiscovery":{"version":"1.5.3","server":"glpiinventory"},"netinventory":{"version":"1.5.3","server":"glpiinventory"}}}it's the return done by glpi server to agent : I didn't configure anything to specify to use remoteinventory ...
So I wonder how it runs, how it must be configured
Hi @EC2311
please use GLPI-Agent v1.15, there were some fixes related to database inventory since v1.12.
Having "params" in "inventory" nodes doesn't guaranty database inventory will work: glpi-agent still has to check if it can run the expected inventory (for example it can check if it can run mysql command). If you run glpi-agent in debug2 level, you should check if the expected database inventory module is started and if it requests the credentials to server.
I have a doubt in your first questions, you speak about mysql database inventory and also MSSQL. Is "MSSQL" a typo ?
Regarding remoteinventory, database inventory is only supported when glpi-agent runs on the same computer where the database server runs.
hi @g-bougard
thanks for your reply
I will check with GLPI1.15 : ok
run glpi-agent in debug2 level -> glpi-agent.bat --debug --debug ?
expected database inventory module -> how it appears ?I spoke about MSSQL because for those type of db the size of it raises directly, without parameters : perhaps it's only the size of files ? and not index and so on ?
I spoke about 'remoteinventory' because it's the message received from GLPIserver to the agent (all together are on the same computer : I audit glpi server itself) : so it's easy for me to test dabaseinventory :)
by specifying --json on the command, then the main module (databases runs.
But the other (mssql, mysql and so on) stays disabledto avoid adding others problem, i Updated into glpiagent 1.15
same thing
I added print to follow script in mysql.pm script.
the only one I see is the one set in isenabled subroutineBy default,
glpi-inventoryproduces XML format, so yes, you need to add--jsonoption. You don't need the option when using--partialas output is always JSON in that case.If you require credentials to be sent by server, you need to run glpi-agent so it can ask credentials. With
glpi-inventory, you can specify--credentialsoption.But MySQL database inventory seems disabled in your partial output and this means
mysqlcommand is not available in the PATH: you have to be sure mysql client is installed.hi @g-bougard
Indeed about the path : it's the good way to explain the problem. Thanks !I wrote a script (PS) to scan active service (here mysql) and add the path of it (in case it's not in the path)
Now I see the script Executing mysql -q -sN -e "SHOW VARIABLES LIKE 'version'", but the results are not in the output (local)
I keep you informed[Thu Sep 4 09:17:55 2025][debug] Running GLPI::Agent::Task::Inventory::Generic::Databases
[Thu Sep 4 09:17:55 2025][debug] Running GLPI::Agent::Task::Inventory::Generic::Databases::MySQL
[Thu Sep 4 09:17:55 2025][debug2] [http client] 251ACC41: sending message:
{
"action": "get_params",
"deviceid": "SERVERNAME",
"name": "GLPI-Agent",
"params_id": "2",
"use": "mysql",
"version": "1.15"
}
[Thu Sep 4 09:17:55 2025][debug2] format: Zlib
[Thu Sep 4 09:17:55 2025][debug2] [http client] 251ACC41: received message:
{"expiration":"24","status":"ok"}
[Thu Sep 4 09:17:55 2025][error] Database credential request not supported by server
[Thu Sep 4 09:17:55 2025][debug2] Trying default credentialWhat does it mean ?
As no "credentials" property appears in the answer, it means server and the plugin failed to provide the expected answer: the credentials with params_id=2 for "mysql".
You have to check this "credentials" is well defined.
I assume it's ok for params_id=2 (in glpi)
How can I check the returned value received glpi-agent side ?
Here you can't as it should be inserted into
{"expiration":"24","status":"ok"}
And it is not.What is missing is a "credentials" property like:
"credentials":[{"id": "2","type":"login_password","use":"mysql","login":"login","password": "password"}]You may check GLPI php-errors.log to see if you have an error at the time the
"action": "get_params"agent request is sent.I have no error at all (php_errors log (site and wamp), sql...)
I checked password (compared what i typed in glpi) using shell : it's okI tried using --credentials -> it doesn't check neither... :(
in databases.pm
I think research must be done server glpi to fetch the answer sent by server
I wonder about request.php in src/inventory ;)You can check the file
databaseinventory/inc/task.class.php, specifically theinventoryGetParamsfunction.This function is responsible for loading credentials from the database based on the type (MySQL in your case) and the params_id (2 in your example) requested by the agent.
If the credentials are found, they are properly structured and returned to the agent.
You can also verify the agent’s call in the “Contact log” tab of the Database Params object, which keeps a record of this interaction.
I have submitted a pull request: #77
Could you please provide us with the agent log file after applying your fix?
Here is the agent log (limited at the DB audit)
[Thu Sep 4 13:29:45 2025][debug2] [http client] 3ED115EB: sending message:
{
"action": "get_params",
"deviceid": "AgentServername",
"name": "GLPI-Agent",
"params_id": "3",
"use": "mysql",
"version": "1.15"
}
[Thu Sep 4 13:29:45 2025][debug2] format: Zlib
[Thu Sep 4 13:29:45 2025][debug2] [http client] 3ED115EB: received message:
{"expiration":"24","status":"ok","credentials":[{"id":4,"type":"login_password","use":"mysql","login":"xxxxxxxxxx","password":"yyyyyyyyy","port":3306}]}
[Thu Sep 4 13:29:45 2025][debug2] Trying login_password credential type
[Thu Sep 4 13:29:45 2025][debug2] executing mysql --defaults-extra-file=my-MJuBaw.cnf -q -sN -e "SHOW VARIABLES LIKE 'version'"
[Thu Sep 4 13:29:46 2025][debug2] executing mysql --defaults-extra-file=my-MJuBaw.cnf -q -sN -e "SELECT DATE_SUB(now(), INTERVAL variable_value SECOND) from ...
[Thu Sep 4 13:29:46 2025][debug2] executing mysql --defaults-extra-file=my-MJuBaw.cnf -q -sN -e "SELECT DATE_SUB(now(), INTERVAL variable_value SECOND) from ...
[Thu Sep 4 13:29:46 2025][debug2] executing mysql --defaults-extra-file=my-MJuBaw.cnf -q -sN -e "SHOW DATABASES"
[Thu Sep 4 13:29:46 2025][debug2] executing mysql --defaults-extra-file=my-MJuBaw.cnf -q -sN -e "SELECT sum(data_length+index_length) FROM ...
[Thu Sep 4 13:29:46 2025][debug2] executing mysql --defaults-extra-file=my-MJuBaw.cnf -q -sN -e "SELECT MIN(create_time) FROM information_schema.TABLES WHERE ...
[Thu Sep 4 13:29:46 2025][debug2] executing mysql --defaults-extra-file=my-MJuBaw.cnf -q -sN -e "SELECT MAX(update_time) FROM information_schema.TABLES WHERE ...
[Thu Sep 4 13:29:46 2025][debug2] executing mysql --defaults-extra-file=my-MJuBaw.cnf -q -sN -e "SELECT sum(data_length+index_length) FROM ...Perhaps please verify the behaviour with glpi-inventory which doesn't get credentials at all
I close this issue and thanks a lot for your job



Code of Conduct
Is there an existing issue for this?
GLPI Version
10.0.19
Plugin version
1.0.3
Bug description
When running the agent, I hope it will 'scan' mysql DB.
The agent (glpi agent 1.12) sends the contact :
{
"action": "contact",
"deviceid": "AgentName",
"enabled-tasks": [
"collect",
"deploy",
"esx",
"inventory",
"netdiscovery",
"netinventory",
"remoteinventory"
],
"installed-tasks": [
"collect",
"deploy",
"esx",
"inventory",
"netdiscovery",
"netinventory",
"remoteinventory"
],
"name": "GLPI-Agent",
"tag": "xx",
"version": "1.12"
}
And recevied message :
{"message":"remoteinventory task not supported","disabled":["remoteinventory"],"expiration":"24","status":"ok","tasks":{"collect":{"version":"1.5.3","server":"glpiinventory"},"deploy":{"version":"1.5.3","server":"glpiinventory"},"esx":{"version":"1.5.3","server":"glpiinventory"},"inventory":{"server":"glpi","version":"10.0.19","params":[{"category":"database","use":["mysql"],"params_id":2,"delay":1}]},"netdiscovery":{"version":"1.5.3","server":"glpiinventory"},"netinventory":{"version":"1.5.3","server":"glpiinventory"}}}
we can see there is the DB parameters in it, but the remoteinventory is not supported :
and of course there is no DB inventory.
What is the configuration to set (on agent ? on server) in order to inventory mysql DB ?
in fact the MSSQL DB are well inventoried, without using plugin databaseInventory...
Thanks
Relevant log output
Page URL
No response
Steps To reproduce
No response
Your GLPI setup information
No response
Anything else?
No response