drule.create

Description

object drule.create(object/array **discoveryRules**)

This method allows to create new discovery rules.

Parameters

(object/array) Discovery rules to create.

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

ParameterTypeDescription
dchecks
(required)
arrayDiscovery checks to create for the discovery rule.

Return values

(object) Returns an object containing the IDs of the created discrovery rules under the druleids property. The order of the returned IDs matches the order of the passed discrovery 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:

  1. {
  2. "jsonrpc": "2.0",
  3. "method": "drule.create",
  4. "params": {
  5. "name": "Zabbix agent discovery",
  6. "iprange": "192.168.1.1-255",
  7. "dchecks": [
  8. {
  9. "type": "9",
  10. "key_": "system.uname",
  11. "ports": "10050",
  12. "uniq": "0"
  13. }
  14. ]
  15. },
  16. "auth": "038e1d7b1735c6a5436ee9eae095879e",
  17. "id": 1
  18. }

Response:

  1. {
  2. "jsonrpc": "2.0",
  3. "result": {
  4. "druleids": [
  5. "6"
  6. ]
  7. },
  8. "id": 1
  9. }

See also

Source

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