zabbix-agent 客户端安装脚本 3.4.11
一、zabbix agent 3.4.11 客户端一键安装脚本 (CentOS 7测试OK)
# cat zabbix_agent_3.4.11.sh
#!/bin/bash
HOST=`ifconfig | sed -n '2p' | awk '{print $2}'`
function zabbix_agentd_install(){
groupadd zabbix
useradd -g zabbix zabbix
tar zxvf zabbix-3.4.11.tar.gz
cd zabbix-3.4.11
./configure --prefix=/usr/local/zabbix_agent --enable-agent
make; make install
cat >>/etc/services<<EOF
zabbix-agent 10050/tcp Zabbix Agent
zabbix-agent 10050/udp Zabbix Agent
zabbix-trapper 10051/tcp Zabbix Trapper
zabbix-trapper 10051/udp Zabbix Trapper
EOF
sed -i -e '93s/.*/Server=192.168.56.200/' -e "145s/.*/Hostname="${HOST}"/" -e '134s/.*/ServerActive=192.168.56.200/' /usr/local/zabbix_agent/etc/zabbix_agentd.conf
cp misc/init.d/fedora/core/zabbix_agentd /etc/init.d/
chmod a+x /etc/init.d/zabbix_*
chkconfig --add zabbix_agentd
chkconfig --level 345 zabbix_agentd on
sed -i -e '22s/.*/BASEDIR=\/usr\/local\/zabbix_agent/' -e '28 aCONF_FILE=$BASEDIR/etc/zabbix_agentd.conf' -e '71s/.*/action $"Starting $BINARY_NAME: " $FULLPATH -c $CONF_FILE/' /etc/init.d/zabbix_agentd
systemctl daemon-reload
service zabbix_agentd start
ln -s /usr/local/zabbix_agent/sbin/* /usr/sbin/
ln -s /usr/local/zabbix_agent/bin/* /usr/bin/
}
zabbix_agentd_install
// 生产配置
#!/bin/bash
HOST=`ifconfig | sed -n '2p' | awk '{print $2}'`
function zabbix_agentd_install(){
groupadd zabbix
useradd -g zabbix zabbix
tar zxvf zabbix-3.4.11.tar.gz
cd zabbix-3.4.11
./configure --prefix=/usr/local/zabbix_agent --enable-agent
make; make install
cat >>/etc/services<<EOF
zabbix-agent 10050/tcp Zabbix Agent
zabbix-agent 10050/udp Zabbix Agent
zabbix-trapper 10051/tcp Zabbix Trapper
zabbix-trapper 10051/udp Zabbix Trapper
EOF
sed -i -e '93s/.*/Server=10.14.4.102/' -e "145s/.*/Hostname="${HOST}"/" -e '134s/.*/ServerActive=10.14.4.102/' /usr/local/zabbix_agent/etc/zabbix_agentd.conf
cp misc/init.d/fedora/core/zabbix_agentd /etc/init.d/
chmod a+x /etc/init.d/zabbix_*
chkconfig --add zabbix_agentd
chkconfig --level 345 zabbix_agentd on
sed -i -e '22s/.*/BASEDIR=\/usr\/local\/zabbix_agent/' -e '28 aCONF_FILE=$BASEDIR/etc/zabbix_agentd.conf' -e '71s/.*/action $"Starting $BINARY_NAME: " $FULLPATH -c $CONF_FILE/' /etc/init.d/zabbix_agentd
systemctl daemon-reload
service zabbix_agentd start
ln -s /usr/local/zabbix_agent/sbin/* /usr/sbin/
ln -s /usr/local/zabbix_agent/bin/* /usr/bin/
}
zabbix_agentd_install
二、安装过程故障问题排查
1、编译安装过程中报错,信息如下:
checking for architecture... linux (linux-gnu) checking for the linux kernel version... unknown family (3.10.0-862.el7.x86_64) checking size of void *... 8 checking for libpcre support... no configure: error: Unable to use libpcre (libpcre check failed)
解决方法:
yum -y install pcre*

浙公网安备 33010602011771号