Synchronization between OCS servers master/slaves

Operating principe

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

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 synchronization, you have to create a cronjob.

Configuration of management console

Inventory Files Acces

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

Inventory Files Tab

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 --remov Remove succesfuly injected files
-m --msg Show message returned my ocsinventory
-v --verbose Verbose mode
--stdin Read data from STDIN
--sslmode Enable or disable SSL (0
--cafile CA File to use for SSL Communication

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

Synchronsation of one inventory using HTTPS

perl -f MYFILE.OCS -u https://OCSmasterServer/ocsinventory -v --sslmode 1 --cafile /path/to/ca/file

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