获取

描述

整数/数组 history.get(object parameters)

该方法允许根据给定的参数检索历史数据 参考: known issues

参数

(object) 定义期望输出的参数.

该方法支持以下参数:

参数 类描述
history整数 要回的历史对象类型.

可能的值:
0 - 数字浮点;
1 - 字符串;
2 - 日志;
3 - 无符号数字;
4 - 文本.

默认值: 3.
hostids字符串/数组 只返回给主机的历史记录
itemids字符串/数组 只返回给监控项的历史记录
time_from时间戳 仅返在给定时间时或之后收到的值
time_till时间戳 仅返在给定时间时或之前收到的值
sortfield字符串/数组 按照给定属性对结果进行排序

可能的值: itemidclock
countOutput布尔值 这些数对于所有get方法都是通用的,详细描述可参考: reference commentary
editable布尔值 ::
excludeSearch布尔值 ::
filter对象 ::
limit整数 ::
output查询 ::
search对象 ::
searchByAny布尔值 ::
searchWildcardsEnabled布尔值 ::
sortorder字符串/数组 :::
startSearch布尔值 ::

返回值

(整数/数组) 返回:

  • 一组对象
  • 如果使用了countOutput参数,返回检索对象的数量

示例

获取监控项历史数据

从数字(浮点)监控项中获取最近10条数据

请求:

  1. {
  2. "jsonrpc": "2.0",
  3. "method": "history.get",
  4. "params": {
  5. "output": "extend",
  6. "history": 0,
  7. "itemids": "23296",
  8. "sortfield": "clock",
  9. "sortorder": "DESC",
  10. "limit": 10
  11. },
  12. "auth": "038e1d7b1735c6a5436ee9eae095879e",
  13. "id": 1
  14. }

响应:

  1. {
  2. "jsonrpc": "2.0",
  3. "result": [
  4. {
  5. "itemid": "23296",
  6. "clock": "1351090996",
  7. "value": "0.0850",
  8. "ns": "563157632"
  9. },
  10. {
  11. "itemid": "23296",
  12. "clock": "1351090936",
  13. "value": "0.1600",
  14. "ns": "549216402"
  15. },
  16. {
  17. "itemid": "23296",
  18. "clock": "1351090876",
  19. "value": "0.1800",
  20. "ns": "537418114"
  21. },
  22. {
  23. "itemid": "23296",
  24. "clock": "1351090816",
  25. "value": "0.2100",
  26. "ns": "522659528"
  27. },
  28. {
  29. "itemid": "23296",
  30. "clock": "1351090756",
  31. "value": "0.2150",
  32. "ns": "507809457"
  33. },
  34. {
  35. "itemid": "23296",
  36. "clock": "1351090696",
  37. "value": "0.2550",
  38. "ns": "495509699"
  39. },
  40. {
  41. "itemid": "23296",
  42. "clock": "1351090636",
  43. "value": "0.3600",
  44. "ns": "477708209"
  45. },
  46. {
  47. "itemid": "23296",
  48. "clock": "1351090576",
  49. "value": "0.3750",
  50. "ns": "463251343"
  51. },
  52. {
  53. "itemid": "23296",
  54. "clock": "1351090516",
  55. "value": "0.3150",
  56. "ns": "447947017"
  57. },
  58. {
  59. "itemid": "23296",
  60. "clock": "1351090456",
  61. "value": "0.2750",
  62. "ns": "435307141"
  63. }
  64. ],
  65. "id": 1
  66. }

来源

CHistory::get() in frontends/php/include/classes/api/services/CHistory.php.