zabbix agent一键安装脚本

       公司hadoop集群新增了datanode数据结点,需要为其添加zabbix监控,特写出如下脚本,提高安装效率。

       zabbix serve端采用zabbix-2.2.2版本,新增datanode机器上采用最用的zabbix-2.2.5版本,亲测两者兼容可用。OS环境均为:CentOS 6.4

   

脚本内容如下:       

#!/bin/bash
# By V_v
#zabbix server 端IP 地址
SERVER="zabbix server ip address"

#zabbix 版本号,也就是源码包.tar.gz前面的部分
VER="zabbix-2.2.5"

useradd zabbix 

yum -y groupinstall "Development tools"
tar xvf $VER.tar.gz
cd $VER
./configure --prefix=/usr/local/zabbix --enable-agent
make install
#该版本zabbix不需要make,直接make install即可,其它版本请酌情修改

echo "Installation completed !"

mkdir /var/log/zabbix
chown zabbix.zabbix /var/log/zabbix

cp misc/init.d/fedora/core/zabbix_agentd /etc/init.d/
chmod 755 /etc/init.d/zabbix_agentd

sed -i "s#BASEDIR=/usr/local#BASEDIR=/usr/local/zabbix#g" /etc/init.d/zabbix_agentd

ln -s /usr/local/zabbix/etc /etc/zabbix
ln -s /usr/loca/zabbix/bin/zabbix_get /usr/bin/
ln -s /usr/loca/zabbix/bin/zabbix_sender /usr/bin/
ln -s /usr/loca/zabbix/sbin/zabbix_agent /usr/sbin/
ln -s /usr/loca/zabbix/sbin/zabbix_agentd /usr/sbin/


echo "zabbix-agent 10050/tcp #Zabbix Agent" >> /etc/services
echo "zabbix-agent 10050/udp #Zabbix Agent" >> /etc/services
echo "zabbix-trapper 10051/tcp #Zabbix Trapper" >> /etc/services
echo "zabbix-trapper 10051/udp #Zabbix Trapper" >> /etc/services


sed -i "s/Server\=127.0.0.1/Server=$SERVER/g" /etc/zabbix/zabbix_agentd.conf
sed -i "s/ServerActive\=127.0.0.1/ServerActive=$SERVER:20051/g" /etc/zabbix/zabbix_agentd.conf
sed -i "s#tmp/zabbix_agedtd.log#var/log/zabbix/zabbix_agentd.log#g" /etc/zabbix/zabbix_agentd.conf
sed -i "s#UnsafeUserParameters=0#UnsafeUserParameters=1#g" /etc/zabbix/zabbix_agentd.conf
sed -i "s%# Include=/usr/local/etc/zabbix_agentd.userparams.conf%Include=/etc/zabbix/zabbix_agentd.conf.d/%g" /etc/zabbix/zabbix_agentd.conf


chkconfig zabbix_agentd on
service zabbix_agentd start

可点此直接下载:zabbix agent一键安装脚本