本文共 2132 字,大约阅读时间需要 7 分钟。
-
-
-
-
-
-
-
-
- import os,re,sys,urllib,wmi
-
- c = wmi.WMI ()
- for s in c.Win32_Service ():
- if s.Caption == "Zabbix Agent":
- sys.exit("zabbix already install")
-
- url = 'http://192.168.110.110/zabbix_agents_2.0.4.win.rar'
- local = 'C:\\zabbix_agents_2.0.4.win.rar'
- urllib.urlretrieve(url,local,)
- url = 'http://192.168.110.110/rar.exe'
- local = 'C:\\rar.exe'
- urllib.urlretrieve(url,local,)
- os.popen('C:\\rar.exe x -y C:\\zabbix_agents_2.0.4.win.rar -ed C:\\')
-
- sProgramFiles = os.environ['PROGRAMFILES']
- if "(86)" in sProgramFiles:
- os.popen('C:\\zabbix\\bin\\win64\\zabbix_agentd.exe -c C:\\zabbix\\conf\\zabbix_agentd.win.conf -i')
- else:
- os.popen('C:\\zabbix\\bin\\win32\\zabbix_agentd.exe -c C:\\zabbix\\conf\\zabbix_agentd.win.conf -i')
- #以下是添加windows网卡流量监控的自定key,注意:一般的执行命令或脚本自定义key格式为:UserParameter=keyname,commd,网卡的为 PerfCounter=keyname,""
- conm = os.popen('typeperf.exe -qx|find "Network Interface"|find "Bytes"|find /v "Total"|find /v "Loopback"').readlines()
- f=open('C:\zabbix\conf\zabbix_agentd.win.conf','a+')
- f.write('\n')
- e = 0
- for i in range(len(conm)):
- c = re.search('Sent',conm[i])
- if c:
- b = "PerfCounter " + "=" + " eth"+str(e) + "_Out," + '"'
-
-
-
-
-
-
-
- + str(conm[i]).strip() + '",30'
-
- f.write("%s \n" %b)
- e += 1
- f.close()
- ''
-
-
-
-
-
-
-
- os.popen('net start "Zabbix Agent"')
- os.popen('net stop "Zabbix Agent"')
- os.popen('net start "Zabbix Agent"')
- os.remove('C:\\rar.exe')
- os.remove('C:\\zabbix_agents_2.0.4.win.rar')
- sys.exit("zabbix install success !")
转载地址:http://ijdml.baihongyu.com/