获取

Description 说明

integer/array trend.get(object **parameters**)

The method allows to retrieve trend data according to the given parameters. 该方法用于根据指定的参数检索趋势数据。

Parameters 参数

(object) Parameters defining the desired output. (object)定义所需输出的参数。 The method supports the following parameters. 该方法提供以下参数。

Parameter 参数Type 类型Description 说明
itemidsstring/array 字符串/数组Return only trends with the given item IDs. 仅返回指定监控项ID的趋势。
time_fromtimestamp 时间戳Return only values that have been collected after or at the given time. 仅返回指定时间(包含)之后已采集的值。
time_tilltimestamp 时间戳Return only values that have been collected before or at the given time. 仅返回指定时间(包含)之前已采集的值。
countOutputboolean 布尔值Count the number of retrieved objects. 计算检索对象的数量。
limitinteger 整数型Limit the amount of retrieved objects. 限制检索对象的数量。
outputquery 查询Set fields to output. 输出设置的字段。

Return values 返回值

(integer/array) Returns either: 返回两者其中任一:

  • an array of objects; 一组对象;

  • the count of retrieved objects, if the countOutput parameter has been used. 如果已经使用了countOutput参数,则检索对象的计数。

Examples 范例

Retrieving item trend data 检索监控项趋势数据

Request 请求:

  1. {
  2. "jsonrpc": "2.0",
  3. "method": "trend.get",
  4. "params": {
  5. "output": [
  6. "itemid",
  7. "clock",
  8. "num",
  9. "value_min",
  10. "value_avg",
  11. "value_max",
  12. ],
  13. "itemids": [
  14. "23715"
  15. ],
  16. "limit": "1"
  17. },
  18. "auth": "038e1d7b1735c6a5436ee9eae095879e",
  19. "id": 1
  20. }

Response 响应:

  1. {
  2. "jsonrpc": "2.0",
  3. "result": [
  4. {
  5. "itemid": "23715",
  6. "clock": "1446199200",
  7. "num": "60",
  8. "value_min": "0.1650",
  9. "value_avg": "0.2168",
  10. "value_max": "0.3500",
  11. }
  12. ],
  13. "id": 1
  14. }

Source 源码

CTrend::get() in frontends/php/include/classes/api/services/CTrend.php. CTrend::get()方法可在frontends/php/include/classes/api/services/CTrend.php中参考。