【问题标题】:Can not fetch the history data of memory when using zabbix api使用zabbix api时无法获取内存的历史数据
【发布时间】:2016-01-27 12:07:00
【问题描述】:

我试图使用history.get 方法获取vm.memory.size[used], vm.memory.size[cached], vm.memory.size[buffers], vm.memory.size[total] 的历史数据,但它什么也没返回。
我可以通过item.get 呼叫获得 itemid。代码如下所示。

import sys  
import time
import logging
from pyzabbix import ZabbixAPI

stream = logging.StreamHandler(sys.stdout)
stream.setLevel(logging.DEBUG)
log = logging.getLogger('pyzabbix')
log.addHandler(stream)
log.setLevel(logging.DEBUG) 

zapi = ZabbixAPI(ZABBIX_SERVER)
zapi.login(user, passwd)  
# get itemid
items = zapi.item.get(output='extend', hostids=['10470', '10471', '10472', '10473'], search={'key_': 'vm.memory.size[used]'})  
history = zapi.history.get(output='extend', itemids=['83140', '83141', '83142', '83143'], history=0, time_from=time.time() - 3600, time_till=time.time(), sortfield='clock', sortorder='DESC')  

history是一个空列表[],那么如何获取内存的历史数据呢?

【问题讨论】:

标签: python zabbix


【解决方案1】:

我有一个 python 脚本来生成 zabbix 的自定义报告,并且时间戳以这种形式工作。

Date_F = "04/10/2015"
Date_T = "07/10/2015"

Begin = time.mktime(datetime.datetime.strptime(Date_F, "%d/%m/%Y").timetuple())
End = time.mktime(datetime.datetime.strptime(Date_T, "%d/%m/%Y").timetuple()

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-08-13
    • 2017-01-21
    • 1970-01-01
    相关资源
    最近更新 更多