Skip to main content

GLPI – Connect, check, and repair an external GLPI with Medulla

Applies to: Medulla Server
Version: Medulla 5.6.x (specific checks starting with 5.6.6)
Compatibility: GLPI 10 and GLPI 11
Environment: On-Premise / Debian
Category: GLPI integration / Configuration / Diagnostics
Tool: medulla_itsm.py

Overview

Medulla can be connected to an external GLPI server to use information related to equipment, users, entities, and inventories.

The medulla_itsm.py script centralizes the diagnostics, configuration, and repair operations for this connection.

It replaces the following legacy tools:

  • change_itsm_parameters.py: GLPI connection configuration.
  • check_itsm_access.sh: checks access and permissions

The script has two modes:

Mode Function Modification
Check (check) Diagnose the configuration and identify anomalies. Automatic normalization of misspelled API parameter names in admin.saas_application.
Correction (fix) Connect an external GLPI or repair an existing configuration. Yes, after preliminary checks and confirmation in interactive mode.

The script is available in French, English, Spanish, and German. It can be used interactively or in an automated way.

Important: The script configures Medulla and checks GLPI prerequisites. It does not automatically create remote SQL accounts, GLPI users, or API clients. These elements must be set up in GLPI.

1. Prerequisites

1.1. On the Medulla server

The script must be run directly on the Medulla server.

It requires:

  • Python 3.7 or later.
  • The Python mysql.connector module.
  • The Python requests module.
  • The Python nacl module, recommended for validating GLPI 11 encryption keys.
  • The MariaDB/MySQL command-line client.
  • The systemctl command.
  • Linux administrator privileges for correction mode.

On Debian, install the necessary dependencies:

sudo apt-get update
sudo apt-get install python3-mysql.connector python3-requests python3-nacl default-mysql-client

The script automatically checks these prerequisites at startup.

1.2. On the GLPI server

Check that:

  • GLPI 10 or 11 is installed and its database is up to date.
  • The Medulla server can access the GLPI MySQL/MariaDB database.
  • The SQL port is allowed from the Medulla server.
  • A dedicated SQL account for Medulla exists.
  • The GLPI web interface is accessible.
  • The GLPI REST API is enabled when API functions are required.
  • A GLPI API user and an API client named MMC are configured for read-write mode.
  • The required inventory plugin is installed and active if inventory reporting is used.

1.3. Required network flows

Source Destination Port Usage
Medulla server GLPI SQL server TCP 3306 (default) Access to the GLPI database.
Medulla server GLPI web server TCP 443 or 80 Web interface, REST API, and inventory reporting.

Note: The SQL port can be customized. The script checks DNS resolution, Medulla’s source IP address, and the accessibility of the remote port.

2. Download and run the script

The script is available on the official Medulla download server:

Download medulla_itsm.py

2.1. Download the script

On the Medulla server, run:

wget https://dl.medulla-tech.io/ma/medulla_itsm.py

Make the file executable:

chmod +x medulla_itsm.py

2.2. Launch the interactive interface

sudo ./medulla_itsm.py

The script prompts you to select a language:

Language / Langue / Idioma / Sprache

  1) English
  2) Français
  3) Español
  4) Deutsch

  > [1] 2

To start directly in French:

sudo ./medulla_itsm.py --lang fr

The script then detects whether Medulla is using its local GLPI or an external GLPI.

Example when no external GLPI is configured:

Medulla ⇄ GLPI — outil de connexion à un ITSM (GLPI) externe

Aucun GLPI externe connecté
(dbhost = localhost dans /etc/mmc/plugins/glpi.ini.local)

Que voulez-vous faire ?

  1) Connecter un GLPI externe à Medulla
  2) Mode vérification — diagnostiquer la configuration actuelle
  3) Quitter

When an external GLPI connection already exists, check mode is selected by default.

2.3. Check an existing connection

sudo ./medulla_itsm.py --lang fr --mode check

2.4. Configure or repair a connection

sudo ./medulla_itsm.py --lang fr --mode fix

Key takeaway: Check mode can automatically correct API parameter names in admin.saas_application. Correction mode requires root privileges and displays the plan before requesting confirmation in interactive mode.

3. External GLPI detection

