注:本文基於:https://blog.51cto.com/14227204/2474670web
1、自動發現:
一、部署安裝agent端:ide
[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 ]
二、登陸到zabbix web界面操做
建立自動發現規則
建立自動發現動做
2、自動註冊
自動註冊比自動發現配置少、方便,自動註冊是客戶端向服務端發送數據rest
#須要在原有配置文件上更改以下 [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