# 最近领导需要一份数据,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,time users=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()
时间: 2024-08-02 06:57:46