Zabbix Documentation 3.4 (current)In development:4.4 (devel)Unsupported:

User Tools

Site Tools





object host.create(object/array hosts)

This method allows to create new hosts.此方法允许创建新的主机。

Parameters 参数

(object/array) Hosts to create.要创建的主机。

Additionally to the standard host properties, the method accepts the following parameters. 另外,对于标准主机属性,此方法接受以下参数。

参数 类型 说明
object/array Host groups to add the host to.将主机添加到主机组中。

The host groups must have the groupid property defined.主机组必须已定义groupid属性。
object/array Interfaces to be created for the host.为主机创建的接口。
templates object/array Templates to be linked to the host. 链接到主机的模板。

The templates must have the templateid property defined. 模板必须已定义过templateid属性。
macros object/array User macros to be created for the host.为主机创建的用户宏。
inventory object Host inventory properties. 主机资产清单属性。

Return values 返回值

(object) Returns an object containing the IDs of the created hosts under the hostids property. The order of the returned IDs matches the order of the passed hosts.返回一个对象其中包含在hostids属性下已创建主机的ID。返回ID的命令与传递主机的命令相匹配。


Creating a host 创建一个主机

Create a host called “Linux server” with an IP interface, add it to a group, link a template to it and set the MAC addresses in the host inventory.创建一个具有IP接口的“Linux Server”主机,将其添加到主机组中,链接一个模板并且把MAC地址设置到主机资产清单里。


    "jsonrpc": "2.0",
    "method": "host.create",
    "params": {
        "host": "Linux server",
        "interfaces": [
                "type": 1,
                "main": 1,
                "useip": 1,
                "ip": "",
                "dns": "",
                "port": "10050"
        "groups": [
                "groupid": "50"
        "templates": [
                "templateid": "20045"
        "inventory_mode": 0,
        "inventory": {
            "macaddress_a": "01234",
            "macaddress_b": "56768"
    "auth": "038e1d7b1735c6a5436ee9eae095879e",
    "id": 1


    "jsonrpc": "2.0",
    "result": {
        "hostids": [
    "id": 1

See also参见

Source 来源

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