1、安装说明: 找一台测试机,然后还用zabbix_server 的安装包来安装
[root@192 local]# tar -xf zabbix-4.0.1.tar.gz
[root@192 local]# cd zabbix-4.0.1
[root@192 zabbix-4.0.1]# useradd zabbix -s /sbin/nologin -M
[root@192 zabbix-4.0.1]# yum -y install mysql-devel libcurl-devel net-snmp-devel php-bcmath php-ldap php-mbstring php-gd php-xmlwriter libevent-devel libevent pcre* gcc gcc-c++ libxml2-devel libcurl-devel
[root@192 zabbix-4.0.1]# ./configure --prefix=/usr/local/zabbix --enable-server --enable-agent --with-mysql --with-net-snmp --with-libcurl --with-libxml2
[root@192 zabbix-4.0.1]# make && make install
[root@bogon zabbix-4.0.1]# sed -i "94c Server=192.168.1.204" /usr/local/zabbix/etc/zabbix_agentd.conf
[root@bogon zabbix-4.0.1]# sed -i "135c ServerActive=192.168.1.204" /usr/local/zabbix/etc/zabbix_agentd.conf
[root@bogon zabbix-4.0.1]# sed -i "290c UserParameter=login-user,who|wc -l" /usr/local/zabbix/etc/zabbix_agentd.conf
[root@www ~]# sed -i 's/Server=192.168.1.206/Server=192.168.1.204/g' /usr/local/zabbix/etc/zabbix_agentd.conf
[root@www ~]# sed -i 's/ServerActice=192.168.1.206/ServerActice=192.168.1.204/g' /usr/local/zabbix/etc/zabbix_agentd.conf
[root@www ~]# sed -i 's/# Hostname=/Hostname=www.test3.com/g' /usr/local/zabbix/etc/zabbix_agentd.conf #这个主机名是客户端的主机名,不要写成server的
2、创建启动文件
cat >> /etc/init.d/zabbix_agentd << EOF #!/bin/bash # # chkconfig: - 90 10 # description: Starts and stops Zabbix Agent using chkconfig # Tested on Fedora Core 2 - 5 # Should work on all Fedora Core versions # # @name: zabbix_agentd # @author: Alexander Hagenah <hagenah@topconcepts.com> # @created: 18.04.2006 # # Modified for Zabbix 2.0.0 # May 2012, Zabbix SIA # # Source function library. . /etc/init.d/functions # Variables # Edit these to match your system settings # Zabbix-Directory BASEDIR=/usr/local/zabbix # Binary File BINARY_NAME=zabbix_agentd # Full Binary File Call FULLPATH=$BASEDIR/sbin/$BINARY_NAME # PID file PIDFILE=/tmp/$BINARY_NAME.pid # Establish args ERROR=0 STOPPING=0 # # No need to edit the things below # # application checking status if [ -f $PIDFILE ] && [ -s $PIDFILE ] then PID=`cat $PIDFILE` if [ "x$PID" != "x" ] && kill -0 $PID 2>/dev/null && [ $BINARY_NAME == `ps -e | grep $PID | awk '{print $4}'` ] then STATUS="$BINARY_NAME (pid `pidof $APP`) running.." RUNNING=1 else rm -f $PIDFILE STATUS="$BINARY_NAME (pid file existed ($PID) and now removed) not running.." RUNNING=0 fi else if [ `ps -e | grep $BINARY_NAME | head -1 | awk '{ print $1 }'` ] then STATUS="$BINARY_NAME (pid `pidof $APP`, but no pid file) running.." else STATUS="$BINARY_NAME (no pid file) not running" fi RUNNING=0 fi # functions start() { if [ $RUNNING -eq 1 ] then echo "$0 $ARG: $BINARY_NAME (pid $PID) already running" else action $"Starting $BINARY_NAME: " $FULLPATH touch /var/lock/subsys/$BINARY_NAME fi } stop() { echo -n $"Shutting down $BINARY_NAME: " killproc $BINARY_NAME RETVAL=$? echo [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$BINARY_NAME RUNNING=0 } # logic case "$1" in start) start ;; stop) stop ;; status) status $BINARY_NAME ;; restart) stop sleep 10 start ;; help|*) echo $"Usage: $0 {start|stop|status|restart|help}" cat <<EOF start - start $BINARY_NAME stop - stop $BINARY_NAME status - show current status of $BINARY_NAME restart - restart $BINARY_NAME if running by sending a SIGHUP or start if not running help - this screen EOF exit 1 ;; esac exit 0 EOF
3、启动zabbix_agent
[root@bogon init.d]# /etc/init.d/zabbix_agentd start
Starting zabbix_agentd (via systemctl): [ OK ]
4、停止zabbix_agent
[root@bogon init.d]# /etc/init.d/zabbix_agentd stop
Stopping zabbix_agentd (via systemctl): [ OK ]
5、设置开机自启
添加开机自启文件
cat >> /lib/systemd/system/zabbix_agent.service << EOF
#!/bin/bash
[Unit]
Description=zabbix
After=network.target
[Service]
Type=forking
ExecStart=/etc/init.d/zabbix_agentd start
ExecStop=/etc/init.d/zabbix_agentd stop
PrivateTmp=true
[Install]
WantedBy=multi-user.target
EOF
启动zabbix_agent
systemctl start zabbix_agent
停止zabbix_agent
systemctl stop zabbix_agent
设置开机自启
systemctl enable zabbix_agent
参照文档
https://blog.csdn.net/baidu_38432732/article/details/84329003
http://www.cnblogs.com/smlile-you-me/p/10015826.html