zabbix server安装
闲来无事,写了个zabbix-server的安装脚本
#!/bin/bash #Install system is ubuntu14.0+ #zabbix-agent and zabbix-server is version:3.4 ZABBIX_USER=zabbix ZABBIX_GROUP=zabbix ZABBIX_HOSTNAME=`hostname` ZABBIX_DIR=/usr/local/zabbix ZABBIX_CONF=$ZABBIX_DIR/etc/ ZABBIX_AGENAME=zabbix_agentd.conf ZABBIX_SERNAME=zabbix_server.conf ZABBIX_AGE=zabbix-agent ZABBIX_SER=zabbix-server ZABBIX_SER_DIR=/etc/init.d/ ZABBIX_PRO=$ZABBIX_DIR/sbin ZABBIX_PHP=/etc/php5/apache2/ ZABBIX_PHP_CON=php.ini ZABBIX_DATA=zabbix MYSQL_INF=`dpkg -l mysql-server php5 apache2` if [ $? -eq 0 ]; then echo $MYSQL_INF else echo $MYSQL_INF exit 0 fi PIN=`ping cn.archive.ubuntu.com -c 3 | wc -l` if [ $PIN -eq 8 ]; then # apt-get update apt-get install -y gcc make default-jdk \ libcurl4-openssl-dev libssh2-1-dev \ libsnmp-dev snmp zabbix-server-mysql \ zabbix-frontend-php mysql-server \ mysql-client libmysqlclient-dev \ libevent-dev libpcre3-dev daemon else echo 'Unable to connect to the network...' exit 0 fi if [ -d $ZABBIX_DIR ]; then echo "zabbix is install Directory $ZABBIX_DIR" else echo "clear zabbix install Directory $ZABBIX_DIR" mkdir -p $ZABBIX_DIR fi tar zxf zabbix_3.4.1.orig.tar.gz cd zabbix-3.4.1 if [ $? -eq 0 ]; then groupadd $ZABBIX_USER useradd -g $ZABBIX_USER $ZABBIX_USER -s /sbin/nologin ./configure --prefix=$ZABBIX_DIR \ --enable-server \ --enable-agent \ --enable-ipv6 \ --enable-java \ --with-mysql \ --with-net-snmp \ --with-libcurl \ --enable-proxy \ --with-ssh2 \ --enable-java && sudo make && sudo make install cp misc/init.d/debian/$ZABBIX_AGE $ZABBIX_SER_DIR cp misc/init.d/debian/$ZABBIX_SER $ZABBIX_SER_DIR #php.ini config sed -i "s@post_max_size = 8M@post_max_size = 16M@g" $ZABBIX_PHP$ZABBIX_PHP_CON sed -i "s@max_execution_time = 30@max_execution_time = 300@g" $ZABBIX_PHP$ZABBIX_PHP_CON sed -i "s@max_input_time = 60@max_input_time = 300@g" $ZABBIX_PHP$ZABBIX_PHP_CON sed '879 adate.timezone = "Asia/Shanghai"' -i $ZABBIX_PHP$ZABBIX_PHP_CON #zabbix_agent.conf sed -i "s@DAEMON=/usr/local/sbin@DAEMON=$ZABBIX_PRO@g" $ZABBIX_SER_DIR$ZABBIX_SER sed -i "s@Server=127.0.0.1@Server=192.168.20.101@g" $ZABBIX_CONF$ZABBIX_NAME sed -i "s@ServerActive=127.0.0.1@ServerActive=192.168.20.101@g" $ZABBIX_CONF$ZABBIX_NAME sed -i "s@Hostname=Zabbix server@Hostname=$ZABBIX_HOSTNAME@g" $ZABBIX_CONF$ZABBIX_NAME #zabbix_server.conf sed -i "s@# DBHost=localhost@DBHost=localhost@g" $ZABBIX_CONF$ZABBIX_SERNAME sed -i "s@# DBPassword=@DBPassword=zabbix@g" $ZABBIX_CONF$ZABBIX_SERNAME sed -i "s@DAEMON=/usr/local/sbin@DAEMON=$ZABBIX_PRO@g" $ZABBIX_SER_DIR$ZABBIX_SER #zabbix mysql initialization mysql -uroot -p'zabbix' -e "create database $ZABBIX_DATA character set utf8;" mysql -uroot -p'zabbix' -e "grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix';" mysql -uroot -p'zabbix' -e "flush privileges;" mysql -uroot -p'zabbix' $ZABBIX_DATA < database/mysql/schema.sql mysql -uroot -p'zabbix' $ZABBIX_DATA < database/mysql/images.sql mysql -uroot -p'zabbix' $ZABBIX_DATA < database/mysql/data.sql #zabbix server chown -R $ZABBIX_USER:$ZABBIX_GROUP $ZABBIX_DIR $ZABBIX_SER_DIR$ZABBIX_AGE start $ZABBIX_SER_DIR$ZABBIX_SER start else exit 0 fi