The Mass_ocs_import plugin

This extension works from version 0.70 of GLPI or greater. Its purpose is to allow the addition and synchronization machines for OCS Inventory.

The extension is composed of:

  • a script for Linux that allows to run the script from the command line or via cron. It gives the ability to run several processes to complete the treatment.
  • a script for Windows to run from the command line or put in a scheduled task. On this platform, the script can not run a single process for treatment.
  • a graphical interface that allows the execution of all scripts. It provides information on imported machines, synchronized, linked and not imported.


  1. On Linux, the package “php-cli or php5-cli” must be installed
  2. Copy the files in the plugins directory of GLPI.
  3. Changing the owner of all files and directories to the apache user
  4. Make executable scripts in the scripts directory
  5. Log into GLPI
  6. In the Setup menu “Plugins click Import mass OCS
  7. Click Install the plugin
  8. Configuration Mode OCSNG “OCS Server '” Number of items to synchronize via cron to “0”

Configuring the plugin

The extension has several configuration options:

  • Enable traces recorded in the data base on the execution of scripts
  • Updated information all machines xx: indicates the frequency of recording data to execute a script (eg 3 indicates that the process will save the information on all 3 machines)
  • Show processes where nothing has been changed: yes even if the process did not change are displayed in the list.
  • Clear process after xx hours: indicates the number of hours during which data from a script are stored in base. (default 2)
  • Delete empty process after xx hours: indicates the number of hours during which data from a script that did nothing in the Treaty are kept basic. (Caution! Default 0 to keep all the empty process indefinitely)
  • Number of seconds to refresh the page (not refreshrate 0): indicates the frequency in seconds to refresh the detail page of a script is refreshed. If the value is 0, the page is not redisplayed.
  • Maximum number of machines imported by thread (0 no limit): You can voluntarily limit the maximum number of machines that will be processed by a script. If the value is 0, then no limit is put in place
  • OCS server by default shows the OCS server on which the script will synchronize.
  • If not prevent machinery imported complete explanation
  • Number of machines: complete explanation

You can manually disable synchronization by clicking the button “Enable lock. In this case, a file lock is placed on the file system. This prevents the script to start synchronization. This option allows you to temporarily stop the synchronization process for a SCO Update GLPI for example.


The synchronization script adapted to the platform, is launched by hand and / or via a scheduled task or a crontab

Scripts are available in the GLPI/scripts directory.

  • On Linux the script is run with one of the commands:
sh - thread_nbr = [number of threads to run] - server_id = [ID server OCS]


php run.php - thread_nbr = [number of threads to run] - server_id = [ID server OCS]
  • Under Windows the script is run with the command
php run.php - thread_nbr = [number of threads to run] - server_id = [ID server OCS]

If the command php is not in a folder in your PATH, edit and use the run.bat fileinformingthe correct paths:

SET path_php = 'C: OCSNGxamppphp'

SET plugin_glpi = 'C: OCSNGxampphtdocsglpipluginsmass_ocs_importscripts'

It is possible to track the execution of scripts. The interface is accessible from the menu Plugins» Import mass OCS.

Launch via cron

Add the script in the crontab of your apache user (www-data for debian):

* / 5 * * * * / var / www / glpi / plugins / mass_ocs_import / scripts / - thread_nbr = 2 - server_id = 1

for example, to run the script every 5 minutes

For Debian / Ubuntu, if the cron job above does not work, try:

 * / 5 * * * * php / var / www / glpi / plugins / mass_ocs_import / scripts / run.php - thread_nbr = 2 - server_id = 1

Interface tracking script executions

The first tab shows a list of all the scripts launched. For each of them, a summary of actions is presented. By clicking on the login script opens a 3rd tab that displays the details of all transactions, thread by thread. Visualization interface machines not imported

The second tab displays the list of machines that have been imported from OCS. Some information from the OCS inventory are displayed to help identify problems. For machines in this tab, you can perform a manual import. It suffices for this, select the computers and the destination entity. Then press “Import” and import occurs.