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

替换

描述

object hostinterface.replacehostinterfaces(object parameters)

此方法允许给指定主机替换所有主机接口.

参数

(对象) 包含要更新的主机ID和新主机接口的参数.

参数 类 描述
hostid
(必选)
字符串 要更 主机的ID.
interfaces
(必须)
对象/数组 替换当 主机接口的主机接口.

返回值

(对象)interfaceids属性中返回已创建主机接口ID的对象.

示例

更换主机接口

用单个代理接口替换所有主机接口.

请求:

{
           "jsonrpc": "2.0",
           "method": "hostinterface.replacehostinterfaces",
           "params": {
               "hostid": "30052",
               "interfaces": {
                   "dns": "",
                   "ip": "127.0.0.1",
                   "main": 1,
                   "port": "10050",
                   "type": 1,
                   "useip": 1
               }
           },
           "auth": "038e1d7b1735c6a5436ee9eae095879e",
           "id": 1
       }

响应:

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

参考

来源

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