Zabbix Agent安装和配置
1.下载安装包(zabbix-2.2.4.tar.gz)
http://www.zabbix.com/download.php 由于目前server安装的最新稳定版本2.2.4,所以agent端安装不得高于server端版本,且agent端一般改动比较小,所以安装2.2.1(stable)和2.2.4(stable)都行. 说明:由于线上已经安装了一套agent环境,为了不引起冲突,所以本次安装时,选择了源码编译,自己指定安装路径和进程启动用户.正常情况下建议使用rpm安装.
2.安装
2.1 zabbix安装目录: /etc/zabbix_agentd_om
mkdir -p /etc/zabbix_agentd_om
2.2 进程启动用户zabbix:
groupadd zabbix -g 200
useradd zabbix -g zabbix -u 200
2.3 创建log和pid文件目录
mkdir -p /var/log/zabbix
chown zabbix:zabbix /var/log/zabbix
mkdir -p /var/run/zabbix
chown zabbix:zabbix /var/run/zabbix
2.4 安装
tar zxvf zabbix-2.2.4.tar.gz
cd zabbix-2.2.4
./configure --prefix=/etc/zabbix_agentd_om --enable-agent
make && make install
3.修改配置
mkdir -p /etc/zabbix_agentd_om/etc/zabbix_agentd.conf.d/
cat /dev/null > /etc/zabbix_agentd_om/etc/zabbix_agentd.conf
vi /etc/zabbix_agentd_om/etc/zabbix_agentd.conf
PidFile=/var/run/zabbix/zabbix_agented_om.pid
LogFile=/var/log/zabbix/zabbix_agented_om.log
LogFileSize=0
erver=42.62.**.**
ListenPort=10060
ServerActive=42.62.**.**
Hostname=Zabbix server
Include=/etc/zabbix_agentd_om/etc/zabbix_agentd.conf.d/
4.开启和关闭脚本添加
将以下脚本添加到/etc/init.d/目录下,并给予执行权限 cat /etc/init.d/zabbix_agent_om
#!/bin/sh
# chkconfig: - 86 14
# description: Zabbix agent daemon
# processname: zabbix_agentd
# config: /etc/zabbix_agentd_om/etc/zabbix_agentd.conf
# Source function library.
. /etc/rc.d/init.d/functions
if [ -x /etc/zabbix_agentd_om/sbin/zabbix_agentd ]; then
exec=etc/zabbix_agentd_om/sbin/zabbix_agentd
else
exit 5
fi
prog=${exec##*/}
conf=/etc/zabbix_agentd_om/etc/zabbix_agentd.conf
lockfile=/var/lock/subsys/zabbix-agented
start()
{
echo -n $"Starting Zabbix agent: "
daemon $exec -c $conf
rv=$?
echo
[ $rv -eq 0 ] && touch $lockfile
return $rv
}
stop()
{
echo -n $"Shutting down Zabbix agent: "
killall -u zabbix
rv=$?
echo
[ $rv -eq 0 ] && rm -f $lockfile
return $rv
}
restart()
{
stop
start
}
case "$1" in
start|stop|restart)
$1
;;
force-reload)
restart
;;
status)
status $prog
;;
*)
echo $"Usage: $0 {start|stop|status|restart|try-restart|force-reload}"
exit 2
;;
esac
5.开启和关闭方法:
chmod 755 /etc/init.d/zabbix_agent_om
service zabbix_agent_om start
service zabbix_agent_om stop
6.设置开机启动:
chkconfig --add zabbix_agent_om
chkconfig zabbix_agent_om on
7.防火墙设置
在agent需要允许能和server端通讯,记得保存iptables.