按照zabbix的官方文档获取history.get的api时,返回值为空;
官方请求参数:
{
"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': [], 'id': 1}
问题原因:“history”的值 不正确;
问题分析:官方文档解释
item.get中解释:
history.get中解释:
解决方案:“history”的值不正确; 那存在多个值,我们如何获取呢?
在item.get接口的返回值中恰好有一个“history”参数,但是这两个参数根本不是一回事
真正和history.get接口入参“history”对应的是item.get接口返回值中的“value_type”;所以将item.get中value_type的值取出 替换history.get的history 即可解决;
参考示例:
此处备注: