历史记录.推送

描述

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 文件中。