W3Cschool
恭喜您成為首批注冊(cè)用戶
獲得88經(jīng)驗(yàn)值獎(jiǎng)勵(lì)
日常使用報(bào)表調(diào)用關(guān)系
日常使用報(bào)表 _report 函數(shù)
(1)獲取報(bào)表的時(shí)間范圍
time_from = int(time.mktime(startTime))+1
time_till = int(time.mktime(endTime))
(2)獲取需要輸出的host 列表【主要是獲取hostid】
host_list = self._hosts_get()
如果沒有--hostid和--hostgroupid參數(shù),此函數(shù)將會(huì)返回所有的主機(jī)列表
(3)對(duì)每個(gè)host輸出和想要輸出的item相關(guān)的item信息列表【主要是獲取對(duì)應(yīng)hostid的相關(guān)itemid】
itemid_all_list = self.item_get(host_info[0],itemName)
item_get 調(diào)用的是zabbix官方api item.get |
(4)依次對(duì)要查詢的itemid進(jìn)行求最大值,最小值以及平均值
report_min,report_max,report_avg = self.__trend_get(itemid,time_from,time_till)
這個(gè)函數(shù)的主要參數(shù)就是itemid 和 time_from,time_till
__trend_get調(diào)用的是zabbix官方api trend.get,同時(shí)對(duì)返回的數(shù)據(jù)進(jìn)行了下求值運(yùn)算(最大值,最小值,平均值) 計(jì)算方法為: 最大值:特定時(shí)間范圍內(nèi),trend.get 獲取特定itemid的最大值中的最大值 最小值:特定時(shí)間范圍內(nèi),trend.get 獲取特定itemid的最小值中的最小值 平均值:特定時(shí)間范圍內(nèi),trend.get 獲取特定itemid的平均值重新求平均值 trend.get 為zabbix3.0 加的api,故低于zabbix3.0的版本需要使用history.get 進(jìn)行計(jì)算 |
(5)對(duì)輸出的信息進(jìn)行處理
if history_type=="3": report_min=int(report_min) report_max=int(report_max) report_avg=int(report_avg) report_min=str(report_min) report_max=str(report_max) report_avg=str(report_avg) |
類型是3時(shí),結(jié)果為整數(shù)型的
0 - numeric float; 1 - character; 2 - log; 3 - numeric unsigned; 整型 4 - text. |
想要對(duì)數(shù)據(jù)進(jìn)行處理時(shí),可以從第5步方面著手處理,good luck
Copyright©2021 w3cschool編程獅|閩ICP備15016281號(hào)-3|閩公網(wǎng)安備35020302033924號(hào)
違法和不良信息舉報(bào)電話:173-0602-2364|舉報(bào)郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號(hào)
聯(lián)系方式:
更多建議: