Zabbix Documentation 3.4

3.04.04.2 (current)In development:4.4 (devel)Unsupported:1.82.02.22.43.23.4

User Tools

Site Tools


Sidebar

zh:manual:api:reference:item:create

item.create

Description 说明

object item.create(object/array items)

This method allows to create new items.此方法允许创建新的项。

Web items cannot be created via the Zabbix API.无法通过Zabbix API创建Web items。

Parameters参数

(object/array) Items to create.要创建的items

Additionally to the standard item properties, the method accepts the following parameters.除了项属性之外,该方法接受以下参数。

属性 类型 说明
applications array IDs of the applications to add the item to. 要添加项的应用程序的ID。

Return values 返回值

(object) Returns an object containing the IDs of the created items under the itemids property. The order of the returned IDs matches the order of the passed items.返回包含“itemids”属性下创建项的ID的对象。 返回的ID的顺序与传递的项的顺序相匹配。

Examples 示例

Creating an item 创建一个item

Create a numeric Zabbix agent item to monitor free disk space on host with ID “30074” and add it to two applications.创建一个数字Zabbix代理项,以监控ID为“30074”的主机上的可用磁盘空间,并将其添加到两个应用程序中。

Request:

{
    "jsonrpc": "2.0",
    "method": "item.create",
    "params": {
        "name": "Free disk space on $1",
        "key_": "vfs.fs.size[/home/joe/,free]",
        "hostid": "30074",
        "type": 0,
        "value_type": 3,
        "interfaceid": "30084",
        "applications": [
            "609",
            "610"
        ],
        "delay": "30s"
    },
    "auth": "038e1d7b1735c6a5436ee9eae095879e",
    "id": 1
}

Response:

{
    "jsonrpc": "2.0",
    "result": {
        "itemids": [
            "24758"
        ]
    },
    "id": 1
}

Creating a host inventory item

Create a Zabbix agent item to populate the host's “OS” inventory field.

Request:

{
    "jsonrpc": "2.0",
    "method": "item.create",
    "params": {
        "name": "uname",
        "key_": "system.uname",
        "hostid": "30021",
        "type": 0,
        "interfaceid": "30007",
        "value_type": 1,
        "delay": "10s",
        "inventory_link": 5
    },
    "auth": "038e1d7b1735c6a5436ee9eae095879e",
    "id": 1
}

Response:

{
    "jsonrpc": "2.0",
    "result": {
        "itemids": [
            "24759"
        ]
    },
    "id": 1
}

Source 来源

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