From OCS Inventory NG
Jump to: navigation, search

Synchronisation between OCS servers master/slaves

Operating principe

Since 1.02 release, you can use the OCS_OPT_GENERATE_OCS_FILES server parameter to automatically generate these files to "inject" it to a higher level server. (in case of multi entities configuration for example).

In that case, you can use a cronjob if the two servers are connected, or put it on the higher level server and run it on loopback.

Warning: This feature just allows you to "inject" inventories into a higher level server. It will be impossible to deploy packages from the highest server.

Simplified Diagram


Prerequires is a script designed to send inventory to an OCS server using .ocs files generated by -local (or /local for windows). You must have a writable directory to store .ocs files. If you want to automate this synchronisation, you have to create a cronjob.

Configuration of management console

To configure this feature, click on Configuration icon, and Config. Then, click on Inventory Files tab.

En configure injector.jpg

Warning: Don't forget to create the directory with writable rights.

Server configuration

The configuration file is in


You can verify values here


  # Use with ocsinventory-injector, enable the multi entities feature
  # Generate either compressed file or clear XML text
  # Specify if you want to keep trace of all inventory between to synchronisation with the higher level server
  # Path to ocs files directory (must be writeable)
  PerlSetEnv OCS_OPT_OCS_FILES_PATH /home/ocs

Warning: Values in database (GUI) take precedence over the configuration file, that's why you have to use web interface to configure this feature.

Command line options

Options Complete options Meaning
-h --help Command line options
-d --directory Load every .ocs files from a directory
-f --file Load a speficic file
-u --url Ocsinventory backend URL, default is http://ocsinventory-ng/ocsinventory
--useragent HTTP user agent, default is OCS-NG_LOCAL_PL_v".VERSION."
-r --remove Remove succesfuly injected files
-m --msg Show message returned my ocsinventory
-v --verbose Verbose mode
--stdin Read data from STDIN

Note: You can specify a --file or a --directory or STDIN. Current directory is the default


Synchronsation of one inventory

perl  -v -f myInventory.ocs  -u http://OCSmasterServer/ocsinventory

Synchronsation of all inventories in a specific directory

perl  -v -r -d /my/specific/directory -u http://OCSmasterServer/ocsinventory

Cron job

You can "inject" inventories automaticaly with a new entry in your crontab :

##### Every 5 minutes ----- execution of OCS injector 
*/5  * * * *   root    perl /usr/src/OCSNG_UNIX_SERVER-1.3.3/binutils/ -v -r -d /home/ocs -u http://OCSmasterServer/ocsinventory