当前位置:网站首页>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-自动发现规则】
边栏推荐
- 响应式移动Web测试题
- 用于压缩视频感知增强的多目标网络自适应时空融合
- Recursive Fusion and Deformable Spatiotemporal Attention for Video Compression Artifact Reduction
- tars源码分析之4
- NLP literature reading summary
- CMS source code of multi wechat management system developed based on thinkphp6, with one click curd and other functions
- Pangu open source: multi support and promotion, the wave of chip industry
- MySQL 45 learning notes (XI) how to index string fields
- 2022年6月小结
- 响应式——媒体查询
猜你喜欢
Master-slave replication principle of MySQL database
CMS source code of multi wechat management system developed based on thinkphp6, with one click curd and other functions
Summary of MySQL common judgment functions!! Have you used it
校园网络问题
《剑指Offer》第2版——力扣刷题
果果带你写链表,小学生看了都说好
the input device is not a TTY. If you are using mintty, try prefixing the command with ‘winpty‘
Centos8 install mysql 7 unable to start up
[thread pool]
Set JTAG fuc invalid to normal IO port
随机推荐
Selection (022) - what is the output of the following code?
[Mori city] random talk on GIS data (I)
How to input single quotation marks and double quotation marks in latex?
kubernetes集群之Label管理
Latex中的单引号,双引号如何输入?
同一个job有两个source就报其中一个数据库找不到,有大佬回答下吗
[FPGA tutorial case 8] design and implementation of frequency divider based on Verilog
Boast about Devops
Crawler (III) crawling house prices in Tianjin
【FPGA教程案例7】基于verilog的计数器设计与实现
Finishing (III) - Exercise 2
NLP-文献阅读总结
Review of enterprise security incidents: how can enterprises do a good job in preventing source code leakage?
The difference between synchronized and lock
Tar source code analysis Part 2
Introduction to spark core components
Summary of MySQL common judgment functions!! Have you used it
2022年,或許是未來10年經濟最好的一年,2022年你畢業了嗎?畢業後是怎麼計劃的?
notepad++如何统计单词数量
js 常用时间处理函数