注:本文基于:https://blog.51cto.com/14227204/2474670

一、自动发现:
1、部署安装agent端:

[root@agent /]# mkdir /zabbix          # 个人习惯,可忽略
[root@agent /]# cd /zabbix/
[root@agent /]# rz
[root@agent zabbix]# tar zxf zabbix-3.2.1.tar.gz 
[root@agent zabbix]# cd zabbix-3.2.1/
[root@agent zabbix-3.2.1]# useradd -M -s /sbin/nologin  zabbix
[root@agent zabbix-3.2.1]# ./configure --prefix=/usr/local/zabbix --enable-agent && make && make install
[root@agent zabbix-3.2.1]# cp misc/init.d/fedora/core/zabbix_agentd /etc/init.d/
[root@agent /]# sed -i 's/BASEDIR=\/usr\/local/BASEDIR=\/usr\/local\/zabbix/g' /etc/init.d/zabbix_agentd 
[root@agent /]# sed -i 's/PIDFILE=\/tmp\/$BINARY_NAME.pid/PIDFILE=$BASEDIR\/logs\/$BINARY_NAME.pid/g' /etc/init.d/zabbix_agentd 
[root@agent /]# chmod +x /etc/init.d/zabbix_agentd
[root@agent /]# sed -i 's/# PidFile=\/tmp\/zabbix_agentd.pid/PidFile=\/usr\/local\/zabbix\/logs\/zabbix_agentd.pid/g' /usr/local/zabbix/etc/zabbix_agentd.conf
[root@agent /]# sed -i 's/LogFile=\/tmp\/zabbix_agentd.log/LogFile=\/usr\/local\/zabbix\/logs\/zabbix_agentd.log/g' /usr/local/zabbix/etc/zabbix_agentd.conf
[root@agent /]# sed -i 's/Server=127.0.0.1/Server=192.168.171.133/g' /usr/local/zabbix/etc/zabbix_agentd.conf
[root@agent /]# sed -i 's/# ListenPort=10050/ListenPort=10050/g' /usr/local/zabbix/etc/zabbix_agentd.conf
[root@agent /]# sed -i 's/ServerActive=127.0.0.1/ServerActive=192.168.171.133/g' /usr/local/zabbix/etc/zabbix_agentd.conf
[root@agent /]# sed -i 's/Hostname=Zabbix server/Hostname=192.168.171.134/g' /usr/local/zabbix/etc/zabbix_agentd.conf
[root@agent /]# sed -i 's/# Timeout=3/Timeout=15/g' /usr/local/zabbix/etc/zabbix_agentd.conf
[root@agent /]# sed -i 's/# Include=\/usr\/local\/etc\/zabbix_agentd.conf.d\//Include=\/usr\/local\/zabbix\/etc\/zabbix_agentd.conf.d\//g' /usr/local/zabbix/etc/zabbix_agentd.conf
[root@agent /]# egrep -v '^$|^#' /usr/local/zabbix/etc/zabbix_agentd.conf 
PidFile=/usr/local/zabbix/logs/zabbix_agentd.pid
LogFile=/usr/local/zabbix/logs/zabbix_agentd.log
Server=192.168.171.133
ListenPort=10050
ServerActive=192.168.171.133
Hostname=192.168.171.134
Timeout=15
Include=/usr/local/zabbix/etc/zabbix_agentd.conf.d/
[root@agent /]# mkdir -p /usr/local/zabbix/logs       # 创建日志存放路径
[root@agent /]# chown -R zabbix:zabbix /usr/local/zabbix/     # 赋予权限
[root@agent /]# /etc/init.d/zabbix_agentd start           # 启动agent
Reloading systemd:                                         [  OK  ]
Starting zabbix_agentd (via systemctl):                    [  OK  ]

2、登录到zabbix web界面操作
创建自动发现规则


创建自动发现动作






二、自动注册
自动注册比自动发现配置少、方便,自动注册是客户端向服务端发送数据

#需要在原有配置文件上更改如下
[root@agent /]# sed -i 's/# HostMetadataItem=/HostMetadataItem=system.uname/g' /usr/local/zabbix/etc/zabbix_agentd.conf
[root@agent /]# /etc/init.d/zabbix_agentd restart