欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  科技

zabbix安装

程序员文章站 2023-12-25 16:27:21
闲来无事,写了个zabbix-server的安装脚本 #!/bin/bash #Install system is ubuntu14.0+ #zabbix-agent and zabbix-server is version:3.4 ZABBIX_USER=zabbix ZABBIX_GROUP=z ......
闲来无事,写了个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

上一篇:

下一篇: