快速搭建zabbix_agentd
这里用zabbix-2.2.3做例子,其它包也行
先下载包
wget http://jaist.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/2.2.3/zabbix-2.2.3.tar.gz
不同版本的zabbix.tar包:http://jaist.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/
注意:脚本zabbix.sh和包zabbix-2.2.3.tar.gz在同一目录下, 脚本里“服务端IP”自己要修改,如果你的zabbix包版本不一样,脚本里的包名也要修改
系统环境必须有yum源;如果没有yum源,系统至少有gcc和tar命令,然后将脚本里的两个yum命令删除,再运行脚本。
包下载完后编写脚本
vim zabbix.sh
_________________________________________________________________________________________________________________
#!/bin/bash
groupadd zabbix
useradd zabbix -g zabbix
yum install tar vim -y
yum groupinstall "development" -y
tar xzf zabbix-2.2.3.tar.gz
cd zabbix-2.2.3
./configure --prefix=/usr/local/zabbix --enable-agent
make install
cp misc/init.d/fedora/core/zabbix_agentd /etc/init.d/
chmod +x /etc/init.d/zabbix_agentd
f1=`sed -i '21d' /usr/local/zabbix/etc/zabbix_agentd.conf`
f2=`sed -i '80d' /usr/local/zabbix/etc/zabbix_agentd.conf`
f3=`sed -i '120d' /usr/local/zabbix/etc/zabbix_agentd.conf`
g1=`sed -i '22c BASEDIR=/usr/local/zabbix' /etc/init.d/zabbix_agentd`
h1=`echo "PidFile=/tmp/zabbix_agentd.pid" >> /usr/local/zabbix/etc/zabbix_agentd.conf`
h2=`echo "LogFile=/tmp/zabbix_agentd.log" >> /usr/local/zabbix/etc/zabbix_agentd.conf`
h3=`echo "Server=服务端IP" >> /usr/local/zabbix/etc/zabbix_agentd.conf`
h4=`echo "ServerActive=服务端IP:10051" >> /usr/local/zabbix/etc/zabbix_agentd.conf`
h5=`echo "UnsafeUserParameters=1" >>/usr/local/zabbix/etc/zabbix_agentd.conf`
i=`/etc/init.d/zabbix_agentd start`
j=`chkconfig zabbix_agentd on`
k=`setenforce 0`
l=`iptables -A INPUT -p tcp --dport 10050 -j ACCEPT`
m=`iptables -A INPUT -p udp --dport 10050 -j ACCEPT`
n=`service zabbix_agentd restart`
echo " 配置完成!!! "
exit 0
:wq
_________________________________________________________________________________________________________________
chmod +x zabbix.sh ------------- 给脚本赋予执行权限
./zabbix.sh --------------- 运行脚本
只需运行脚本完成后,客户端就搭建成功了