本文共 2098 字,大约阅读时间需要 6 分钟。
#/bin/bash
#auto install zabbix#by efoni 2018.7ZABBIX_SOFT="zabbix-3.2.6.tar.gz"
ZABBIX_DIR=echo $ZABBIX_SOFT|sed 's/\.tar.*//g'
INSTALL_DIR="/usr/local/zabbix/"SERVER_IP="192.168.189.201"IP=ifconfig|grep Bcast|awk '{print $2}'|sed 's/addr://g'
SERVER_INSTALL(){
yum -y install curl curl-devel net-snmp net-snmp-devel perl-DBIgroupadd zabbix ;useradd -g zabbix zabbix;usermod -s /sbin/nologin zabbixtar -xzf $ZABBIX_SOFT;cd echo $ZABBIX_SOFT|sed 's/.tar.*//g'
#config zabbix server
cat >$ZABBIX_DIR/etc/zabbix_server.conf<<EOFLogfile=/tmp/zabbix_server.logServer=$SERVER_IPServerActive=$SERVER_IPHostname=$IPEOF#start zabbix server and agentd
/etc/init.d/zabbix_server restart/etc/init.d/zabbix_agentd restart/etc/init.d/iptables stopsetenforce 0}AGENT_INSTALL(){
yum -y install curl curl-devel net-snmp net-snmp-devel perl-DBIgroupadd zabbix ;useradd -g zabbix zabbix;usermod -s /sbin/nologin zabbixtar -xzf #ZABBIX_SOFT;cdecho $ZABBIX_SOFT|sed 's/.tar.*//g'
./configure --prefix=/usr/local/zabbix --enable-agent&&make installif [ $? -eq 0 ];thenln -s /usr/local/zabbix/zabbix_* /usr/local/sbinficd - ;cd $ZABBIX_DIRcp misc/init.d/tru64/zabbix_agentd /etc/init.d/zabbix_agentd ;chmod o+x /etc/init.d/zabbix_agentd #config zabbix agentd
cat >$ZABBIX_DIR/etc/zabbix_agentd.conf<<EOFLogfile=/tmp/zabbix_agentd.logServer=$SERVER_IPServerActive=$SERVER_IPHostname=$IPEOF#start zabbix agentd
/etc/init.d/zabbix_agentd restart/etc/init.d/iptables stopsetenforce 0}read -p "please confirm whether to install zabbix server,yes or no?" INPUT
if [ $INPUT == "yes" -o $INPUT == "y" ];thenSERVER_INSTALLelseAGENT_INSTALLfi转载于:https://blog.51cto.com/efoni/2146275