You are browsing the documentation for iTop 2.6 which is not the current version.

Consider browsing to iTop 3.2 documentation

REST/CLI services

  • cron.php: the heartbeat of iTop, enables some features like asynchronous emails
  • synchro_exec.php: trigger the synchronization of a list of data sources
  • synchro_import.php: in one single operation, import data and trigger the synchronization process
  • import.php: import data from CSV files
  • export.php: export data in various formats

How to call them

The import, export and data synchronization pages can be run either as REST web services or from the Command-Line Interface (CLI). Since the CLI mode can only be used by scripts running on the iTop server itself it is considered as safer and generally runs with less limitations compared to the web pages (on most system the CLI mode has its own php.ini configuration). For example:

  • CLI mode can benefit from longer timeout or no timeout at all (useful for running big imports)
  • The memory_limit setting may be set to a bigger value for PHP scripts running in CLI mode.

In CLI mode, the arguments to iTop pages are always given with the prefix -- (two consecutive hyphens).

Example (on Windows):

php.exe -q c:\inetpub\itop\synchro\synchro_exec.php --auth_user=john --auth_pwd=trust,no1

Same example (on Linux):

php -q /var/www/itop/synchro/synchro_exec.php --auth_user=john --auth_pwd=trust,no1

or, even better, using a parameters file:

php -q /var/www/itop/synchro/synchro_exec.php --param_file=/etc/itop/params.foo
On some Linux systems the PHP command-line interface must be installed as a separate package (called php-cli or php5-cli). To check if the PHP CLI is installed (and available in the path) on your system simply type which php from the command prompt.

Why and how to use a parameters file

For security reasons it is always better to avoid passing credentials (user names and passwords) on the command line (the command lines corresponding to the processes running on the system are generally visible to all users logged-in). iTop offers the alternative to pass all command-line parameters inside a file, called the “parameters file” via the argument param_file . This argument can be used with most of the REST/CLI web services, it must contain the path to a parameters file.

Make sure that the parameters file is readable by the process that will run the PHP page, and that it cannot be accessed through the web server.

A parameters file contains key/value pairs and always uses the same format. It can be commented: any character found after # on a given line will be ignored

When a parameter is specified both in the param file and as a command-line argument, the value given on the command line has precedence.

Example:

params
# This is a parameter file
#
# If a parameter is given both in the file and in the arguments,
# then the value given as argument is retained
#
 
# Authentication
auth_user = qwertyuiop
auth_pwd = ded!catedL0g1n
 
# My web service
size_min = 20 # Megabytes
time_limit = 40 # Minutes
2_6_0/advancedtopics/rest_cli.txt · Last modified: 2020/02/05 11:42 by 127.0.0.1
Back to top
Contact us