This is a translation of the original English documentation page. Help us make it better.

Sidebar

Zabbix Summit 2022
Register for Zabbix Summit 2022

drule.get

説明

integer/array drule.get(object parameters)

このメソッドは、与えられたパラメータに従ってディスカバリールールを取得することができます。

このメソッドは、どのタイプのユーザーでも利用可能です。このメソッドを呼び出す許可は、ユーザーロール設定で
取り消すことができます。詳しくは User roles をご覧ください。

パラメータ

(object) 希望する出力を定義するパラメータ

このメソッドは、以下のパラメータをサポートしています。

パラメータ Type 説明
dhostids string/array Return only discovery rules that created the given discovered hosts.
druleids string/array Return only discovery rules with the given IDs.
dserviceids string/array Return only discovery rules that created the given discovered services.
selectDChecks query Return a dchecks property with the discovery checks used by the discovery rule.

Supports count.
selectDHosts query Return a dhosts property with the discovered hosts created by the discovery rule.

Supports count.
limitSelects integer Limits 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.
sortfield string/array Sort the result by the given properties.

Possible values are: druleid and name.
countOutput boolean These parameters being common for all get methods are described in detail in the reference commentary.
editable boolean
excludeSearch boolean
filter object
limit integer
output query
preservekeys boolean
search object
searchByAny boolean
searchWildcardsEnabled boolean
sortorder string/array
startSearch boolean

戻り値

(integer/array) のどちらかを返します:

  • オブジェクトの配列
  • もし countOutput パラメータが使用されている場合は、取得したオブジェクトの数

すべてのディスカバリールールを取得する

設定されたすべてのディスカバリールールと、それらが使用するディスカバリーチェックを取得します。

Request:

{
           "jsonrpc": "2.0",
           "method": "drule.get",
           "params": {
               "output": "extend",
               "selectDChecks": "extend"
           },
           "auth": "038e1d7b1735c6a5436ee9eae095879e",
           "id": 1
       }

Response:

{
           "jsonrpc": "2.0",
           "result": [
               {
                   "druleid": "2",
                   "proxy_hostid": "0",
                   "name": "Local network",
                   "iprange": "192.168.3.1-255",
                   "delay": "5s",
                   "nextcheck": "1348754327",
                   "status": "0",
                   "dchecks": [
                       {
                           "dcheckid": "7",
                           "druleid": "2",
                           "type": "3",
                           "key_": "",
                           "snmp_community": "",
                           "ports": "21",
                           "snmpv3_securityname": "",
                           "snmpv3_securitylevel": "0",
                           "snmpv3_authpassphrase": "",
                           "snmpv3_privpassphrase": "",
                           "uniq": "0",
                           "snmpv3_authprotocol": "0",
                           "snmpv3_privprotocol": "0",
                           "host_source": "1",
                           "name_source": "0"                     
                       },
                       {
                           "dcheckid": "8",
                           "druleid": "2",
                           "type": "4",
                           "key_": "",
                           "snmp_community": "",
                           "ports": "80",
                           "snmpv3_securityname": "",
                           "snmpv3_securitylevel": "0",
                           "snmpv3_authpassphrase": "",
                           "snmpv3_privpassphrase": "",
                           "uniq": "0",
                           "snmpv3_authprotocol": "0",
                           "snmpv3_privprotocol": "0",
                           "host_source": "1",
                           "name_source": "0"                    
                       }
                   ]
               },
               {
                   "druleid": "6",
                   "proxy_hostid": "0",
                   "name": "Zabbix agent discovery",
                   "iprange": "192.168.1.1-255",
                   "delay": "1h",
                   "nextcheck": "0",
                   "status": "0",
                   "dchecks": [
                       {
                           "dcheckid": "10",
                           "druleid": "6",
                           "type": "9",
                           "key_": "system.uname",
                           "snmp_community": "",
                           "ports": "10050",
                           "snmpv3_securityname": "",
                           "snmpv3_securitylevel": "0",
                           "snmpv3_authpassphrase": "",
                           "snmpv3_privpassphrase": "",
                           "uniq": "0",
                           "snmpv3_authprotocol": "0",
                           "snmpv3_privprotocol": "0",
                           "host_source": "2",
                           "name_source": "3"                    
                       }
                   ]
               }
           ],
           "id": 1
       }

参照

ソース

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