NO.B.0007-zabbix-agent's passive, active mode, comparison, item scheduling method

I. Overview:
Insert picture description here

2. Passive mode
1. Create a host:
Insert picture description here

2. Add Items to the host:
Insert picture description here

Note: net.tcp.service supports the following types of protocols:
FTP HTTP, HTTPS, IMAP, LDAP, NNTP, POP, SMTP, SSH Telnet, NTP
3. Return to the ZABBIX-Agent client to modify the configuration file:

[root@localhost ~]# vim /etc/zabbix/zabbix_agentd.conf
Server=192.168.1.59,192.168.1.103    // 你的服务器地址,zabbix-server
                                                             //  若你的服务器有多个地址,可以用逗号分开。
Hostname=Another host                       // 你的客户端名称
#  ServerActive= 127.0.0.1                    // 你的服务器地址zabbix-server
// Agent操作常用命令:
[root@localhost ~]#   
sed -ri 's/^Server=(.*)/Server=192.168.1.1/' /etc/zabbix/zabbix_agentd.conf
[root@localhost ~]#   
sed -ri 's/^ServerActive=(.*)/ServerActive=192.168.1.1/' /etc/zabbix/zabbix_agentd.conf
[root@localhost ~]#   
 sed -ri '/# StartAgents=3/a\StartAgents=0' /etc/zabbix/zabbix_agentd.conf
[root@localhost ~]#   
sed -ri "s/^Hostname=(.*)/Hostname=$(hostname)/" /etc/zabbix/zabbix_agentd.conf
[root@localhost ~]#   
 egrep '^Server|^ServerActive|^Hostname|^StartAgents' /etc/zabbix/zabbix_agentd.conf
[root@localhost ~]#   
zabbix_agentd && ps -ef|grep zabbix_agentd

StartAgents=0 #Client agent mode. Set to 0 to enable the active mode, and the passive mode is turned off, but the zabbix_agentd of the monitored terminal does not listen to the local port
Server=xxxx #server IP address in passive mode, if it is in pure active mode, you can comment
ServerActive=xxxx #serverIP address in active mode
Hostname=test_host #Important: The hostname of the client, if not configured, use the host name.
Note: The zabbix agent in pure active mode can only support Zabbix Agent (Active) type monitoring items.

5. Use telnet to test on ZABBIX-server: (whether firewall.server and zabbix-agent services are turned on)

//查看端口是否开启:
[root@localhost ~]# ss -tunlp
tcp   LISTEN     0      128                       *:10050
OR
//在服务器端ZABBIX-server端安装Telnet来测试:
[root@localhost ~]# yum -y install telnet
[root@localhost ~]# telnet 192.168.1.60 10050
Trying 192.168.1.60...
Connected to 192.168.1.60.
Escape character is 

How to clone our item
configuration ——> Host ——> Monitoring item ——> Another host ——> Change the name to SSH server status ——> Key value: net.tcp.service[ssh] ——> Clone
Insert picture description here

6. Obtain item-related values ​​through commands

// 1、安装zabbix-agent
[root@localhost ~]# yum -y install zabbix-agent
// 2、通过zabbix-get获取item相关的值:
[root@localhost ~]# zabbix_get -s 127.0.0.1 -k system.cpu.load
0.000000

3. Active mode:
1. zabbix-agent actively initiates a connection to our zabbi-server and asks for monitored items.
2. zabbix-server makes a request back to zabbix-agent,
3. zabbix-agent collects item-related values
to be collected by zabbix-server , 4. returns the collected value to zabbx-server
[root@localhost ~]# vim /etc /zabbix/zabbix_agentd.conf
Option: StartAgents // Option: StartAgents
Insert picture description here

# Number of pre-forked instances of zabbix_agentd that process passive checks.    
                                     //处理被动检查的zabbix_agentd的预分支实例的数量。
# If set to 0, disables passive checks and the agent will not listen on any TCP port.  
                                    //#如果设置为0,则禁用被动检查,代理将不会监听任何TCP端口。

# If this parameter is not specified, active checks are disabled.  
                                    //如果未指定此参数,则禁用活动检查。
ServerActive=192.168.1.59:10051     //配置服务器的地址及端口

Insert picture description here

5. After the configuration is successful, the value is found to be particularly large, and it will always be added; this is because his statistics are the sum of all values.
Configuration -> Host -> Monitoring Items -> Process -> Change per second
Insert picture description here

Set to change every second
Insert picture description hereInsert picture description here

6. Check now: It can only speed up the time for us to update data, not the database. The time for the database to add data to the cache.
Passive mode: zabbix4.x Check now that supports passive mode (only passive mode requests will be sent successfully )
Insert picture description hereInsert picture description hereActive mode: zabbix4.x check now does not support active mode check now (send failed)

Insert picture description hereInsert picture description hereComparison of ZABBIX passive mode and active mode:
Monitoring items of zabbix-agent version:
Insert picture description here

You can also send version information to other servers: modify the configuration file in the zabbix_agent.conf file and separate it with a comma after ServerActive.

[root@localhost ~]# vim /etc/zabbix/zabbix_agentd.conf ServerActive
=192.168.1.59:10051
If zabbix passive mode:
1. We need our zabbix-server to actively retrieve data from zabbix-agent, then it will consume us The massive resources of the server.
2. We need to open port 10050 in zabbix-agent
3. It is easier to configure for beginners than zabbix-agent active mode.
4. Support custom interval mode to obtain information.
5. The default templates of zabbix-server are in passive mode. If we need to use active mode, we need to change its information acquisition mode.

If we use zabbix-agent active mode:
1. We need zabbix-agent to actively contact the server, which will share some load and pressure, because the server is responsible for responding.
2. zabbix-agent does not need to open port 10050 to zabbix-server Going to links increases our network security.
3. There will be fewer network links, further saving our network bandwidth

Passive mode:
1. After adding an item before zabbix-front-web, at this time, Zaibbix-server will not know that there is the item, because it has not loaded the item into its cache. Actually, just put it in the database.
2. The default is 60s to read the database once, and it takes 60s to load the database into the cache of zabbix-server. If the item update interval you configure is 60s, the fastest speed to get the item is 60s, the slowest speed It should be between 60s and 120s.
3. The server uses its internal item ID to poll. For example, to check a CPU Load. The polling interval is 60s.

Active mode:
1. After adding an item on zabbix-front-web, at this time, Zaibbix-server will not know that there is the item, because it has not loaded the item into its cache. Actually, just put it in the database.
2. When it is not added to the cache, zabbix-agent actively asks zabbix-server which items to monitor. At this time, zabbix-sever thinks that it does not monitor any monitoring items.
3. zabbix-agent active polls every 2 minutes by default.
4. If we set the update interval of zabbix-agent to 60s. For zabbix-agent active mode, it takes about three minutes to obtain data.

Guess you like

Origin blog.51cto.com/15005403/2552388