如何採用Python zabbix_api 擷取效能資料

來源:互聯網
上載者:User

標籤:python   zabbix   zabbix_api   

# 最近領導需要一份資料,OpenStack ,VMware,物理機之間的效能報告,在撰寫報告之前需要資料支撐,我們採用的是zabbix 監控,需要採取一周內的曆史資料作為對比,那資料如何擷取,請看以下章節#/usr/bin/env python#-*-coding:UTF-8"""    wget http://doc.bonfire-project.eu/R4.1/_static/scripts/fetch_items_to_csv.py    http://doc.bonfire-project.eu/R3/monitoring/bonfire_monitoring_data_to_csv.html"""import os,sys,timeusers=u‘admin‘pawd = ‘admin‘exc_py = ‘/data/zabbix/fetch_items_to_csv.py‘os.system(‘easy_install zabbix_api‘)os.system(‘mkdir -p /data/zabbix/cvs/‘)if not os.path.exists(exc_py):    os.system("mkdir -p /data")    os.system("wget http://doc.bonfire-project.eu/R4.1/_static/scripts/fetch_items_to_csv.py -O /data/zabbix/fetch_items_to_csv.py")def show_items(moniter, dip):    items = dict()    items[‘io_read_win‘] = "perf_counter[\\2\\16]"    items[‘io_write_win‘] = "perf_counter[\\2\\18]"    items[‘io_read_lin‘] = "iostat[,wkB\/s]"    items[‘io_write_lin‘] = "iostat[,rkB\/s]"    items[‘cpu_util‘] = "system.cpu.util"    items[‘net_in_linu_vm‘] = "net.if.in[eth0]"    items[‘net_out_lin_vm‘] = "net.if.out[eth0]"    items[‘net_in_win_vm‘] = "net.if.in[Red Hat VirtIO Ethernet Adapter]"    items[‘net_in_win_vm_2‘] = "net.if.in[Red Hat VirtIO Ethernet Adapter #2]"    items[‘net_in_win_vm_3‘] = "net.if.in[Red Hat VirtIO Ethernet Adapter #3]"    items[‘net_out_win_vm‘] = "net.if.out[Red Hat VirtIO Ethernet Adapter]"    items[‘net_out_win_vm_2‘] = "net.if.out[Red Hat VirtIO Ethernet Adapter #2]"    items[‘net_out_win_vm_3‘] = "net.if.out[Red Hat VirtIO Ethernet Adapter #3]"    items[‘net_in_phy_web‘] = "net.if.in[bond0]"    items[‘net_out_phy_web‘] = "net.if.out[bond0]"    items[‘net_in_phy_db‘] = "net.if.in[bond0]"    items[‘net_out_phy_db‘] = "net.if.out[bond0]"    items[‘net_in_phy_web‘] = "net.if.in[TEAM : WEB-TEAM]"    items[‘net_out_phy_web‘] = "net.if.in[TEAM : WEB-TEAM]"    items[‘net_in_phy_db‘] = "net.if.in[TEAM : DB Team]"    items[‘net_out_phy_db‘] = "net.if.out[TEAM : DB Team]"    items[‘iis_conntion‘] = "perf_counter[\\Web Service(_Total)\\Current Connections]"    items[‘tcp_conntion‘] = "k.tcp.conn[ESTABLISHED]"    for x,y in items.items():        print x,y,dip        os.system(‘mkdir -p /data/zabbix/cvs/%s‘ % dip)        cmds = """         python /data/zabbix/fetch_items_to_csv.py -s ‘%s‘ -n ‘%s‘ -k ‘%s‘ -u ‘%s‘ -p ‘%s‘ -t1 ‘2015-06-23 00:00:01‘ -t2 ‘2015-06-30 00:00:01‘ -o /data/zabbix/cvs/%s/%s_%s.cvs""" %(moniter,dip,y,users,pawd,dip,dip,x)                 os.system(cmds)def work():    moniter=‘192.168.1.1‘    ip_list = [‘192.168.1.11‘,‘192.168.1.2‘,‘192.168.1.3‘,‘192.168.1.10‘]    for ip in ip_list:        show_items(moniter,ip )if __name__ == "__main__":    sc = work()


本文出自 “歡迎評論,歡迎點贊” 部落格,請務必保留此出處http://swq499809608.blog.51cto.com/797714/1671360

如何採用Python zabbix_api 擷取效能資料

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.