使用python api从zabbix获取历史记录 [英] getting history from zabbix with python api

查看:45
本文介绍了使用python api从zabbix获取历史记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个关于使用 python 从 zabbix 获取历史记录的问题.我才刚开始学python,请不要嫌弃)所以,我有一个小脚本 python,谁获取主机,谁显示所有项目,我尝试从这些信息中获取一秒钟的历史记录,但随后不进行过滤.

<预><代码>>>>从 pyzabbix 导入 ZabbixAPI>>>zapi = ZabbixAPI("http://192.168.55.128/zabbix")>>>zapi.login("admin", "zabbix")>>>对于 zapi.host.get(filter={'groupids': '9'}) 中的主机:...印刷主机>>>对于 zapi.item.get(filter={'host':'Zabbix server', 'name' : 'Processor load (5 min average per core)'}):...打印项目>>>history = zapi.history.get({"itemid":"23297","time_from":"2014-10-04 00:10:00", "time_till":"2014-10-04 00:10:01", "输出":"扩展" })>>>印刷历史

在此之后,我拥有所有项目,并且没有过滤时间,为什么?请帮助.附言我必须过滤的东西,所以他们只返回给我的值(设置日期)

谢谢

解决方案

time_fromtime_till 参数中,尝试使用 Unix 时间戳,如下所示:

<预><代码>>>>history = zapi.history.get({"itemids":"23297", "time_from":"1412370600", "time_till":"1412370601", "output":"extend" })>>>印刷历史

i have one question about getting history from zabbix with python. I'm only start learn python, so please don't dislike) so, i have little script python, who get the host, who showing all items, and i try from this information get history for the one second, but then don't filter.

>>> from pyzabbix import ZabbixAPI
>>> zapi = ZabbixAPI("http://192.168.55.128/zabbix")
>>> zapi.login("admin", "zabbix")
>>> for host in zapi.host.get(filter={'groupids': '9'}):
...     print host
>>>for item in zapi.item.get(filter={'host':'Zabbix server', 'name' : 'Processor load (5 min average per core)'}):
...     print item
>>> history = zapi.history.get({"itemid" : "23297","time_from":"2014-10-04 00:10:00", "time_till":"2014-10-04 00:10:01", "output":"extend" })
>>> print history

and after this, i have all items, and no filter time, why? help please. P.S. what i must filter, so them return to me only the value (for the setting date)

Thanks

解决方案

In time_from and time_till parameters, try using a Unix timestamp, like so:

>>> history = zapi.history.get({"itemids":"23297", "time_from":"1412370600", "time_till":"1412370601", "output":"extend" })
>>> print history

这篇关于使用python api从zabbix获取历史记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