这是原厂英文文档的翻译页面. 欢迎帮助我们 完善文档.
2022 Zabbix中国峰会
2022 Zabbix中国峰会

替换

描述

object hostinterface.replacehostinterfaces(object parameters)

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

该方法适用于管理员超级管理员用户类型。可以在用户角色设置中撤销调用该方法的权限。有关详细信息,参阅用户角色

参数

(object) 包含要更新的主机ID和新主机接口的参数。

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

返回值

(object)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 ui/include/classes/api/services/CHostInterface.php