Skip to content

Inventory Dabase Mysql #75

Description

@EC2311

Code of Conduct

  • I agree to follow this project's Code of Conduct

Is there an existing issue for this?

  • I have searched the existing issues

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

Activity

  1. stonebuzz commented on Sep 3, 2025

    @stonebuzz
    Contributor

    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 --credential option. 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

  2. EC2311 commented on Sep 3, 2025

    @EC2311
    Author

    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

  3. g-bougard commented on Sep 3, 2025

    @g-bougard

    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.

  4. EC2311 commented on Sep 3, 2025

    @EC2311
    Author

    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 :)

  5. EC2311 commented on Sep 3, 2025

    @EC2311
    Author

    i found something :
    glpi-inventory --debug --debug

    Image

    with glpi-inventory --debug --debug --partial=DATABASE

    Image

    why ?

  6. EC2311 commented on Sep 3, 2025

    @EC2311
    Author

    by specifying --json on the command, then the main module (databases runs.
    But the other (mssql, mysql and so on) stays disabled

    to 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 subroutine

  7. g-bougard commented on Sep 3, 2025

    @g-bougard

    By default, glpi-inventory produces XML format, so yes, you need to add --json option. You don't need the option when using --partial as 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 --credentials option.

    But MySQL database inventory seems disabled in your partial output and this means mysql command is not available in the PATH: you have to be sure mysql client is installed.

  8. EC2311 commented on Sep 4, 2025

    @EC2311
    Author

    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

  9. EC2311 commented on Sep 4, 2025

    @EC2311
    Author

    [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 credential

    What does it mean ?

  10. g-bougard commented on Sep 4, 2025

    @g-bougard

    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.

  11. EC2311 commented on Sep 4, 2025

    @EC2311
    Author

    I assume it's ok for params_id=2 (in glpi)

    How can I check the returned value received glpi-agent side ?

  12. g-bougard commented on Sep 4, 2025

    @g-bougard

    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.

  13. EC2311 commented on Sep 4, 2025

    @EC2311
    Author

    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 ok

    I tried using --credentials -> it doesn't check neither... :(

    in databases.pm

    Image

    I think research must be done server glpi to fetch the answer sent by server
    I wonder about request.php in src/inventory ;)

  14. stonebuzz commented on Sep 4, 2025

    @stonebuzz
    Contributor

    You can check the file databaseinventory/inc/task.class.php, specifically the inventoryGetParams function.

    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.

  15. EC2311 commented on Sep 4, 2025

    @EC2311
    Author

    I found the mistake :)

    Image

    we received params_id (the one of DB in fact) and not the one of credentials

    what i remarked too :
    -> glpi-agent does the inventory of DB
    -> glpi-inventory doesn't call task (get_params) -> no trace of call with an dump file

    Now I have my contact log filled:)

  16. stonebuzz commented on Sep 4, 2025

    @stonebuzz
    Contributor

    I have submitted a pull request: #77

    Could you please provide us with the agent log file after applying your fix?

  17. EC2311 commented on Sep 4, 2025

    @EC2311
    Author

    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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions