drule.get

Description

integer/array drule.get(object **parameters**)

The method allows to retrieve discovery rules according to the given parameters.

This method is available to users of any type. Permissions to call the method can be revoked in user role settings. See User roles for more information.

Parameters

(object) Parameters defining the desired output.

The method supports the following parameters.

ParameterTypeDescription
dhostidsstring/arrayReturn only discovery rules that created the given discovered hosts.
druleidsstring/arrayReturn only discovery rules with the given IDs.
dserviceidsstring/arrayReturn only discovery rules that created the given discovered services.
selectDChecksqueryReturn a dchecks property with the discovery checks used by the discovery rule.

Supports count.
selectDHostsqueryReturn a dhosts property with the discovered hosts created by the discovery rule.

Supports count.
limitSelectsintegerLimits the number of records returned by subselects.

Applies to the following subselects:
selectDChecks - results will be sorted by dcheckid;
selectDHosts - results will be sorted by dhostsid.
sortfieldstring/arraySort the result by the given properties.

Possible values are: druleid and name.
countOutputbooleanThese parameters being common for all get methods are described in detail in the reference commentary.
editableboolean
excludeSearchboolean
filterobject
limitinteger
outputquery
preservekeysboolean
searchobject
searchByAnyboolean
searchWildcardsEnabledboolean
sortorderstring/array
startSearchboolean

Return values

(integer/array) Returns either:

  • an array of objects;

  • the count of retrieved objects, if the countOutput parameter has been used.

Examples

Retrieve all discovery rules

Retrieve all configured discovery rules and the discovery checks they use.

Request:

  1. {
  2. "jsonrpc": "2.0",
  3. "method": "drule.get",
  4. "params": {
  5. "output": "extend",
  6. "selectDChecks": "extend"
  7. },
  8. "auth": "038e1d7b1735c6a5436ee9eae095879e",
  9. "id": 1
  10. }

Response:

  1. {
  2. "jsonrpc": "2.0",
  3. "result": [
  4. {
  5. "druleid": "2",
  6. "proxy_hostid": "0",
  7. "name": "Local network",
  8. "iprange": "192.168.3.1-255",
  9. "delay": "5s",
  10. "nextcheck": "1348754327",
  11. "status": "0",
  12. "dchecks": [
  13. {
  14. "dcheckid": "7",
  15. "druleid": "2",
  16. "type": "3",
  17. "key_": "",
  18. "snmp_community": "",
  19. "ports": "21",
  20. "snmpv3_securityname": "",
  21. "snmpv3_securitylevel": "0",
  22. "snmpv3_authpassphrase": "",
  23. "snmpv3_privpassphrase": "",
  24. "uniq": "0",
  25. "snmpv3_authprotocol": "0",
  26. "snmpv3_privprotocol": "0",
  27. "host_source": "1",
  28. "name_source": "0"
  29. },
  30. {
  31. "dcheckid": "8",
  32. "druleid": "2",
  33. "type": "4",
  34. "key_": "",
  35. "snmp_community": "",
  36. "ports": "80",
  37. "snmpv3_securityname": "",
  38. "snmpv3_securitylevel": "0",
  39. "snmpv3_authpassphrase": "",
  40. "snmpv3_privpassphrase": "",
  41. "uniq": "0",
  42. "snmpv3_authprotocol": "0",
  43. "snmpv3_privprotocol": "0",
  44. "host_source": "1",
  45. "name_source": "0"
  46. }
  47. ]
  48. },
  49. {
  50. "druleid": "6",
  51. "proxy_hostid": "0",
  52. "name": "Zabbix agent discovery",
  53. "iprange": "192.168.1.1-255",
  54. "delay": "1h",
  55. "nextcheck": "0",
  56. "status": "0",
  57. "dchecks": [
  58. {
  59. "dcheckid": "10",
  60. "druleid": "6",
  61. "type": "9",
  62. "key_": "system.uname",
  63. "snmp_community": "",
  64. "ports": "10050",
  65. "snmpv3_securityname": "",
  66. "snmpv3_securitylevel": "0",
  67. "snmpv3_authpassphrase": "",
  68. "snmpv3_privpassphrase": "",
  69. "uniq": "0",
  70. "snmpv3_authprotocol": "0",
  71. "snmpv3_privprotocol": "0",
  72. "host_source": "2",
  73. "name_source": "3"
  74. }
  75. ]
  76. }
  77. ],
  78. "id": 1
  79. }

See also

Source

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