integer/array history.get(object parameters)
该方法允许根据给定的参数检索历史数据。
另见: 已知问题
如果数据还没有被“管家”删除,这个方法可能会返回被删除实体的历史数据。
这个方法对任何类型的用户都是可用的。调用该方法的权限可以在用户角色设置中撤销。前往用户角色以获取更多信息。
(object) 参数定义所期望的输出。
该方法支持以下参数。
| 参数 | 类型 | 描述 | 
|---|---|---|
| history | integer | 要返回的历史对象的类型。 可能的取值: 0 - 浮点数; 1 - 字符; 2 - 日志; 3 - 无符号数; 4 - 文本。 默认: 3.  | 
       
| hostids | string/array | 只返回给定主机的历史。 | 
| itemids | string/array | 只返回给定监控项的历史。 | 
| time_from | timestamp | 只返回在给定时间或在给定时间之后收到的值。 | 
| time_till | timestamp | 只返回在给定时间之前或在给定时间收到的值。 | 
| sortfield | string/array | 按给定的属性对结果进行排序。 可能的取值: itemid 和 clock. | 
       
| 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
           },
           "auth": "038e1d7b1735c6a5436ee9eae095879e",
           "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
       }ui/include/classes/api/services/CHistory.php 的 CHistory::get()。