Skip to main content

3CX Rest API

Compatibility​

This connector is designed to be compatible with the following products.

ProductModelVersions
3CX-20.0.0.1620

3CX Version 18 is no longer supported and should be upgraded to Version 20.

Pack assets​

Templates​

The Monitoring Connector 3CX Rest API brings a host template:

  • App-VoIP-3cx-Restapi-custom

The connector brings the following service templates (sorted by the host template they are attached to):

Service AliasService TemplateService Description
SystemApp-Voip-3cx-System-Restapi-customCheck system health

The services listed above are created automatically when the App-VoIP-3cx-Restapi-custom host template is used.

Collected metrics & status​

Here is the list of services for this connector, detailing all metrics linked to each service.

Metric nameUnit
system.calls.active.usage.countcount
system.calls.active.free.countcount
system.calls.active.usage.percentage%
system.extensions.registered.countcount
service#statusN/A

Prerequisites​

Depending on the type of administrator account you use, you'll find the necessary instructions in the 3CX's official documentation[FR].

Installing the monitoring connector​

Pack​

The installation procedures for monitoring connectors are slightly different depending on whether your license is offline or online.

  1. If the platform uses an online license, you can skip the package installation instruction below as it is not required to have the connector displayed within the Configuration > Connectors > Monitoring Connectors menu. If the platform uses an offline license, install the package on the central server with the command corresponding to the operating system's package manager:
dnf install centreon-pack-applications-voip-3cx-restapi
  1. Whatever the license type (online or offline), install the 3CX Rest API connector through the Configuration > Connectors > Monitoring Connectors menu.

Plugin​

Since Centreon 22.04, you can benefit from the 'Automatic plugin installation' feature. When this feature is enabled, you can skip the installation part below.

You still have to manually install the plugin on the poller(s) when:

  • Automatic plugin installation is turned off
  • You want to run a discovery job from a poller that doesn't monitor any resource of this kind yet

More information in the Installing the plugin section.

Use the commands below according to your operating system's package manager:

dnf install centreon-plugin-Applications-Voip-3cx-Restapi

Using the monitoring connector​

Using a host template provided by the connector​

  1. Log into Centreon and add a new host through Configuration > Hosts.
  2. Fill in the Name, Alias & IP Address/DNS fields according to your resource's settings.
  3. Apply the App-VoIP-3cx-Restapi-custom template to the host. A list of macros appears. Macros allow you to define how the connector will connect to the resource, and to customize the connector's behavior.
  4. Fill in the macros you want. Some macros are mandatory.
