#!/bin/bash
#auto Install Zabbix
#by Max 2017
zabbix_soft= "Zabbix-2.0.6.tar.gz"
Install_dir= "/usr/local/zabbix/"
server_ip= "192.168.0.100"
ip= ' Ifconfig|grep Bcast|awk ' {print $} ' |sed ' s/addr://g '
Server_install () {
Yum-y Install Curl Curl-devel net-snmp net-snmp-devel perl-dbi
Groupadd Zabbix
Useradd-g Zabbix zabbix;usermod-s/sbin/nologin Zabbix
TAR-XZF $ZABBIX _soft
CD ' Echo $ZABBIX _soft|sed ' s/.tar.*//g '
./configure--prefix=/usr/local/zabbix--enable-server--enable-agent--with-mysql--enable-ipv6--WITH-NET-SNMP-- With-libcurl &&make Install
If [$?-eq 0];then
Ln-s/usr/local/zabbix/sbin/zabbix_*/usr/local/sbin/
Fi
CD-
CD zabbix-2.0.6
CP Misc/init.d/tru64/{zabbix_agentd,zabbix_server}/etc/init.d/
chmod o+x/etc/init.d/zabbix_*
Mkdir-p/var/www/html/zabbix/
Cp-a frontends/php/*/var/www/html/zabbix/
#config Zabbix Server
Cat > $INSTALL _dir/etc/zabbix_server.conf<<eof
Logfile=/tmp/zabbix_server.log
Dbhost=localhost
Dbname=zabbix
Dbuser=zabbix
dbpassword=123456
Eof
#config Zabbix Agentd
Cat > $INSTALL _dir/etc/zabbix_agentd.conf<<eof
Logfile=/tmp/zabbix_agentd.log
server= $SERVER _ip
Serveractive= $SERVER _ip
Hostname = $IP
Eof
#start Zabbix Agentd
/etc/init.d/zabbix_server restart
/etc/init.d/zabbix_agentd restart
/etc/init.d/iptables stop
Setenforce 0
}
Agent_install () {
Yum-y Install Curl Curl-devel net-snmp net-snmp-devel perl-dbi
Groupadd Zabbix
Useradd-g Zabbix zabbix;usermod-s/sbin/nologin Zabbix
TAR-XZF $ZABBIX _soft
CD ' Echo $ZABBIX _soft|sed ' s/.tar.*//g '
./configure--prefix=/usr/local/zabbix--enable-agent&&make Install
If [$?-eq 0];then
Ln-s/usr/local/zabbix/sbin/zabbix_*/usr/local/sbin/
Fi
CD-
CD zabbix-2.0.6
CP Misc/init.d/tru64/zabbix_agentd/etc/init.d/zabbix_agentd
chmod O+x/etc/init.d/zabbix_agentd
#config Zabbix Agentd
Cat > $INSTALL _dir/etc/zabbix_agentd.conf<<eof
Logfile=/tmp/zabbix_agentd.log
server= $SERVER _ip
Serveractive= $SERVER _ip
Hostname = $IP
Eof
#start Zabbix Agentd
/etc/init.d/zabbix_agentd restart
/etc/init.d/iptables stop
Setenforce 0
}
Read-p "Confirm whether to install Zabbix server,yes or no? [y/n] The INPUT
if [$INPUT = = "Y"];then
Server_install
Else
Agent_install
Fi
Shell Road--zabbix Automatic deployment