The script checks the dbhost parameter in the [main] section in:

/etc/mmc/plugins/glpi.ini.local

If dbhost is missing, empty, or set to localhost, the script assumes that no external GLPI is configured.

In this case:

  • Check mode does not run the external GLPI checks.
  • Correction mode prompts you to configure a new connection.
  • The local GLPI settings are not used as default values.

The script refuses to configure localhost as the SQL host for an external GLPI, even with the --force option.

When reconfiguring an existing external GLPI, the current values are suggested based on the Medulla configuration files and the admin.saas_application table.

4. Check an existing GLPI connection

To diagnose the existing GLPI connection, run the following command on the Medulla server.

sudo ./medulla_itsm.py --lang fr --mode check

The script retrieves the parameters stored on the Medulla server and performs several sets of checks.

Possible write in check mode When checking the local database, the script attempts to rename known parameters whose names differ only in case, spaces, or invisible characters. It only intervenes if the exact expected name is missing and preserves the parameter’s value. This correction can also occur in read-only mode, without an external GLPI configured, and with the --non-interactive option.

In interactive mode, the script may prompt you to switch to correction mode after a failure or to connect to an external GLPI for the first time. Add --non-interactive to suppress these prompts.

4.1. Prerequisites and Medulla database

The script checks:

  • The availability of Python modules.
  • The necessary system commands.
  • Connection to the xmppmaster database.
  • The Medulla version.
  • Whether the MariaDB FEDERATED engine is enabled.
  • Permissions required to create a federated server.
  • Access to the admin.saas_application table.

4.2. GLPI database connection

The diagnostic checks:

  • DNS resolution for the GLPI server.
  • Accessibility of the SQL port.
  • MySQL/MariaDB authentication.
  • Whether the GLPI database exists.
  • The major version of GLPI: 10 or 11.
  • Consistency of the GLPI schema version.
  • The presence of the necessary tables and views.
  • SQL permissions for the Medulla account.
  • Installed and active inventory plugins.

4.3. GLPI and REST API configuration

Depending on the selected mode, the script also checks:

  • GLPI settings, particularly url_base.
  • REST API activation.
  • Authentication via credentials and tokens.
  • The API client named MMC.
  • The GLPI API user and their status.
  • Any IP address restrictions.
  • The validity of available tokens.
  • The GLPI session profile.
  • The TLS certificate.
  • The inventory reporting URL, when enabled.

4.4. Medulla internal configuration

Finally, the script checks:

  • The GLPI and substitute agent configuration files.
  • The consistency of the saas_application table.
  • The definition of the federated server itsm_federated.
  • The federated local_glpi_* tables.
  • The columns required since Medulla 5.6.6.
  • The status of the mmc-agent service and the two substitute services.

If the GLPI database is inaccessible, checks that depend on its contents are skipped, but the web and API tests are still run when the settings allow it.

4.5. Understand the results

Indicator Meaning
[✓] Check passed.
[!] Warning that may require checking.
[✗] Check failed.
[=] Information about the detected configuration.

Failures are accompanied, when possible, by instructions on how to correct them.

In interactive mode, the script may prompt you to switch directly to correction mode.

5. Configure or repair the GLPI connection

To configure an external GLPI or correct an existing connection:

sudo ./medulla_itsm.py --lang fr --mode fix

The script prompts you for the necessary parameters and suggests existing values when an external configuration is already present.

5.1. Connection parameters

Parameter Description Example
--url GLPI main URL. https://glpi.exemple.fr
--db-host GLPI SQL server address. 10.10.0.101
--db-port SQL port. 3306
--db-name GLPI database name. glpi
--db-user SQL user dedicated to Medulla. medulla_glpi
--db-pass SQL password. Confidential value
--api-url GLPI REST API URL. Depending on the GLPI version
--api-user GLPI API user. medulla_api
--api-pass API user password. Confidential value
--readonly Enable read-only mode. true / false
--apiapptoken MMC API client token. App-Token
--apiusertoken API user token. User-Token
--crypt-key GLPI encryption key encoded in Base64. Depending on GLPI

5.2. Checks before applying the changes

