安装Zabbix-agent环境

1 初始化环境
#192.168.0.161
setenforce 0
systemctl stop firewalld
systemctl enable firewalld
2 部署 Zabbix Agent

CentOS7.x操作系统安装:

rpm -Uvh https://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-2.el7.noarch.rpm
yum install zabbix-agent -y

CentOS6.x操作系统安装:

rpm -Uvh https://repo.zabbix.com/zabbix/4.0/rhel/6/x86_64/zabbix-release-4.0-2.el7.noarch.rpm
yum install zabbix-agent -y

修改配置文件:

# egrep -v "^#|^$" /etc/zabbix/zabbix_agentd.conf 
PidFile=/var/run/zabbix/zabbix_agentd.pid
LogFile=/var/log/zabbix/zabbix_agentd.log
LogFileSize=0
DebugLevel=3
Server=192.168.0.160
ListenPort=10050
ListenIP=192.168.0.161
ServerActive=192.168.0.160
Hostname=agent1
HostMetadata=vaedit test
Include=/etc/zabbix/zabbix_agentd.d/*.conf
UnsafeUserParameters=1

启动并加入开机启动:

systemctl start zabbix-agent
systemctl enable zabbix-agent

联通性测试

在Zabbix服务器执行以下命令,判断是否可以正常连接到Zabbix agent服务器。

/usr/local/zabbix/bin/zabbix_get -s 192.168.0.161 -p 10050 -k "system.uptime"

774564

返回数字说明连通正常。否则可能是被监控机防火墙阻断,无法连通,可以尝试在被监控机添加放行规则:

iptables -I INPUT -s 192.168.0.160 -p tcp --dport 10050 -j ACCEPT