2022 Zabbix中国峰会
2022 Zabbix中国峰会

hostinterface.massadd

Description 说明

object hostinterface.massadd(object parameters)

This method allows to simultaneously add host interfaces to multiple hosts.该方法允许同时向多个主机添加主机接口。

Parameters 参数

(object) Parameters containing the host interfaces to be created on the given hosts.包含要在给定主机上创建的主机接口的参数。

The method accepts the following parameters.该方法接受以下参数。

参数 类 描述
hosts
(required)
object/array Hosts to be updated. 要更新的主机。

The hosts must have the hostid property defined.主机必须定义“hostid”属性。
interfaces
(required)
object/array Host interfaces to create on the given hosts.在给定的主机上创建主机接口。

Return values 返回值

(object) Returns an object containing the IDs of the created host interfaces under the interfaceids property.返回一个包含“interfaceID”属性下创建的主机接口的ID的对象。

Examples 示例

Creating interfaces创建接口

Create an interface on two hosts.在两台主机上创建一个接口。

Request:

{
           "jsonrpc": "2.0",
           "method": "hostinterface.massadd",
           "params": {
               "hosts": [
                   {
                       "hostid": "30050"
                   },
                   {
                       "hostid": "30052"
                   }
               ],
               "interfaces": {
                   "dns": "",
                   "ip": "127.0.0.1",
                   "main": 0,
                   "port": "10050",
                   "type": 1,
                   "useip": 1
               }
           },
           "auth": "038e1d7b1735c6a5436ee9eae095879e",
           "id": 1
       }

Response:

{
           "jsonrpc": "2.0",
           "result": {
               "interfaceids": [
                   "30069",
                   "30070"
               ]
           },
           "id": 1
       }

See also 参见

Source 来源

CHostInterface::massAdd() in frontends/php/include/classes/api/services/CHostInterface.php.