The script checks the parameters and the connection to the external GLPI before applying the Medulla configuration plan. Name normalization in admin.saas_application occurs as soon as the local database is checked. If the installation of SQL views is allowed, it also occurs during the pre-check, before the Medulla plan is confirmed.

If errors are detected, interactive mode allows you to:

  1. Correct the parameters.
  2. Proceed despite the errors.
  3. Cancel the operation.

The script then displays the plan of the proposed changes. In interactive mode, it prompts for confirmation before applying it.

Caution: The --force option does not correct network errors, missing SQL permissions, or invalid parameters. It is recommended that you resolve any pre-check failures before continuing.

6. Prepare GLPI SQL permissions

Medulla must have a dedicated SQL account on the GLPI database.

The required permissions depend on the selected operating mode.

6.1. Read-only mode

This mode allows Medulla to view GLPI data without modifying it.

The SQL account must have read permissions on the necessary tables and views.

Example:

GRANT SELECT, SHOW VIEW
ON `glpi`.*
TO 'medulla_glpi'@'MEDULLA_SERVER_IP';

Replace MEDULLA_SERVER_IP with the authorized IP address.

In this mode, the script:

  • Does not request API credentials or tokens.
  • Retains the API values from admin.saas_application. The local database check may correct the name of a parameter.
  • Checks that the API URL responds. Authentication tests are reserved for read-write mode.
  • Disables inventory reporting to GLPI.
  • Sets dbreadonly = 1.
  • Sets check_uuidinventory = True.

Point to watch: Any requirements Medulla may have regarding API tokens and the encryption key in read-only mode must be validated based on the features being used. The script does not configure these in this mode.

6.2. Read-write mode

This mode allows Medulla to interact with GLPI, subject to the SQL permissions and the API user’s permissions.

In particular, the script checks the following privileges:

  • SELECT
  • INSERT
  • UPDATE
  • DELETE

Example of permissions on the GLPI database:

GRANT SELECT, INSERT, UPDATE, DELETE, SHOW VIEW
ON `glpi`.*
TO 'medulla_glpi'@'MEDULLA_SERVER_IP';

Creating or replacing SQL views may require additional permissions, including CREATE VIEW and DROP.

These permissions can be temporarily granted to an administrator responsible for applying the views, rather than to the account used daily by Medulla.

7. Install the SQL views required by Medulla

Medulla uses four specific SQL views in the GLPI database:

  • glpi_computers_pulse
  • glpi_view_computers_items_printer
  • glpi_view_computers_items_peripheral
  • glpi_view_peripherals_manufacturers

The script checks for their presence and accessibility.

7.1. SQL files by GLPI version

GLPI version SQL file
GLPI 10 glpi-100.sql
GLPI 11 glpi-110.sql

7.2. Automatic installation

When views are missing or broken, the interactive correction mode offers the following options:

  1. To download and apply the SQL file corresponding to the GLPI version.
  2. To apply the file manually, then rerun the checks.
  3. To continue without applying the views.

To enable automatic application in non-interactive mode, use:

--apply-sql

Important: The script does not perform a full backup of the GLPI database before applying the SQL file. Perform a backup before making any changes to the schema.

7.3. Manual installation

For GLPI 10:

wget -O glpi-100.sql https://dl.medulla-tech.io/nc/glpi-100.sql

For GLPI 11:

wget -O glpi-110.sql https://dl.medulla-tech.io/nc/glpi-110.sql

After backing up the database, apply the corresponding file using an SQL account with the necessary permissions.

Example for GLPI 11:

mysql -h GLPI_SERVER -P 3306 -u SQL_USER -p glpi < glpi-110.sql

Then rerun the diagnostic:

sudo ./medulla_itsm.py --lang fr --mode check

8. Configure the GLPI REST API

In read-write mode, Medulla uses the GLPI REST API for certain administration and synchronization operations.

8.1. Create the GLPI API user

In GLPI:

Administration → Users

Create a user dedicated to Medulla.

Recommended configuration:

Parameter Value
Type Standard user dedicated to Medulla.
Profile Profile tailored to the required operations.
Entity Root entity if all entities must be accessible.
Recursion Enabled when child entities need to be managed.
Status Active user.

A Super-Admin profile allows for the most extensive administration operations but should be reserved for situations where these permissions are necessary.

Then generate the user token:

