Skip to main content

Verify access and permissions between Medulla and GLPI

Applies to: Medulla / GLPI
Medulla version: All
GLPI version: 10 / 11
Environment: On-Premise
Category: Diagnostics / GLPI Integration

Background

Medulla communicates with GLPI through several mechanisms:

  • direct access to GLPI’s MySQL/MariaDB database to retrieve the information necessary for Medulla to function;
  • Medulla-specific SQL views, created in the GLPI database;
  • federated tables (local_glpi_*) that expose certain GLPI tables to Medulla;
  • the GLPI API for certain operations and interactions with GLPI.

If you encounter issues with inventory reporting, synchronization, or accessing GLPI from Medulla, a diagnostic script can automatically check Medulla’s configuration and permissions.

The script directly uses the GLPI configuration stored on the Medulla server.
Therefore, there is no need to manually enter database login credentials or API tokens: the SQL parameters are read from the GLPI plugin configuration, and the API tokens are read from the Medulla administration database.


1. Download the diagnostic script

Log in to the Medulla server via SSH using an account with the necessary permissions, then download the script:

wget https://dl.medulla-tech.io/nc/check_itsm_access.sh

Then make the script executable:

chmod +x check_itsm_access.sh

Script version:
If you have previously downloaded the script, delete the old copy and download it again to ensure you have the latest checks (including the federated table verification).


2. Run the check

Run the script from the Medulla server:

./check_itsm_access.sh

The script automatically retrieves the GLPI connection settings configured in Medulla and performs the checks in two parts:

  • ITSM Database Access Check: checks on the GLPI database;
  • ITSM API Access Check: checks on the GLPI API.

Before starting, it verifies that the necessary tools are present (see Script prerequisites) and that the configuration file exists.


3. Checks on the GLPI database

Access to the GLPI database

The script begins by verifying that Medulla can connect to the GLPI database using the currently configured settings ([main] section of the glpi.ini.local file). If no port is specified, port 3306 is used by default.

It executes a simple SQL query to verify:

  • whether the MySQL/MariaDB server is accessible;
  • the configured port;
  • the database name;
  • the user used by Medulla;
  • the password;
  • the permissions required to query the database.

When the connection is successful, the following result is displayed:

[✓] Database connection successful

If the connection fails, the script stops immediately, as the following checks cannot be performed:

[✗] Failed to connect to database

==========================================
Database connectivity check failed!
==========================================

If this first step fails:
First check the MySQL/MariaDB credentials, the port being used, network permissions, and the permissions granted to the Medulla user on the GLPI database.


Presence of the required GLPI tables

The script then verifies that the 16 GLPI tables used by the integration are accessible:

glpi_computers
glpi_users
glpi_profiles
glpi_entities
glpi_groups
glpi_softwares
glpi_networkports
glpi_printers
glpi_monitors
glpi_peripherals
glpi_tickets
glpi_changes
glpi_problems
glpi_projects
glpi_locations
glpi_plugin_glpiinventory_collects

The glpi_plugin_glpiinventory_collects table is provided by the GLPI Inventory plugin. Its absence generally indicates that the plugin is not installed or is not enabled.

If all expected tables are accessible:

[✓] All 16 required tables found

Otherwise, the script displays a list of missing or inaccessible tables:

[✗] Missing tables: ...

Checking Medulla SQL views

Medulla also uses several specific SQL views to retrieve certain GLPI information. The script checks for the presence and accessibility of the following views:

glpi_computers_pulse
glpi_view_computers_items_printer
glpi_view_computers_items_peripheral
glpi_view_peripherals_manufacturers

If all views are accessible:

[✓] All 4 required views found

If not, the script lists the missing views and provides instructions on how to create them:

[✗] Missing views: ...

The views are created by importing the SQL script corresponding to your version of GLPI into the GLPI database:

GLPI version SQL script
GLPI 10 https://dl.medulla-tech.io/nc/glpi-100.sql
GLPI 11 https://dl.medulla-tech.io/nc/glpi-110.sql

Import example:

wget https://dl.medulla-tech.io/nc/glpi-110.sql
mysql -h <GLPI_HOST> -P <PORT> -u <USER> -p <GLPI_DATABASE> < glpi-110.sql

Creating views may require an account with higher privileges than the Medulla user (for example, the MySQL/MariaDB root account).

Caution in read-only mode:
Simply having the views is not enough. The MySQL/MariaDB user used by Medulla must also have the necessary SELECT and SHOW VIEW permissions.

