drule.create

Description

object drule.create(object/array discoveryRules)

This method allows to create new discovery rules.

This method is only available to Admin and Super admin user types. Permissions to call the method can be revoked in user role settings. See User roles for more information.

Parameters

(object/array) Discovery rules to create.

Additionally to the standard discovery rule properties, the method accepts the following parameters.

Parameter Type Description
dchecks array Discovery checks to create for the discovery rule.

Parameter behavior:
- required

Return values

(object) Returns an object containing the IDs of the created discovery rules under the druleids property. The order of the returned IDs matches the order of the passed discovery rules.

Examples

Create a discovery rule

Create a discovery rule to find machines running the Zabbix agent in the local network. The rule must use a single Zabbix agent check on port 10050.

Request:

{
           "jsonrpc": "2.0",
           "method": "drule.create",
           "params": {
               "name": "Zabbix agent discovery",
               "iprange": "192.168.1.1-255",
               "concurrency_max": "10",
               "dchecks": [
                   {
                       "type": "9",
                       "key_": "system.uname",
                       "ports": "10050",
                       "uniq": "0"
                   }
               ]
           },
           "id": 1
       }
Copy
✔ Copied

Response:

{
           "jsonrpc": "2.0",
           "result": {
               "druleids": [
                   "6"
               ]
           },
           "id": 1
       }
Copy
✔ Copied

See also

Source

CDRule::create() in ui/include/classes/api/services/CDRule.php.

To toggle search highlight, press Ctrl+Alt+H
Have an improvement suggestion for this page? Select the text that could be improved and press Ctrl+Enter to send it to the editors.