Skip to content

ocsinventoryng plugin ocsng_fullsync script not work with glpi docker #398

@jackchuong

Description

@jackchuong

Hi all,
I'm trying to use glpi 11.0.6 docker with ocsinventoryng plugin , here my environment:
Ubuntu 22.04.2 LTS
Docker version 24.0.5, build ced0996
I have nginx proxy container in front of glpi service
My glpi docker-compose.yml (follow documentation at https://hub.docker.com/r/glpi/glpi)

version: '3'

services:
  glpi-server:
    image: glpi/glpi:11.0.6
    container_name: glpi-server
    environment:
      - TZ=Asia/Ho_Chi_Minh
    env_file:
      - .env
    volumes:
      - "./glpi-data:/var/glpi:rw"
      - "./php.ini:/usr/local/etc/php/conf.d/custom-config.ini:ro"
    #ports:
    #  - 80:80
    #  - 443:443
    restart: always
    networks:
      - glpinet
      - proxynet

  glpi-mysql:
    image: mysql:8.0.26
    container_name: glpi-mysql
    environment:
      - TZ=Asia/Ho_Chi_Minh
    env_file:
      - .env
    # ports:
    #   - 3306:3306
    volumes:
      - ./my.cnf:/etc/mysql/my.cnf
      - ./mysqldata:/var/lib/mysql
      #- ./dbscripts:/docker-entrypoint-initdb.d
    restart: always
    networks:
      - glpinet

networks:
  glpinet:
    name: glpinet
  proxynet:
    external: true

glpi containers started and running ok
I go to glpi web UI and install ocsinventoryng plugin 2.1.11 via marketplace
I configured ocsinventoryng plugin connecting to ocs mysql service successfully , I can import computers from ocs to glpi manually.
However , computers from ocs are not imported to glpi automatically.
I attempt to run ocsng_fullsync,php script inside glpi-server container to see if it works.

docker exec -it glpi-server bash
cd /var/glpi/marketplace/ocsinventoryng/public/scripts
www-data@7f3e44a280e9:/var/glpi/marketplace/ocsinventoryng/public/scripts$ php ocsng_fullsync.php
PHP Warning:  require_once(../../../../src/Glpi/Application/ResourcesChecker.php): Failed to open stream: No such file or directory in /var/glpi/marketplace/ocsinventoryng/public/scripts/ocsng_fullsync.php on line 40
PHP Fatal error:  Uncaught Error: Failed opening required '../../../../src/Glpi/Application/ResourcesChecker.php' (include_path='.:/usr/local/lib/php') in /var/glpi/marketplace/ocsinventoryng/public/scripts/ocsng_fullsync.php:40
Stack trace:
#0 {main}
  thrown in /var/glpi/marketplace/ocsinventoryng/public/scripts/ocsng_fullsync.php on line 40

I can find file /var/www/glpi/src/Glpi/Application/ResourcesChecker.php , but ocsng_fullsync.php is trying to find at /var/glpi ???

I tried to add GLPI_DIR_ROOT="/var/www/glpi" env into glpi-server container

root@5d57e8a1f8db:/var/glpi/marketplace/ocsinventoryng/public/scripts# export | grep DIR
declare -x APACHE_CONFDIR="/etc/apache2"
declare -x GLPI_CONFIG_DIR="/var/glpi/config"
declare -x GLPI_DIR_ROOT="/var/www/glpi"
declare -x GLPI_LOG_DIR="/var/glpi/logs"
declare -x GLPI_MARKETPLACE_DIR="/var/glpi/marketplace"
declare -x GLPI_VAR_DIR="/var/glpi/files"
declare -x PHP_INI_DIR="/usr/local/etc/php"

But it still not works.

I edited ocsng_fullsync.php
define("GLPI_DIR_ROOT", "../../../.."); --> define("GLPI_DIR_ROOT", "/var/www/glpi");

Then run ocsng_fullsync.php again

root@5d57e8a1f8db:/var/glpi/marketplace/ocsinventoryng/public/scripts# php ocsng_fullsync.php
RuntimeException {#189
  #message: "MySQL query error: Out of range value for column 'threadid' at row 1 (1264) in SQL query "INSERT INTO `glpi_plugin_ocsinventoryng_threads` (`start_time`, `threadid`, `status`, `plugin_ocsinventoryng_ocsservers_id`, `imported_machines_number`, `synchronized_machines_number`, `not_unique_machines_number`, `failed_rules_machines_number`, `notupdated_machines_number`, `linked_machines_number`, `link_refused_machines_number`, `total_number_machines`, `error_msg`) VALUES ('2026-03-11 09:30:58', '-1', '1', '0', '0', '0', '0', '0', '0', '0', '0', '0', '')"."
  #code: 0
  #file: "/var/www/glpi/src/DBmysql.php"
  #line: 416
  trace: {
    /var/www/glpi/src/DBmysql.php:416 {
      DBmysql->doQuery($query)^
      › if (!$res) {
      ›     throw new RuntimeException(
      ›         sprintf(
    }
    /var/www/glpi/src/DBmysql.php:1377 { …}
    /var/www/glpi/src/CommonDBTM.php:778 { …}
    /var/www/glpi/src/CommonDBTM.php:1382 { …}
    /var/glpi/marketplace/ocsinventoryng/public/scripts/ocsng_fullsync.php:178 { …}
  }

It inserted "-1" value into column 'threadid' , which failed , because column 'threadid' type is int unsigned

mysql> describe `glpi`.`glpi_plugin_ocsinventoryng_threads`;
+-------------------------------------+--------------+------+-----+---------+----------------+
| Field                               | Type         | Null | Key | Default | Extra          |
+-------------------------------------+--------------+------+-----+---------+----------------+
| id                                  | int unsigned | NO   | PRI | NULL    | auto_increment |
| threadid                            | int unsigned | NO   |     | 0       |                |
| start_time                          | timestamp    | YES  |     | NULL    |                |
| end_time                            | timestamp    | YES  | MUL | NULL    |                |
| status                              | int unsigned | NO   |     | 0       |                |
| error_msg                           | text         | NO   |     | NULL    |                |
| imported_machines_number            | int unsigned | NO   |     | 0       |                |
| synchronized_machines_number        | int unsigned | NO   |     | 0       |                |
| failed_rules_machines_number        | int unsigned | NO   |     | 0       |                |
| linked_machines_number              | int unsigned | NO   |     | 0       |                |
| notupdated_machines_number          | int unsigned | NO   |     | 0       |                |
| not_unique_machines_number          | int unsigned | NO   |     | 0       |                |
| link_refused_machines_number        | int unsigned | NO   |     | 0       |                |
| total_number_machines               | int unsigned | NO   |     | 0       |                |
| plugin_ocsinventoryng_ocsservers_id | int unsigned | NO   |     | 1       |                |
| processid                           | int unsigned | NO   | MUL | 0       |                |
| entities_id                         | int unsigned | NO   |     | 0       |                |
| rules_id                            | int unsigned | NO   |     | 0       |                |
+-------------------------------------+--------------+------+-----+---------+----------------+
18 rows in set (0.00 sec)

How can I fix this issue ? Please give me some advice , thank you very much

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