Refer to the documentation on configuring GLPI access to determine the required permissions:

https://docs.medulla-tech.io/books/medulla-faq-u6w/page/glpi-connecting-an-external-glpi


Checking federated tables

Medulla relies on federated tables that expose certain GLPI tables via MariaDB’s FEDERATED engine. The script checks for the presence of the following 7 tables:

Federated table GLPI source table
local_glpi_configs glpi_configs
local_glpi_entities glpi_entities
local_glpi_filters glpi_computers
local_glpi_items_softwareversions glpi_items_softwareversions
local_glpi_machines glpi_computers
local_glpi_softwares glpi_softwares
local_glpi_softwareversions glpi_softwareversions

If all federated tables are present:

[✓] All 7 required federated tables found

Otherwise:

[✗] Missing federated tables: ...

The script then displays the SQL queries needed to declare the federated server itsm_federated and create the missing tables, pre-populated with the configured connection settings. For reference, these queries are as follows:

CREATE OR REPLACE SERVER itsm_federated FOREIGN DATA WRAPPER 'mariadb'
  OPTIONS ( HOST "<GLPI_HOST>", PORT "<PORT>", USER '<USER>', PASSWORD '<PASSWORD>', DATABASE '<GLPI_DATABASE>' );

CREATE OR REPLACE TABLE `local_glpi_configs` (`id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(150) DEFAULT NULL, `value` text DEFAULT NULL, PRIMARY KEY (`id`)) ENGINE=FEDERATED DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci CONNECTION='itsm_federated/glpi_configs';

CREATE OR REPLACE TABLE `local_glpi_machines` (`id` int NOT NULL, primary key(id), `entities_id` int(10) NOT NULL DEFAULT 0, `name` varchar(255) NULL DEFAULT NULL, `is_template` tinyint(4) NOT NULL DEFAULT 0, `is_deleted` tinyint(4) NOT NULL DEFAULT 0) ENGINE=FEDERATED DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci CONNECTION='itsm_federated/glpi_computers';

CREATE OR REPLACE TABLE `local_glpi_filters` (`id` int NOT NULL, primary key(id), `states_id` int(10) NOT NULL DEFAULT 0, `entities_id` int(10) NOT NULL DEFAULT 0, `computertypes_id` int(10) NOT NULL DEFAULT 0, `autoupdatesystems_id` int(10) NOT NULL DEFAULT 0) ENGINE=FEDERATED DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci CONNECTION='itsm_federated/glpi_computers';

CREATE OR REPLACE TABLE `local_glpi_items_softwareversions` (`id` int NOT NULL, primary key(id), `items_id` int NOT NULL DEFAULT 0, `itemtype` varchar(100) NOT NULL, `softwareversions_id` int NOT NULL DEFAULT 0) ENGINE=FEDERATED DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci CONNECTION='itsm_federated/glpi_items_softwareversions';

CREATE OR REPLACE TABLE `local_glpi_softwareversions` (`id` int NOT NULL, primary key(id), `softwares_id` int NOT NULL DEFAULT 0, `name` varchar(255) DEFAULT NULL, `comment` text DEFAULT NULL) ENGINE=FEDERATED DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci CONNECTION='itsm_federated/glpi_softwareversions';

CREATE OR REPLACE TABLE `local_glpi_softwares` (`id` int NOT NULL, primary key(id), `name` varchar(255) NULL DEFAULT NULL, `comment` text NULL DEFAULT NULL) ENGINE=FEDERATED DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci CONNECTION='itsm_federated/glpi_softwares';

CREATE OR REPLACE TABLE `local_glpi_entities` (`id` int(10) unsigned NOT NULL DEFAULT 0, PRIMARY KEY (`id`), `completename` text DEFAULT NULL, `name` varchar(255) DEFAULT NULL) ENGINE=FEDERATED DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci CONNECTION='itsm_federated/glpi_entities';

Prerequisites:
The FEDERATED engine must be available and enabled on the MariaDB server. Declaring the federated server and creating the tables may require the MySQL/MariaDB root account.


4. Checks on the GLPI API

Once the SQL checks are complete, the script automatically tests access to the GLPI API configured in Medulla.

Loading the API configuration

The script retrieves:

  • the API URL, GLPI username, and password from the [webservices] section of the /etc/mmc/plugins/glpi.ini.local file (glpi_base_url, glpi_username, and glpi_password parameters);
  • the tokens from the saas_application table in Medulla’s admin database, using the credentials from the /etc/mmc/plugins/admin.ini.local file:
    • glpi_mmc_app_token: App-Token of the API client used by Medulla;
    • glpi_root_user_token: GLPI user_token;
    • glpi_crypt_key: GLPI encryption key.

If any of these three items is missing from the database, the script stops:

[✗] Failed to load ITSM API configuration. Missing required tokens or crypt key in database.

Caution:
In this case, the script displays the retrieved values for ITSM_APP_TOKEN, ITSM_USER_TOKEN, and ITSM_CRYPT_KEY in plain text. Mask them before transmitting them.

API server accessibility

The first test verifies that the GLPI API URL is accessible from the Medulla server (10-second timeout).

If the server is reachable:

[✓] API server reachable at ...

If the test fails, the script stops, as the authentication tests cannot be performed:

[✗] Cannot reach API server at ...

==========================================
API connectivity check failed!
==========================================

If the test fails:
Check the configured URL, DNS resolution, network flows, firewall rules, and the availability of the GLPI server.


Authentication with GLPI credentials

The script then attempts to open a GLPI API session (initSession) using the username and password configured in Medulla, associated with the App-Token.

When authentication succeeds:

[✓] Credential authentication successful

Otherwise, the script displays the HTTP status code returned by GLPI and provides a curl command to perform further diagnostics (the password is masked in the command):

[✗] Credential auth failed with HTTP status ...

Token-based authentication

Finally, the script performs a second authentication test using:

  • the GLPI user_token;
  • the API client’s app_token used by Medulla.

If the tokens are valid:

[✓] Token authentication successful

Otherwise:

[✗] Token auth failed with HTTP status ...

The script also provides a diagnostic curl command (the user_token is masked in it).


5. Interpret the result

The script performs a total of 7 checks. If all are valid, it concludes with:

==========================================
All checks passed! (7 checks)
==========================================

Communication between Medulla and GLPI is then functional for the elements tested by the script.

If one or more checks fail, the script displays the number of failed and successful checks:

==========================================
Some checks failed! (Failed: X, Passed: Y)
==========================================

Lines preceded by [✗] identify the check(s) that failed.

Error Item to check
Missing required tools Installation of crudini, mysql, and curl on the Medulla server
Configuration file not found / not readable Existence and read permissions for /etc/mmc/plugins/glpi.ini.local (run the script with an account that has sufficient privileges)
Failed to load database configuration dbhost, dbuser, and dbname parameters in the [main] section of glpi.ini.local
Failed to connect to database Network access, SQL port, user, password, and MySQL/MariaDB permissions
Missing tables GLPI version/structure, installation of the GLPI Inventory plugin, and read permissions on the relevant tables
Missing views Import of the SQL script for Medulla views (GLPI 10 or 11) and SELECT/SHOW VIEW permissions
Missing federated tables FEDERATED engine enabled, itsm_federated federated server declared, and local_glpi_* tables created
Failed to load ITSM API configuration admin.ini.local file and the glpi_mmc_app_token, glpi_root_user_token, and glpi_crypt_key values from the saas_application table
Cannot reach API server GLPI URL, DNS, routing, firewall, and server availability
Credential auth failed GLPI user, password, and app_token
Token auth failed user_token, app_token, and GLPI API configuration

6. Script prerequisites

The script uses the following tools on the Medulla server:

  • crudini
  • mysql
  • curl

It automatically checks for their presence before starting the tests.

It uses the Medulla configuration located in:

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

as well as the saas_application table in Medulla’s admin database, where the API tokens and the GLPI encryption key are stored.


7. If you encounter a problem

If the script reports an error, correct the indicated issue and then simply rerun it:

./check_itsm_access.sh

If the problem persists, send the complete script output to Medulla support to facilitate troubleshooting.

Security:
Some of the script’s output contains secrets in plain text, including:

  • the SQL view import command (MySQL/MariaDB password);
  • the query to create the federated server itsm_federated (MySQL/MariaDB password);
  • the token and encryption key values if the API configuration fails to load;
  • the App-Token in the diagnostic curl commands.

Before transmitting results or diagnostic commands, always mask any passwords, API tokens, or other authentication secrets.


Additional documentation

For the initial configuration of MySQL/MariaDB permissions, SQL views, and the GLPI API, refer to the FAQ on connecting an external GLPI:

https://docs.medulla-tech.io/books/medulla-faq-u6w/page/glpi-connecting-an-external-glpi

SQL scripts for creating Medulla views:

Diagnostic script:

https://dl.medulla-tech.io/nc/check_itsm_access.sh