Zabbix Agent installation (source)

下载源文件:https://www.zabbix.com/download_sources

yum install -y gcc pcre*

groupadd --system zabbix useradd --system -g zabbix -d /zabbix -s /sbin/nologin -c "Zabbix Monitoring System" zabbix

mkdir -m u=rwx,g=rwx,o= -p /zabbix/{conf,log,bin,sbin}

chown -R zabbix:zabbix /zabbix

 

tar -xvf zabbix-5.2.4.tar.gz
cd zabbix-5.2.4

./configure --help

./configure --prefix=/zabbix  --sysconfdir=/zabbix/conf   --enable-agent

 

make clean
make install


cat >/etc/init.d/zabbix_agentd<<EOF
#!/bin/bash
#chkconfig:2345 85 15
#processname:zabbix_agentd
#description:zabbix_agentd server daemon

start(){
/zabbix/sbin/zabbix_agentd
/bin/echo "Starting zabbix_agentd...."
}
stop(){
for i in \`ps -ef|grep zabbix_agentd|grep -v grep|grep -v status|grep -v restart|awk '{if(\$8!="grep")print \$2;}'\`
do
kill -9 \$i
done
}
status(){
if [ \`ps -ef|grep zabbix_agentd|grep -v grep|grep -v status|awk '{if(\$8!="grep")print \$2;}'|wc -l\` -gt 0 ]
then
/bin/echo "\$0 zabbix_agentd is running...."
/bin/ps -ef|grep zabbix_agentd|grep -v grep |grep -v status
else
/bin/echo "\$0 zabbix_agentd is stopped"
fi
}
restart(){
stop
start
}
case "\$1" in
"start")
start
;;
"stop")
stop
;;
"status")
status
;;
"restart")
restart
;;
*)
echo "usage: \$0 start|stop|status|restart"
;;
esac
EOF

chmod 755 /etc/init.d/zabbix_agentd
chkconfig zabbix_agentd on
service zabbix_agentd start


如果有开启防火墙,则需开放端口:

firewall-cmd --zone=public --add-port=10050/tcp --permanent
firewall-cmd --reload
service zabbix_agentd restart






https://www.zabbix.com/documentation/current/manual/installation/install
posted @ 2020-12-25 16:17  sam_wang10  阅读(94)  评论(0编辑  收藏  举报