推送

描述

object history.push(object/array itemHistoryData)

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

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

参数

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

该方法支持下列参数。

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

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

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

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

参数行为:
- 必须
clocktimestamp收到监控项的值的时间。
nsinteger收到值时的纳秒数。

返回值

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

示例

发送监控项历史数据

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

请求:

  1. {
  2. "jsonrpc": "2.0",
  3. "method": "history.push",
  4. "params": [
  5. {
  6. "itemid": 10600,
  7. "value": 0.5,
  8. "clock": 1690891294,
  9. "ns": 45440940
  10. },
  11. {
  12. "itemid": 10600,
  13. "value": 0.6,
  14. "clock": 1690891295,
  15. "ns": 312431
  16. },
  17. {
  18. "itemid": 10601,
  19. "value": "[Tue Aug 01 15:01:35 2023] [error] [client 1.2.3.4] File does not exist: /var/www/html/robots.txt"
  20. },
  21. {
  22. "itemid": 999999,
  23. "value": 123
  24. }
  25. ],
  26. "id": 1
  27. }

响应:

  1. {
  2. "jsonrpc": "2.0",
  3. "result": {
  4. "response": "success",
  5. "data": [
  6. {
  7. "itemid": "10600"
  8. },
  9. {
  10. "itemid": "10600"
  11. },
  12. {
  13. "itemid": "10601",
  14. "error": "Item is disabled."
  15. },
  16. {
  17. "error": "No permissions to referred object or it does not exist."
  18. }
  19. ]
  20. },
  21. "id": 1
  22. }

另见

源码

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