On this page
itemprototype.update
描述
object itemprototype.update(object/array itemPrototypes)
此方法用于 update 现有的 监控项原型。
此方法仅适用于 管理员 和 超级管理员 用户类型。调用该方法的权限可以在用户角色设置中撤销。更多信息请参见 User roles。
参数
(object/array) 要更新的监控项原型属性。
每个监控项原型都必须定义 itemid 属性,其他所有属性均为可选。只有传入的属性会被更新,其余属性将保持不变。
除了标准监控项原型属性之外,该方法还接受以下参数。
| Parameter | Type | Description |
|---|---|---|
| preprocessing | array | 用于替换当前预处理选项的监控项原型预处理选项。 参数行为: - 只读,适用于继承对象 |
| tags | array | 监控项原型标签。 |
返回值
(object) 返回一个 object,其中包含更新后的 监控项 原型的 ID,这些 ID 位于 itemids 属性下。
示例
修改 监控项 原型的接口
更改发现的 监控项 将使用的 主机 接口。
执行请求:
{
"jsonrpc": "2.0",
"method": "itemprototype.update",
"params": {
"itemid": "27428",
"interfaceid": "132"
},
"id": 1
}
响应:
{
"jsonrpc": "2.0",
"result": {
"itemids": [
"27428"
]
},
"id": 1
}
更新依赖的 监控项 原型
更新依赖监控项原型的主监控项原型ID。仅 允许在同一主机(模板/发现规则)上设置依赖关系 因此主节点和从属节点的监控项应具有相同的hostid和ruleid。
执行请求:
{
"jsonrpc": "2.0",
"method": "itemprototype.update",
"params": {
"master_itemid": "25570",
"itemid": "189030"
},
"id": 1
}
响应:
{
"jsonrpc": "2.0",
"result": {
"itemids": [
"189030"
]
},
"id": 1
}
更新 HTTP agent 监控项 原型
更改 query 字段并移除所有自定义标题。
执行请求:
{
"jsonrpc": "2.0",
"method": "itemprototype.update",
"params": {
"itemid":"28305",
"query_fields": [
{
"name": "random",
"value": "qwertyuiopasdfghjklzxcvbnm"
}
],
"headers": []
}
"id": 1
}
响应:
{
"jsonrpc": "2.0",
"result": {
"itemids": [
"28305"
]
},
"id": 1
}
更新监控项预处理选项
使用监控项预处理规则“自定义倍数”更新一个监控项原型。
请求:
{
"jsonrpc": "2.0",
"method": "itemprototype.update",
"params": {
"itemid": "44211",
"preprocessing": [
{
"type": 1,
"params": "4",
"error_handler": 2,
"error_handler_params": "5"
}
]
},
"id": 1
}
响应:
{
"jsonrpc": "2.0",
"result": {
"itemids": [
"44211"
]
},
"id": 1
}
更新脚本 监控项 原型
使用不同的脚本更新脚本监控项原型,并删除之前脚本使用的不必要的参数。
执行请求:
{
"jsonrpc": "2.0",
"method": "itemprototype.update",
"params": {
"itemid": "23865",
"parameters": [],
"script": "Zabbix.log(3, 'Log test');\nreturn 1;"
},
"id": 1
}
响应:
{
"jsonrpc": "2.0",
"result": {
"itemids": [
"23865"
]
},
"id": 1
}
来源
CItemPrototype::update() 在 ui/include/classes/api/services/CItemPrototype.php 中。