zabbix是一个基于WEB界面的提供分布式系统监视以及网络监视功能的企业级的开源解决方案。zabbix能监视各种网络参数,保证服务器系统的安全运营;并提供灵活的通知机制以让系统管理员快速定位/解决存在的各种问题。zabbix由2部分构成,zabbix server与可选组件zabbix agent。zabbix server可以通过SNMP,zabbix agent,ping,端口监视等方法提供对远程服务器/网络状态的监视,数据收集等功能,它可以运行在Linux,Solaris,HP-UX,AIX,Free BSD,Open BSD,OS X等平台上。

zabbix对对象的监控可以是主动式也可以被动式,在下面先演示被动式监控linux主机的基本配置,需要对被监控对象安装agent,才能收集到监控对象中定义好的数据,并用图表方式展示在网页上。


1. 被监控的Linux主机上安装zabbix-agent及配置

下面所有的配置是在上篇博文基础上继续演进进行配置。

[root@CentOS84-IP68 ]#rpm -Uvh https://repo.zabbix.com/zabbix/6.0/rhel/8/x86_64/zabbix-release-6.0-1.el8.noarch.rpm

[root@CentOS84-IP68 ]#dnf clean all
[root@CentOS84-IP68 ]#dnf -y install zabbix-agent

[root@CentOS84-IP68 ]#vim /etc/zabbix/zabbix_agentd.conf
[root@CentOS84-IP68 ]#grep "^[a-Z]" /etc/zabbix/zabbix_agentd.conf
PidFile=/run/zabbix/zabbix_agentd.pid
LogFile=/var/log/zabbix/zabbix_agentd.log
LogFileSize=0
Server=192.168.250.18
ListenPort=10050
ListenIP=0.0.0.0
StartAgents=3
ServerActive=127.0.0.1
Hostname=192.168.250.68
Include=/etc/zabbix/zabbix_agentd.d/*.conf
[root@CentOS84-IP68 ]#

[root@CentOS84-IP68 ]#systemctl restart zabbix-agent
[root@CentOS84-IP68 ]#systemctl status zabbix-agent
● zabbix-agent.service - Zabbix Agent
Loaded: loaded (/usr/lib/systemd/system/zabbix-agent.service; disabled; vendor preset: disabled)
Active: active (running) since Mon 2022-05-09 00:50:24 CST; 10s ago
Process: 109238 ExecStart=/usr/sbin/zabbix_agentd -c $CONFFILE (code=exited, status=0/SUCCESS)
Main PID: 109240 (zabbix_agentd)
Tasks: 6 (limit: 23544)
Memory: 3.9M
CGroup: /system.slice/zabbix-agent.service
├─109240 /usr/sbin/zabbix_agentd -c /etc/zabbix/zabbix_agentd.conf
├─109241 /usr/sbin/zabbix_agentd: collector [idle 1 sec]
├─109242 /usr/sbin/zabbix_agentd: listener #1 [waiting for connection]
├─109243 /usr/sbin/zabbix_agentd: listener #2 [waiting for connection]
├─109244 /usr/sbin/zabbix_agentd: listener #3 [waiting for connection]
└─109245 /usr/sbin/zabbix_agentd: active checks #1 [idle 1 sec]

May 09 00:50:24 CentOS84-IP68 systemd[1]: Starting Zabbix Agent...
May 09 00:50:24 CentOS84-IP68 systemd[1]: Started Zabbix Agent.
[root@CentOS84-IP68 ]#ps -ef | grep zabbix
zabbix 109240 1 0 00:50 ? 00:00:00 /usr/sbin/zabbix_agentd -c /etc/zabbix/zabbix_agentd.conf
zabbix 109241 109240 0 00:50 ? 00:00:00 /usr/sbin/zabbix_agentd: collector [idle 1 sec]
zabbix 109242 109240 0 00:50 ? 00:00:00 /usr/sbin/zabbix_agentd: listener #1 [waiting for connection]
zabbix 109243 109240 0 00:50 ? 00:00:00 /usr/sbin/zabbix_agentd: listener #2 [waiting for connection]
zabbix 109244 109240 0 00:50 ? 00:00:00 /usr/sbin/zabbix_agentd: listener #3 [waiting for connection]
zabbix 109245 109240 0 00:50 ? 00:00:00 /usr/sbin/zabbix_agentd: active checks #1 [idle 1 sec]
root 109257 73258 0 00:50 pts/0 00:00:00 grep --color=auto zabbix
[root@CentOS84-IP68 ]#pstree -p 109240
zabbix_agentd(109240)─┬─zabbix_agentd(109241)
├─zabbix_agentd(109242)
├─zabbix_agentd(109243)
├─zabbix_agentd(109244)
└─zabbix_agentd(109245)
[root@CentOS84-IP68 ]#ss -tln |grep 10050
LISTEN 0 128 0.0.0.0:10050 0.0.0.0:*
[root@CentOS84-IP68 ]#tail -n10 /var/log/zabbix/zabbix_agentd.log
109240:20220509:005024.222 **************************
109240:20220509:005024.222 using configuration file: /etc/zabbix/zabbix_agentd.conf
109240:20220509:005024.223 agent #0 started [main process]
109241:20220509:005024.223 agent #1 started [collector]
109242:20220509:005024.224 agent #2 started [listener #1]
109243:20220509:005024.224 agent #3 started [listener #2]
109244:20220509:005024.225 agent #4 started [listener #3]
109245:20220509:005024.226 agent #5 started [active checks #1]
109245:20220509:005024.230 Unable to connect to [127.0.0.1]:10051 [cannot connect to [[127.0.0.1]:10051]: [111] Connection refused]
109245:20220509:005024.230 Active check configuration update started to fail
[root@CentOS84-IP68 ]#

2. Zabbix 上添加Linux主机


实战案例:Zabbix对Linux主机监控_zabbix监控Linux主机


3. 查看监控效果图

实战案例:Zabbix对Linux主机监控_zabbix监控Linux主机_02


实战案例:Zabbix对Linux主机监控_zabbix监控Linux主机_03