MacroDescriptionDefault valueMandatory
3CXUSERNAMEDefine the username for authenticationUSERLOGINX
3CXPASSWORDDefine the password associated with the usernameUSERPASSWORDX
3CXPROTODefine the protocol to reach the API (default: 'https')https
3CXPORTDefine the port to connect to (default: '443')443
3CX_AUTH_MODEDefine the authentication mode. oauth2: for 3CX Enterprise edition. Uses OAuth2 client_credentials flow via POST /connect/token. Requires an API client created in 3CX admin console (/#/office/integrations/api). The API client must have at least the 'Admin' role. login: for 3CX Pro edition. Uses username/password login via POST /webclient/api/Login/GetAccessToken. Requires a System Owner account with 2FA disabled. IMPORTANT: The poller IP must be whitelisted in 3CX admin console under Security > Console Restrictions > Allow access from specific IP addresses. Without this, 3CX returns a degraded token causing 403 errors on all API endpointsoauth2
3CXEXTRAOPTIONSAny extra option you may want to add to every command (a --verbose flag for example). All options are listed here.
  1. Deploy the configuration. The host appears in the list of hosts, and on the Resources Status page. The command that is sent by the connector is displayed in the details panel of the host: it shows the values of the macros.

Using a service template provided by the connector​

  1. If you have used a host template and checked Create Services linked to the Template too, the services linked to the template have been created automatically, using the corresponding service templates. Otherwise, create manually the services you want and apply a service template to them.
  2. Fill in the macros you want (e.g. to change the thresholds for the alerts). Some macros are mandatory (see the table below).
MacroDescriptionValeur par défautObligatoire
DND_PROFILE_NAMEName of the profile to consider as DND (Do Not Disturb). Default: DND. In 3CX version 20, the DND boolean field no longer exists. DND status is derived from the CurrentProfileName field. Use this option to specify the exact profile name configured in your 3CX instance for DND. Example: --dnd-profile-name='Do not disturb'DND
INCLUDE_EXTENSIONFilter extension (by number, first name or last name)
EXCLUDE_EXTENSIONExclude extension (by number, first name or last name)
WARNING_COUNTThreshold for extensions count
CRITICAL_COUNTThreshold for extensions count
WARNING_STATUSDefine the conditions to match for the status to be WARNING. You can use the following variables: extension, registered, dnd, profile, status, duration
CRITICAL_STATUSDefine the conditions to match for the status to be CRITICAL. You can use the following variables: extension, registered, dnd, profile, status, duration
EXTRA_OPTIONSAny extra option you may want to add to the command (a --verbose flag for example). Toutes les options sont listées ici.
  1. Deploy the configuration. The service appears in the list of services, and on the Resources Status page. The command that is sent by the connector is displayed in the details panel of the service: it shows the values of the macros.

How to check in the CLI that the configuration is OK and what are the main options for?​

Once the plugin is installed, log into your Centreon poller's CLI using the centreon-engine user account (su - centreon-engine). Test that the connector is able to monitor a resource using a command like this one (replace the sample values by yours):

/usr/lib/centreon/plugins/centreon_3cx_restapi.pl \
--plugin=apps::voip::3cx::restapi::plugin \
--mode=system \
--hostname='10.0.0.1' \
--port='443' \
--proto='https' \
--api-username='USERLOGIN' \
--api-password='USERPASSWORD' \
--auth-mode='' \
--unknown-status='' \
--warning-status='' \
--critical-status='%\{error\} =~ /true/' \
--warning-calls-active-usage='' \
--critical-calls-active-usage='' \
--warning-calls-active-free='' \
--critical-calls-active-free='' \
--warning-calls-active-usage-prct='' \
--critical-calls-active-usage-prct='' \
--warning-extensions-registered='' \
--critical-extensions-registered=''

The expected command output is shown below:

OK: extensions registered: 70 All services are ok | 'system.calls.active.usage.count'=63;;;0;1000 'system.calls.active.free.count'=53;;;0;1000 'system.calls.active.usage.percentage'=44%;;;0;1000 'system.extensions.registered.count'=70;;;0;70

Troubleshooting​

Please find the troubleshooting documentation for the API-based plugins in this chapter.

Available modes​

In most cases, a mode corresponds to a service template. The mode appears in the execution command for the connector. In the Centreon interface, you don't need to specify a mode explicitly: its use is implied when you apply a service template. However, you will need to specify the correct mode for the template if you want to test the execution command for the connector in your terminal.

All available modes can be displayed by adding the --list-mode parameter to the command:

/usr/lib/centreon/plugins/centreon_3cx_restapi.pl \
--plugin=apps::voip::3cx::restapi::plugin \
--list-mode

The plugin brings the following modes:

ModeLinked service template
extension [code]App-Voip-3cx-Extension-Restapi-custom
license [code]App-Voip-3cx-License-Restapi-custom
system [code]App-Voip-3cx-System-Restapi-custom

Available options​

Modes options​

All available options for each service template are listed below:

OptionDescription
--include-extensionFilter extension (by number, first name or last name).
--exclude-extensionExclude extension (by number, first name or last name).
--dnd-profile-nameName of the profile to consider as DND (Do Not Disturb). Default: DND. In 3CX version 20, the DND boolean field no longer exists. DND status is derived from the CurrentProfileName field. Use this option to specify the exact profile name configured in your 3CX instance for DND. Example: --dnd-profile-name='Do not disturb'
--unknown-statusDefine the conditions to match for the status to be UNKNOWN. You can use the following variables: extension, registered, dnd, profile, status, duration
--warning-statusDefine the conditions to match for the status to be WARNING. You can use the following variables: extension, registered, dnd, profile, status, duration
--critical-statusDefine the conditions to match for the status to be CRITICAL. You can use the following variables: extension, registered, dnd, profile, status, duration
--warning-countThreshold for extensions count.
--critical-countThreshold for extensions count.

All available options for a given mode can be displayed by adding the --help parameter to the command:

/usr/lib/centreon/plugins/centreon_3cx_restapi.pl \
--plugin=apps::voip::3cx::restapi::plugin \
--mode=system \
--help