Automatic registration of zabbix automatic monitoring
1. Introduction to automatic registration
The efficiency of zabbix automatic discovery is very slow. Every time it is automatically discovered, all hosts need to be scanned. It is also similar to the passive mode of zabbix. It needs to detect the machine every time. For example, if a host does not exist this time, download I have to scan again after going online again, which is very inefficient.
The principle of zabbix automatic registration is similar to the active mode. Each time, zabbix-agent actively tells zabbix-server that I am online and need to join monitoring. At this time, zabbix-server immediately joins the monitoring after agreeing. This efficiency is very high. High
Zabbix automatic registration only needs to be configured in four places to take effect
Server=192.168.81.210 //Who is allowed to get the value from me, if zabbixserver is configured, then the value can only be obtained by zabbixserver, even if zabbix_get is installed locally, the value cannot be obtained
ServerActive=192.168.81.210 //who actively report to, fill in the address of zabbix-server here
Hostname=Zabbix server //Here is the name when the monitoring host is added. If there are many machines that need to actively report, there must be a unique name to identify
HostMetadata= //Tags, automatic registration can flexibly link different monitoring templates according to different tags
Configuration steps:
1. Configure zabbix-agent, configure 4 parameters
2. Create automatic registration rules, select the host element on the action side, configure the add host, link template, and join the host group on the operation side
2. Automatically monitor the web host of the automatic registration case
Automatic registration is very simple, you only need to configure zabbix-agent and create an automatic registration rule.
2.1. Configure zabbix-agent
[root@192 ~]# vim /etc/zabbix/zabbix_agentd.conf
Server=192.168.81.210
ServerActive=192.168.81.210
Hostname=192.168.81.250
HostMetadata=web
[root@192 ~]# systemctl restart zabbix-agent
2.2. Create automatic registration rules
Click Configure-Action-Event Source Selection Automatic Registration-Create Action
2.3. Configure automatic registration action information
Name: Automatically monitor web host
New trigger condition: host element contains web
The host element here is the HostMetadata we set
2.4. Configure and fill in active registration operation information
Message configuration: Title: Auto registration: {HOST.HOST}
内容:Host name: {HOST.HOST}
Host IP: {HOST.IP}
Agent port: {HOST.PORT}
The operation is mainly to add who the discovery message is to, add the host, join the host group, and link the template
Click on the new fill-in information to add
Since it is a web host, the templates of nginx, php-fpm, tcp status must be linked
2.5. Speed up zabbix-server
[root@192 ~]# systemctl restart zabbix-agent
2.6. Check whether the addition is successful
Added successfully, the template is also linked successfully
2. Automatically monitor the database host for automatic registration cases
Due to the limited number of machines, we also use 81.250
2.1. Configure zabbix-agent
[root@192 ~]# vim /etc/zabbix/zabbix_agentd.conf
Server=192.168.81.210
ServerActive=192.168.81.210
Hostname=192.168.81.250-db
HostMetadata=db
[root@192 ~]# systemctl restart zabbix-agent
2.2 Create automatic registration rules
Click Configure-Action-Event Source Selection Automatic Registration-Create Action
2.3. Configure automatic registration action information
Name: Automatically monitor the database host
New trigger condition: host element contains db
The host element here is the HostMetadata we set
2.4. Configure and fill in active registration operation information
Message configuration: Title: Auto registration: {HOST.HOST}
内容:Host name: {HOST.HOST}
Host IP: {HOST.IP}
Agent port: {HOST.PORT}
The operation is mainly to add who the discovery message is to, add the host, join the host group, and link the template
Click on the new fill-in information to add
Because it is the db host, the templates of mysql and tcp status must be linked
2.5. Speed up zabbix-server
[root@192 ~]# systemctl restart zabbix-agent
2.6. Check whether the host is added successfully
Successfully added-the template is also automatically linked
3. Detailed configuration of automatic registration operation information
3.1. Send message
Operation type selection message
Send user group select zabbix administrator group
User chooses zabbix administrator
Choose WeChat alarm when you only send it
3.2. Add a host
Operation type select add host and add directly
3.3. Associated Template
Operation type selection and template association-just select the template
3.4. Add host group
Type selection to add to the host group—select the corresponding group
4. View all actions
Configuration-Action