integer/array history.get(object parameters)
该方法允许根据指定的参数查询历史数据。
如果管家尚未清理已删除实体的历史数据,则此方法可以返回该数据。
任何类型的用户都可以使用此方法。可以在用户角色设置中撤销调用该方法的权限。有关更多信息,请参阅用户角色。
(object) 参数定义预期的输出。
该方法支持以下参数。
| 参数 | 类型 | 描述 |
|---|---|---|
| history | integer | 要返回的历史对象的类型。 可能的值: 0 - 浮点数; 1 - 字符; 2 - 日志; 3 - (默认) 无符号数值; 4 - 文本; 5 - 二进制. |
| hostids | ID/array | 仅返回指定主机的历史数据。 |
| itemids | ID/array | 仅返回指定监控项的历史数据。 |
| time_from | timestamp | 仅返回指定时间之后的历史数据。 |
| time_till | timestamp | 仅返回指定时间之前的历史数据。 |
| sortfield | string/array | 按指定的属性对结果进行排序。 可能的值: itemid, clock, ns. |
| countOutput | boolean | 这些参数是所有 get 方法的共同参数,在参考说明页面中有详细描述。 |
| editable | boolean | |
| excludeSearch | boolean | |
| filter | object | |
| limit | integer | |
| output | query | |
| search | object | |
| searchByAny | boolean | |
| searchWildcardsEnabled | boolean | |
| sortorder | string/array | |
| startSearch | boolean |
返回 (integer/array) 其中之一:
countOutput 参数,则为检索到的对象的数量。返回从一个 numeric(float) 监控项收到的10个最新值。
请求:
{ "jsonrpc": "2.0", "method": "history.get", "params": { "output": "extend", "history": 0, "itemids": "23296", "sortfield": "clock", "sortorder": "DESC", "limit": 10 }, "id": 1 }响应:
{ "jsonrpc": "2.0", "result": [ { "itemid": "23296", "clock": "1351090996", "value": "0.085", "ns": "563157632" }, { "itemid": "23296", "clock": "1351090936", "value": "0.16", "ns": "549216402" }, { "itemid": "23296", "clock": "1351090876", "value": "0.18", "ns": "537418114" }, { "itemid": "23296", "clock": "1351090816", "value": "0.21", "ns": "522659528" }, { "itemid": "23296", "clock": "1351090756", "value": "0.215", "ns": "507809457" }, { "itemid": "23296", "clock": "1351090696", "value": "0.255", "ns": "495509699" }, { "itemid": "23296", "clock": "1351090636", "value": "0.36", "ns": "477708209" }, { "itemid": "23296", "clock": "1351090576", "value": "0.375", "ns": "463251343" }, { "itemid": "23296", "clock": "1351090516", "value": "0.315", "ns": "447947017" }, { "itemid": "23296", "clock": "1351090456", "value": "0.275", "ns": "435307141" } ], "id": 1 }CHistory::get() in ui/include/classes/api/services/CHistory.php.