Zabbix-08-Active & Passive
1. Active & Passive
Active-passive mode, which is based on the zabbix-agent discussion
1.1 Passive
Under passive mode, zabbix-server periodically opens random ports and initiates a tcp connection to zabbix-agent's 10050 according to the monitoring items in the host-associated templates and data collection intervals, and then sends commands to obtain monitoring item data, i.e., what commands zabbix-server sends then zabbix- agent to collect what data, zabbix-server when to send zabbix-agent when to collect, zabbix-server does not send zabbix-agent has been unresponsive, and zabbix-agent do not have to care.
Passive mode is simple to configure and can be used after installation without other complex configurations, so it has become the default working mode of zabbix.
Passive mode will increase the workload of zabbix-server, in the environment of hundreds or even thousands of servers will lead to zabbix-server need to rotate to each zabbix-agent to send data collection commands, if the zabbix-server load is very high will lead to can not get the latest data in a timely manner.
1.2 Active
The zabbix-agent actively initiates a tcp connection request to port 10051 of the zabbix-server. In active mode, the IP or host name of the zabbix-server must be specified in the zabbix-agent configuration file. zabbix-agent doesn't know what data it is going to collect and the interval between data collection requests until it connects to the zabbix-server. Before connecting to zabbix-server, zabbix-agent doesn't know what data it wants to collect and the interval time. After connecting to zabbix-server, zabbix-agent obtains its own monitoring items and the interval time of data collection, then collects the data according to the monitoring items and returns it to zabbix-server, which no longer requires zabbix-serve to initiate a connection request to zabbix-agent in active mode. Active mode can reduce the number of local random ports and processes opened by zabbix-server to a certain extent, which reduces the load on zabbix-server.
root@zabbix-server:~# netstat -tanlp | grep 10050
zabbix-server initiates a lot of tcp connections to zabbix-agent, the load on zabbix-server will be very high.
Active-passive is actually based on the monitoring items of the template, the active-passive can be mixed.
2. Passive
zabbix-web01 passive mode by default
root@zabbix-web01:~# 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=192.168.66.120
ListenPort=10050
StartAgents=3
Hostname=192.168.66.125
Include=/etc/zabbix/zabbix_agentd.d/*.conf
Note: In Passive mode, ServerActive does not need to be configured.
3. Active
root@zabbix-web02:~# dpkg -i zabbix-release_4.0-3+bionic_all.deb
root@zabbix-web02:~# apt update
root@zabbix-web02:~# apt install zabbix-proxy-mysql zabbix-agent
root@zabbix-web02:~# vim /etc/zabbix/zabbix_agentd.conf
root@zabbix-web02:~# 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=192.168.66.120
ServerActive=192.168.66.120
Hostname=192.168.66.126
Timeout=30
Include=/etc/zabbix/zabbix_agentd.d/*.conf
root@zabbix-web02:~# systemctl restart zabbix-agent.service
root@zabbix-web02:~# systemctl enable zabbix-agent.service
root@zabbix-web02:~# ss -tnl
4. Creating active Templates
Template-Monitor-Type
The defaults are all passive
Clone Template
Update interval is usually set to 5 minutes in practice to avoid overloading the data with frequent updates.
5.Create Host
Associated Templates
Whether or not it turns green depends on whether or not agent.ping can ping through Host
Since the number of disks and NICs in each server is different, it is not possible to configure them uniformly, so their monitoring items are used as auto-discovery items in the templates.
6. Monitoring Graphs
zabbix automatically converts units based on changes in values
Upload large files to zabbix-web02 and watch the NIC traffic change.
The value that returns to a calm state when the upload is complete
If there are not many servers (less than 100), use zabbix-server + active mode, otherwise use zabbix-server + active mode + Proxy mode
root@zabbix-server:~# netstat -tanlp | grep 192.168.66.126
tcp 0 0 192.168.66.120:10051 192.168.66.126:54314 TIME_WAIT -
10051 It's active, the rest is passive