#!/usr/bin/env python#-*-coding:utf-8-*-import oszabbix_server_ip= ' 10.171.100.28 ' is_running = Os.popen ("Ps-ef | grep Zabbix_agentd | Grep-v grep | Wc-l ") is_installed = Os.popen (" Find/usr/local-name ' zabbix_* ' | Wc-l ") if Int (Is_running.read (). Strip ()) or int (Is_installed.read (). Strip ()): print" "" ***************************** Zabbix_agentd installed, to reload, remove/usr/local/zabbix-agent/************************* "" "Os._exit (0) print ' Select the type of monitored machine: 1-web,2-oracle,3-mysql,4-redis,q-quit ' Choice = Raw_input () result = "if choice = = ' 1 ': result = ' web_ ' elif choice = = ' 2 ': result = ' Oracle_ ' elif choice = = ' 3 ': result = ' Mysql_ ' elif choice = = ' 4 ': result = ' Redis_ ' else:os._exit (0) print ' ... Create Zabbix user ' G = Os.system (' cat/etc/group | grep zabbix ') if g! = 0:os.system (' Groupadd Zabbix ') else:print ' ... Zabb The IX group already exists ' U = Os.system (' cat/etc/passwd | grep zabbix ') if u! = 0:os.system (' Useradd-g zaBbix zabbix-s/sbin/nologin ') print ' ... Zabbix user creation successful ' else:print ' ... Zabbix user already exists ' print ' ... Download Zabbix Install package ' os.chdir ('/tmp ') Os.system (' wget http://10.171.100.28/download/zabbix-3.2.7.tar.gz ') print ' ... Download finished, start extracting ' Os.system (' tar-zxvf zabbix-3.2.7.tar.gz ') print ' ... After extracting, start installing ' os.chdir ('/tmp/zabbix-3.2.7 ') Os.system ('./configure--prefix=/usr/local/zabbix-agent--enable-agent ') Os.system (' make install ') print ' ... Get the native IP ' Myip = os.popen ("IP Add show | grep inet | grep eth0 | awk ' {print $} ' | awk-f/' {print $} ' | Head-n 1 ") Myip = Myip.read (). Strip () print (' ... Configuration zabbix_agentd.conf ') hostname=result+myipf = open ('/usr/local/zabbix-agent/etc/zabbix_agentd.conf ', ' W ') F.write ( "" "logfile=/var/log/zabbix/zabbix_agentd.logserver=%shostname=%s" ""% (zabbix_server_ip,hostname)) F.close print (' ... Configuration zabbix_agentd.conf complete ') os.system (' Mkdir/var/log/zabbix ') os.system (' Touch/var/log/zabbix/zabbix_agentd.log ') Os.system (' Chown zabbix:zabbix/var/log/zabbix/zabbix_agentd.log ') os.system (' Rm-rf/tmp/zabbix* ') print "" ************************************************************ the ZABBIX_AGENTD is installed * * * now run * */usr/local/zabbix-agent/sbin/zabbix_agentd *********************************************************** *"""
Note:
Use
' wget http://10.171.100.28/download/zabbix-3.2.7.tar.gz ' Download the file, you need to configure the following in Nginx
and copy the zabbix-3.2.7.tar.gz installation package into the appropriate directory.
Auto-Install Zabbix_agent script--Python2