drule.get

Description

描述

integer/array drule.get(object **parameters**) 整数/数组 drule.get(object **parameters**)

The method allows to retrieve discovery rules according to the given parameters. 该方法用于根据给定的参数获取发现规则。

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 discovery checks used by the discovery rule in the dchecks property.

Supports count.
selectDHostsqueryReturn the discovered hosts that the discovery rule created in the dhosts property.

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
参数类型描述
dhostidsstring/array仅返回创建给定已发现主机的发现规则
druleidsstring/array仅返回给定ID的发现规则
dserviceidsstring/array仅返回创建给定已发现服务的发现规则
selectDChecksquerydchecks 属性下,返回被发现规则使用的发现检查

支持count.
selectDHostsquerydhosts属性下,返回发现规则创建的发现主机

支持count.
limitSelectsinteger限制子选项返回的记录数

适用于以下子选项:
selectDChecks - 结果按dcheckid排序;
selectDHosts - 结果按dhostsid排序
sortfieldstring/array结果按给定属性排序.

可能的值: druleidname.
countOutputboolean以下参数为get方法通常参数,在参考注释有详细说明
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.

(整数/数组) 返回:

  • 对象数据;

  • 如果countOutput被使用,返回获取对象的计数.

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. },
  28. {
  29. "dcheckid": "8",
  30. "druleid": "2",
  31. "type": "4",
  32. "key_": "",
  33. "snmp_community": "",
  34. "ports": "80",
  35. "snmpv3_securityname": "",
  36. "snmpv3_securitylevel": "0",
  37. "snmpv3_authpassphrase": "",
  38. "snmpv3_privpassphrase": "",
  39. "uniq": "0",
  40. "snmpv3_authprotocol": "0",
  41. "snmpv3_privprotocol": "0"
  42. }
  43. ]
  44. },
  45. {
  46. "druleid": "6",
  47. "proxy_hostid": "0",
  48. "name": "Zabbix agent discovery",
  49. "iprange": "192.168.1.1-255",
  50. "delay": "1h",
  51. "nextcheck": "0",
  52. "status": "0",
  53. "dchecks": [
  54. {
  55. "dcheckid": "10",
  56. "druleid": "6",
  57. "type": "9",
  58. "key_": "system.uname",
  59. "snmp_community": "",
  60. "ports": "10050",
  61. "snmpv3_securityname": "",
  62. "snmpv3_securitylevel": "0",
  63. "snmpv3_authpassphrase": "",
  64. "snmpv3_privpassphrase": "",
  65. "uniq": "0",
  66. "snmpv3_authprotocol": "0",
  67. "snmpv3_privprotocol": "0"
  68. }
  69. ]
  70. }
  71. ],
  72. "id": 1
  73. }

See also

参考

Source

来源

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