user_token

8.2. Create the MMC API client

In GLPI:

Setup → General → API

Enable the necessary authentication methods, including:

  • Authentication with credentials.
  • Authentication via an external token.

Create an API client with the exact name:

MMC

Generate its application token:

app_token

Check that the client is active and that any IP address restrictions allow the Medulla server.

8.3. GLPI API URL

Version Suggested URL
GLPI 10 https://glpi.exemple.fr/apirest.php
GLPI 11 https://glpi.exemple.fr/api.php/v1

The script also accepts a URL using apirest.php for GLPI 11.

8.4. Token management

The script searches for API tokens in the GLPI database.

If a token is available in plain text, it can be retrieved automatically.

For a token that is encrypted, hashed, or in an unrecognized format, provide the original value. A token detected in plain text in GLPI is used automatically, even if a value was passed as an argument or via an environment variable in non-interactive mode.

In this case, regenerate the token in GLPI and enter the displayed value into the script.

The tokens used by Medulla are stored in the table:

admin.saas_application

The relevant parameters include:

  • glpi_mmc_app_token
  • glpi_root_user_token
  • glpi_url_base_api
  • type_api
  • glpi_crypt_key

In read-write correction mode, the script creates any missing API rows and sets type_api to glpi_rest if this value is empty. In read-only mode, the API values already stored are retained.

9. GLPI encryption key

9.1. GLPI 10

For GLPI 10 in read-write mode, correction mode can set glpi_crypt_key to REPLACE when no key is provided and the stored value is empty.

9.2. GLPI 11

For GLPI 11, the script uses the encryption key of the GLPI instance.

On the GLPI server:

sudo base64 -w0 /etc/glpi/glpicrypt.key

Depending on the installation, the file may also be located in:

<GLPI directory>/config/glpicrypt.key

The script checks that the decoded key contains 32 bytes and, when the necessary data is available, that it can be used to decrypt a GLPI value.

Cryptographic validation uses the Python nacl module.

Security: The encryption key, API tokens, and passwords are confidential. Do not share them with support or include them in unprotected screenshots or logs.

10. MariaDB federated server

Medulla uses the MariaDB FEDERATED engine to query certain GLPI tables from its local xmppmaster database.

The script creates or updates a federated server named:

itsm_federated

Local federated tables do not contain copies of GLPI data. Queries are forwarded to the remote server.

10.1. Federated tables

Local Medulla table Remote GLPI table
local_glpi_configs glpi_configs
local_glpi_machines glpi_computers
local_glpi_filters glpi_computers
local_glpi_items_softwareversions glpi_items_softwareversions
local_glpi_softwareversions glpi_softwareversions
local_glpi_softwares glpi_softwares
local_glpi_entities glpi_entities

The script preserves existing federated tables and creates any that are missing.

Starting with Medulla 5.6.6, it also checks for the presence of the following columns:

  • last_inventory_update
  • last_boot
  • date_mod

If necessary, it recreates the local federated table local_glpi_machines to include these columns.

10.2. Required permissions

Creating the federated server requires administrative privileges on MariaDB.

Depending on the MariaDB version:

  • FEDERATED ADMIN on MariaDB 10.5.2 and later.
  • SUPER on earlier versions.
  • Or equivalent global administrative privileges.

The script attempts the following in sequence:

  1. The MariaDB account for Medulla, typically mmc.
  2. The MariaDB root account via the local socket and the Python module.
  3. The MariaDB root account via the mariadb or mysql system client.

This third method was added on November 23, 2026, to support the unix_socket authentication commonly used on Debian.

10.3. Error: Unable to create the federated server

If the script displays:

[✗] Ni mmc ni root (socket local) ne peuvent créer
    le serveur fédéré

First, check MariaDB administrator access:

sudo mariadb -e "SELECT USER(), CURRENT_USER(), VERSION(); SHOW GRANTS FOR CURRENT_USER();"

If this command works, use the version of the script that includes the fallback to the system MariaDB client.

To retrieve the published version of the script:

wget -O medulla_itsm.py https://dl.medulla-tech.io/ma/medulla_itsm.py
chmod +x medulla_itsm.py

If no available account has the necessary privileges, a MariaDB administrator can grant:

