当前位置:网站首页>Zabbix agent主动模式的实现
Zabbix agent主动模式的实现
2022-07-04 07:08:00 【一直在努力学习的菜鸟】
Zabbix agent主动模式的实现
主动模式是由zabbix agent主动向zabbix server的10051端口发起TCP连接请求。因此主动模式下必须在zabbix agent配置文件中指定zabbix server的IP或者主机名(必须可以被解析为IP地址),在连接到zabbix server之前,zabbix agent是不知道自己要采集哪些数据以及间隔多久采集一次数据的,然后在连接到zabbix server以后获取到zabbix agent的监控项和数据采集间隔时间周期,然后再根据监控项采集数据并返回给zabbix server。在主动模式下不再需要zabbix server向zabbix agent发起连接请求,因此,主动模式在一定程度上可以减轻zabbix server打开的本地随机端口和进程数,在一定程度上可以减轻zabbix server的负载压力。
环境准备
四台机器:
zabbix_agent 5.0 被动模式(已安装) Zabbix_java_gateway 5.0 (已安装) 10.0.0.7
zabbix_server 5.0(已安装) 10.0.0.17
Tomcat-8.5(已安装) 10.0.0.27
zabbix_agent 5.0 主动模式 10.0.0.37
关闭防火墙和selinux
#关闭selinux
[[email protected] ~]#sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
#关闭防火墙
[[email protected] ~]#systemctl disable --now firewalld
#重启生效
[[email protected] ~]#reboot
1. 安装zabbix rpm源
[[email protected] ~]#rpm -Uvh https://mirrors.aliyun.com/zabbix/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
[[email protected] ~]#sed -i 's#http://repo.zabbix.com#https://mirrors.aliyun.com/zabbix#' /etc/yum.repos.d/zabbix.repo
[[email protected] ~]#yum clean all
2. 安装zabbix agent
[[email protected] ~]#yum install -y zabbix-agent
#编辑配置文件 /etc/yum.repos.d/zabbix.repo
[[email protected] ~]#vim /etc/yum.repos.d/zabbix.repo
[zabbix-frontend]
...
enabled=1
...
3. 修改zabbix agent配置文件
[[email protected] ~]#vim /etc/zabbix/zabbix_agentd.conf
Server=10.0.0.17
ListenPort=10050
ListenIP=0.0.0.0
StartAgents=5
ServerActive=10.0.0.17 #主动模式的zabbix server地址
Hostname=10.0.0.37
Timeout=30
[[email protected] ~]#grep "^[a-Z]" /etc/zabbix/zabbix_agentd.conf
PidFile=/var/run/zabbix/zabbix_agentd.pid
LogFile=/var/log/zabbix/zabbix_agentd.log
LogFileSize=0
Server=10.0.0.17
ListenPort=10050
ListenIP=0.0.0.0
StartAgents=5
ServerActive=10.0.0.17
Hostname=10.0.0.37
Timeout=30
Include=/etc/zabbix/zabbix_agentd.d/*.conf
4. 启动Zabbix agent进程
#启动Zabbix agent进程,并设置开机自启
[[email protected] ~]#systemctl restart zabbix-agent.service
[[email protected] ~]#systemctl enable zabbix-agent.service
[[email protected] ~]#systemctl status zabbix-agent.service
● zabbix-agent.service - Zabbix Agent
Loaded: loaded (/usr/lib/systemd/system/zabbix-agent.service; enabled; vendor preset: disabled)
Active: active (running) since Sat 2022-07-02 19:12:04 CST; 18s ago
Main PID: 1755 (zabbix_agentd)
CGroup: /system.slice/zabbix-agent.service
├─1755 /usr/sbin/zabbix_agentd -c /etc/zabbix/zabbix_agentd.conf
├─1756 /usr/sbin/zabbix_agentd: collector [idle 1 sec]
├─1757 /usr/sbin/zabbix_agentd: listener #1 [waiting for connection]
├─1758 /usr/sbin/zabbix_agentd: listener #2 [waiting for connection]
├─1759 /usr/sbin/zabbix_agentd: listener #3 [waiting for connection]
├─1760 /usr/sbin/zabbix_agentd: listener #4 [waiting for connection]
├─1761 /usr/sbin/zabbix_agentd: listener #5 [waiting for connection]
└─1762 /usr/sbin/zabbix_agentd: active checks #1 [idle 1 sec]
Jul 02 19:12:04 centos7 systemd[1]: Starting Zabbix Agent...
Jul 02 19:12:04 centos7 systemd[1]: Started Zabbix Agent.
#验证Zabbix agent进程是否存在
[[email protected] ~]#ss -ntlp
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 *:10050 *:*users:(("zabbix_agentd",pid=1762,fd=4),("zabbix_agentd",pid=1761,fd=4),("zabbix_agentd",pid=1760,fd=4),("zabbix_agentd",pid=1759,fd=4),("zabbix_agentd",pid=1758,fd=4),("zabbix_agentd",pid=1757,fd=4),("zabbix_agentd",pid=1756,fd=4),("zabbix_agentd",pid=1755,fd=4))
LISTEN 0 128 *:22 *:*users:(("sshd",pid=1298,fd=3))
LISTEN 0 100 127.0.0.1:25 *:*users:(("master",pid=1461,fd=13))
LISTEN 0 128 [::]:22 [::]:*users:(("sshd",pid=1298,fd=4))
LISTEN 0 100 [::1]:25 [::]:*users:(("master",pid=1461,fd=14))
[[email protected] ~]#ps -ef | grep zabbix_agentd
zabbix 1755 1 0 19:12 ? 00:00:00 /usr/sbin/zabbix_agentd -c /etc/zabbix/zabbix_agentd.conf
zabbix 1756 1755 0 19:12 ? 00:00:00 /usr/sbin/zabbix_agentd: collector [idle 1 sec]
zabbix 1757 1755 0 19:12 ? 00:00:00 /usr/sbin/zabbix_agentd: listener #1 [waiting for connection]
zabbix 1758 1755 0 19:12 ? 00:00:00 /usr/sbin/zabbix_agentd: listener #2 [waiting for connection]
zabbix 1759 1755 0 19:12 ? 00:00:00 /usr/sbin/zabbix_agentd: listener #3 [waiting for connection]
zabbix 1760 1755 0 19:12 ? 00:00:00 /usr/sbin/zabbix_agentd: listener #4 [waiting for connection]
zabbix 1761 1755 0 19:12 ? 00:00:00 /usr/sbin/zabbix_agentd: listener #5 [waiting for connection]
zabbix 1762 1755 0 19:12 ? 00:00:00 /usr/sbin/zabbix_agentd: active checks #1 [idle 1 sec]
root 1788 1565 0 19:14 pts/0 00:00:00 grep --color=auto zabbix_agentd
5. 生成主动模式模板
点击【配置-主机-10.0.0.7-web1-克隆】
6. 验证主动模式主机状态
#【ZBX】绿色,表示主机可用,监控指标检查已成功
7. 验证主动模式主机端口
[[email protected]_server ~]#netstat -tanlp | grep 10.0.0.37
tcp 0 0 10.0.0.17:10051 10.0.0.37:43072 TIME_WAIT -
tcp 0 0 10.0.0.17:10051 10.0.0.37:43062 TIME_WAIT -
tcp 0 0 10.0.0.17:10051 10.0.0.37:43070 TIME_WAIT -
tcp 0 0 10.0.0.17:10051 10.0.0.37:43068 TIME_WAIT -
tcp 0 0 10.0.0.17:10051 10.0.0.37:43066 TIME_WAIT -
tcp 0 0 10.0.0.17:10051 10.0.0.37:43064 TIME_WAIT -
8. 验证主动模式主机数据
9.把【自动发现规则】的时间间隔改为60s
点击【配置-主机-10.0.0.37-web2-自动发现规则】
边栏推荐
- the input device is not a TTY. If you are using mintty, try prefixing the command with ‘winpty‘
- Recursive Fusion and Deformable Spatiotemporal Attention for Video Compression Artifact Reduction
- 测试用例的设计
- [FreeRTOS] FreeRTOS learning notes (7) - handwritten FreeRTOS two-way linked list / source code analysis
- MySQL 45 lecture learning notes (12) MySQL will "shake" for a while
- Responsive mobile web test questions
- Vulhub vulnerability recurrence 77_ zabbix
- Label management of kubernetes cluster
- Directory of tornado
- 抽奖系统测试报告
猜你喜欢
the input device is not a TTY. If you are using mintty, try prefixing the command with ‘winpty‘
How notepad++ counts words
【GF(q)+LDPC】基于二值图GF(q)域的规则LDPC编译码设计与matlab仿真
centos8安装mysql.7 无法开机启动
Four sets of APIs for queues
leetcode825. 适龄的朋友
The final week, I split
Industrial computer anti-virus
Zhanrui tankbang | jointly build, cooperate and win-win zhanrui core ecology
The cloud native programming challenge ended, and Alibaba cloud launched the first white paper on application liveliness technology in the field of cloud native
随机推荐
tornado项目之路由装饰器
【森城市】GIS数据漫谈(一)
[Mori city] random talk on GIS data (I)
NLP-文献阅读总结
How to input single quotation marks and double quotation marks in latex?
Node connection MySQL access denied for user 'root' @ 'localhost' (using password: yes
Summary of June 2022
Tar source code analysis Part 3
Vulhub vulnerability recurrence 76_ XXL-JOB
Redis interview question set
What is industrial computer encryption and how to do it
uniapp小程序分包
About how idea sets up shortcut key sets
jdbc连接es查询的时候,有遇到下面这种情况的大神嘛?
Su Weijie, a member of Qingyuan Association and an assistant professor at the University of Pennsylvania, won the first Siam Youth Award for data science, focusing on privacy data protection, etc
There is no Chinese prompt below when inputting text in win10 Microsoft Pinyin input method
请问旧版的的常用SQL怎么迁移到新版本里来?
[Valentine's day] - you can change your love and write down your lover's name
提升复杂场景三维重建精度 | 基于PaddleSeg分割无人机遥感影像
Why does the producer / consumer mode wait () use while instead of if (clear and understandable)