This method allows to create new LLD rules.此方法允许创建新的LLD规则。

    Parameters 参数

    (object/array) LLD rules to create.

    Additionally to the , the method accepts the following parameters.

    (object) Returns an object containing the IDs of the created LLD rules under the itemids property. The order of the returned IDs matches the order of the passed LLD rules. (object)itemids属性下返回一个包含IDs的被创建的LLD规则。返回的IDs的顺序与传递的LLD规则顺序相匹配。

    Examples 示例

    Creating an LLD rule

    Create a Zabbix agent LLD rule to discover mounted file systems. Discovered items will be updated every 30 seconds. 创建Zabbix agent LLD规则去发现以已装入的文件系统。发现items将被每30s被更新一次。

    Response:

    1. {
    2. "jsonrpc": "2.0",
    3. "result": {
    4. "itemids": [
    5. "27665"
    6. },
    7. "id": 1

    Using a filter

    Create an LLD rule with a set of conditions to filter the results by. The conditions will be grouped together using the logical “and” operator. 创建有由一套删选条件的得到的LLD规则。这些条件将使用逻辑“和”运算符将条件组合在一起。

    Request:

    Response:

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

    Using a custom expression filter 使用自定义表达式的筛选器

    Create an LLD rule with a filter that will use a custom expression to evaluate the conditions. The LLD rule must only discover objects the “{#MACRO1}” macro value of which matches both regular expression “regex1” and “regex2”, and the value of “{#MACRO2}” matches either “regex3” or “regex4”. The formula IDs “A”, “B”, “C” and “D” have been chosen arbitrarily.

    Response:

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

    Using custom query fields and headers 使用自定义查询字段和报头

    Create LLD rule with custom query fields and headers.

    Request:

    Response:

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

    Source

    CDiscoveryRule::create() in frontends/php/include/classes/api/services/CDiscoveryRule.php.