GRANT FEDERATED ADMIN ON *.* TO 'mmc'@'localhost';

On an older version of MariaDB that does not support this privilege, the SUPER privilege may be required.

Recommendation: Prefer one-off use of the MariaDB administrator account via the local socket rather than permanently granting global privileges to the mmc application account.

10.4. FEDERATED engine missing

If the engine is not available, check its status:

SHOW ENGINES;

Depending on the MariaDB version and configuration, its installation may require:

INSTALL SONAME 'ha_federatedx';

To load the engine at every startup, the MariaDB configuration can use:

[mariadb]
plugin_load_add = ha_federatedx

This operation must be performed by a MariaDB administrator.

11. Inventory reporting to GLPI

The script allows you to configure the transfer of inventory data to GLPI.

The available parameters are:

Parameter Description
--inv-forward Enable or disable inventory reporting.
--inv-forward-url URL for receiving GLPI inventories.
--inv-plugin GLPI Inventory or FusionInventory plugin.
--inv-agent Inventory agent used on workstations.
--inv-agent-disabled Disable the inventory agent integrated into the Medulla agent.

Example of a reporting URL:

https://glpi.exemple.fr/front/inventory.php

For GLPI 10 and 11, the script checks for the presence of the GLPI Inventory plugin and flags incompatible FusionInventory configurations.

In read-only mode, inventory reporting is disabled.

12. Changes made on the Medulla server

After the parameters are validated, correction mode applies the changes in the following order:

  1. Creation or update of the federated server itsm_federated and the necessary federated tables.
  2. Update of /etc/mmc/plugins/glpi.ini.local.
  3. Update of admin.saas_application (except in read-only mode).
  4. Configuration of the substitute inventory agent.
  5. Update of the inventory agent settings.
  6. Configuration of the substitute registration agent.
  7. Configuration of registeryagent.ini.local.
  8. Restart of the Medulla services.
  9. Possible request to reconfigure the agents.
  10. Possible regeneration of the agent installer.

Failure to create the federated server The script then stops applying the changes before writing the Medulla files and API values. Any name corrections and view installations made during the preliminary checks remain in effect.

12.1. File backup

Before making any changes, the script backs up the existing files to a backup/ folder next to the files concerned.

Backups are timestamped:

<file-name>.YYYYMMDD-HHMMSS

The backup folder is protected by restrictive permissions.

12.2. Service restart

The script uses, in order of preference:

/usr/sbin/restart-pulse-services

If this tool is unavailable, it attempts to restart the affected services individually.

12.3. Agent reconfiguration

The script can set need_reconf = 1 for all entries in xmppmaster.machines where agenttype = machine. In non-interactive mode, this action is performed by default.

This operation potentially affects the entire managed fleet.

To skip agent reconfiguration:

sudo ./medulla_itsm.py --lang fr --mode fix --no-reconf

12.4. Installer regeneration

If deactivation of the built-in inventory agent is requested, the script can regenerate the installer using:

--disable-inventory

The log for this operation is saved in:

/tmp/generate_agent.log

13. Use in non-interactive mode

The script can be used in an automated procedure with the option:

--non-interactive

Example of connecting to an external GLPI 10 in read-only mode.

sudo ./medulla_itsm.py \
  --lang fr \
  --mode fix \
  --non-interactive \
  --no-reconf \
  --url https://glpi.exemple.fr \
  --db-host 10.10.0.101 \
  --db-port 3306 \
  --db-name glpi \
  --db-user medulla_glpi \
  --api-url https://glpi.exemple.fr/apirest.php \
  --readonly true \
  --inv-forward false

If the SQL account requires a password, provide ITSM_DB_PASS in the process environment. Adjust --api-url to match the GLPI version and configuration. In read-only mode, provide the API URL and specify --inv-forward false.

13.1. Environment variables

Variable Usage
ITSM_DB_PASS GLPI SQL password.
ITSM_API_PASS API user password.
ITSM_APP_TOKEN API application token.
ITSM_USER_TOKEN API user token.
ITSM_CRYPT_KEY GLPI encryption key.

These variables prevent secrets from being passed directly in command-line arguments, which are visible, for example, in process lists.

In automated mode, the variables must be available in the environment of the process running with the necessary privileges.

