推送

描述

object history.push(object/array itemHistoryData)

此方法允许发送监控项历史数据给Zabbix server。

任何类型的用户都可以使用此方法。可以在用户角色设置中撤销调用该方法的权限。有关更多信息,请参阅用户角色

参数

(object/array) 需要发送的监控项历史数据。

该方法支持下列参数。

参数 类型 描述
itemid ID 相关的监控项的ID。

参数行为:
- 如果 hostkey 没有设置时 必须 指定。
host string 主机的技术名称。

参数行为:
- 如果itemid 没有设置时 必须 指定。
key string 监控项键值。

参数行为:
- 如果itemid 没有设置时 必须 指定。
value mixed 监控项的值。

参数行为:
- 必须
clock timestamp 收到监控项的值的时间。
ns integer 收到值时的纳秒数。

返回值

(object) 数据发送操作的返回结果。

示例

发送监控项历史数据

发送监控项"10600", "10601"和"999999"的历史数据给Zabbix server。

请求:

{
    "jsonrpc": "2.0",
    "method": "history.push",
    "params": [
        {
            "itemid": 10600,
            "value": 0.5,
            "clock": 1690891294,
            "ns": 45440940
        },
        {
            "itemid": 10600,
            "value": 0.6,
            "clock": 1690891295,
            "ns": 312431
        },
        {
            "itemid": 10601,
            "value": "[Tue Aug 01 15:01:35 2023] [error] [client 1.2.3.4] File does not exist: /var/www/html/robots.txt"
        },
        {
            "itemid": 999999,
            "value": 123
        }
    ],
    "id": 1
}

响应:

{
    "jsonrpc": "2.0",
    "result": {
        "response": "success",
        "data": [
            {
                "itemid": "10600"
            },
            {
                "itemid": "10600"
            },
            {
                "itemid": "10601",
                "error": "Item is disabled."
            },
            {
                "error": "No permissions to referred object or it does not exist."
            }
        ]
    },
    "id": 1
}

另见

源码

CHistory::push() in ui/include/classes/api/services/CHistory.php.