历史记录.推送

描述

object history.push(object/array itemHistoryData)

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

此方法可供任何类型的用户使用。 可以在用户角色设置中撤销调用该方法的权限。 更多信息请参见User roles

参数

(object/array) 监控项 历史数据以发送。

该方法支持以下参数。

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

参数行为:
- 如果未设置 hostkey,则为必填
host string 主机 的技术名称。

参数行为:
- 如果未设置 itemid,则为必填
key string 监控项 键。

参数行为:
- 如果未设置 itemid,则为必填
value mixed 监控项 值。

参数行为:
- 必填
clock timestamp 接收值的时间。
ns integer 接收值时的纳秒数。

返回值

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

示例

发送 监控项 历史数据

将 监控项 历史数据发送至 Zabbix server 以用于 监控项 "10600"、"10601" 和 "999999"。

执行请求:

{
    "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
}

另请参阅

Source

CHistory::push() 在 ui/include/classes/api/services/CHistory.php 中。