13.2. Additional options

Option Function
--lang fr French interface.
--mode check Diagnostics with possible normalization of local API parameter names.
--mode fix Configuration or repair.
--non-interactive Execution without prompts.
--apply-sql In non-interactive correction mode, allow the SQL file to be applied if views are missing.
--no-reconf Do not request agent reconfiguration.
--force Proceed despite pre-check failures.
--insecure Disable TLS verification.

Security: The --insecure option is intended for temporary diagnostics only. In production, use a valid TLS certificate and a trusted certificate authority.

14. Resolve common errors

Error Possible cause Recommended action
Unable to create the federated server. Insufficient MariaDB privileges or root socket authentication unavailable. Use the fixed version of the script and check MariaDB permissions.
SQL error 2003: name not found. Incorrect or unresolved DNS name. Check the FQDN or use the IP address.
SQL error 2003: connection refused or timed out. Port is filtered, or MariaDB is not listening on the expected interface. Check the firewall and bind-address.
SQL error 1130. Unauthorized source IP address. Adjust the SQL account permissions.
SQL error 1045. Invalid credentials or unauthorized account. Check the user, their authorized host, and their password.
Missing SQL views. Medulla SQL file not applied. Apply glpi-100.sql or glpi-110.sql.
GLPI Inventory plugin missing. Plugin not installed or disabled. Check the plugins in GLPI.
MMC API client not found. API client not created. Create an API client named MMC.
API authentication denied. Incorrect token, user, profile, or IP restrictions. Check the API settings in GLPI.
API token is encrypted or hashed. Original value unavailable. Regenerate the token and enter it in the script.
Invalid TLS certificate. Unrecognized certificate authority. Install the certificate authority's certificate on Medulla.
Invalid GLPI key. Incorrect key or key from another instance. Check glpicrypt.key.
Medulla service is inactive. Configuration or startup error. Check the systemd logs.

14.1. Check MariaDB permissions

sudo mariadb -e "SELECT USER(), CURRENT_USER(), VERSION(); SHOW GRANTS FOR CURRENT_USER();"

14.2. Check Medulla services

systemctl status mmc-agent.service

To view the latest errors:

journalctl -u mmc-agent.service -n 50 --no-pager

14.3. Check for an incomplete GLPI update

If the GLPI code and the database version do not match, complete the update from the GLPI server:

php bin/console db:update

This command must be run in the appropriate context of the GLPI installation, after a backup.

15. Script exit codes

Code Meaning
0 No checks failed.
1 At least one check or apply step failed.
2 Execution interrupted or incorrect usage.
3 Check mode: no external GLPI configured.

After applying the changes, the script waits a few seconds, then performs another set of checks.

An exit code of 0 indicates that the implemented checks completed with no failures.

16. Information to provide to Medulla support

If the problem persists, provide the following:

  • The Medulla version.
  • The GLPI version.
  • The mode used: check or fix.
  • The complete diagnostic output, after removing any confidential information.
  • Any SQL or API error messages.
  • The installation context: new connection or reconfiguration.

To run a diagnostic again:

sudo ./medulla_itsm.py --lang fr --mode check

Confidentiality: Check that no SQL passwords, API passwords, tokens, or encryption keys appear in the transmitted information.

17. Summary

The medulla_itsm.py script centralizes the operations required to connect an external GLPI to Medulla.

It allows you to:

  • Prepare and check a GLPI 10 or 11 connection.
  • Diagnose SQL and API access.
  • Check permissions and SQL views.
  • Configure MariaDB federated tables.
  • Manage API tokens and the GLPI encryption key.
  • Configure inventory reporting.
  • Update the Medulla configuration files.
  • Restart the services and check that they are working properly.
  • Repair an existing configuration.

Download:

wget https://dl.medulla-tech.io/ma/medulla_itsm.py
chmod +x medulla_itsm.py

For an initial connection or a correction:

sudo ./medulla_itsm.py --lang fr --mode fix

To check an existing connection:

sudo ./medulla_itsm.py --lang fr --mode check

Key takeaway: Check mode diagnoses the connection and can correct local API parameter names. Correction mode applies the configuration after preliminary checks and prompts for confirmation in interactive mode.