Table of contents
1. Zabbix automatic discovery and automatic registration mechanism:
2. Zabbix automatic discovery and automatic registration deployment
2. Installation and deployment
2. Installation and deployment
1. Zabbix automatic discovery and automatic registration mechanism:
1. Concept
The zabbix client actively contacts the server and sends its address and port to the server to automatically add the monitoring host.
The client is the active party
Disadvantages: There are too many hosts in the custom network segment, registration will take a long time, and the automatic discovery mechanism is not very stable.
2. Zabbix automatic discovery and automatic registration deployment
//zabbix automatic discovery (passive mode for agent2)
Zabbix server actively discovers all clients and then registers the client information on the server.
The disadvantage is that if there are many hosts in the defined network segment, zabbix server registration will take a long time and the pressure will be greater.
Time synchronization:
yum install ntpdate -y
ntpdate ntp.aliyun.com
//Set the download source of zabbix and install zabbix-agent2
rpm -ivh https://mirrors.aliyun.com/zabbix/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
cd /etc/yum.repos.d
sed -i 's#http://repo.zabbix.com#https://mirrors.aliyun.com/zabbix#' /etc/yum.repos.d/zabbix.repo
yum clean all && yum makecache
yum install -y zabbix-agent2
1. Ensure that the zabbix-agent2 service status on the client is normal
systemctl is-active zabbix-agent2.service
active
2. Delete the original client host on the Web page
Click [Host] in [Configuration] on the left menu bar, check the original client host, and click Delete
3. Configure hosts resolution on the server and client
vim /etc/hosts
20.0.0.45 test1
20.0.0.46 test2
4. Configure automatic discovery on the Web page
Click [Auto Discovery] in [Configuration] on the left menu bar, and click [Create Discovery Rule]
[Name] is set to mynetwork
[IP range] is set to 192.168.10.1-254
[Update interval] is set to 30s
[Check] Click [Add], [Check Type] select Zabbix client, [Port Range] is set to 10050, [Key Value] is set to system.uname
[Device Uniqueness Guidelines] Select IP address
[Host name] Select DNS name
[Visible name] Select the host name
Check [Enabled] and click [Update]
Click [Action] in [Configuration] on the left menu bar, and select [Discover Action] from the menu above.
Check [Auto discovery. Linux servers.] and click [Enable]
Click [Host] in [Configuration] on the left menu bar to refresh. After a period of time, the automatically discovered client hosts will be refreshed.
zabbix automatically registers (active mode for agent2)
zabbix agent2 will actively report its own information and send it to zabbix server.
The disadvantage is that zabbix agent2 may not be able to find the zabbix server due to incorrect configuration of the configuration file or network failure.
vim /etc/hosts
192.168.233.10 zbx-server
192.168.233.30 zbx-agent01
2. Modify the zabbix-agent2 configuration file
because /etc/zabbix/zabbix_agent2.conf
......
HostnameItem=system.hostname #139 line, uncomment
egrep -v "^#|^$" /etc/zabbix/zabbix_agent2.conf
PidFile=/var/run/zabbix/zabbix_agent2.pid
LogFile=/var/log/zabbix/zabbix_agent2.log
LogFileSize=0
Server=192.168.10.22
ServerActive=192.168.10.22
Hostname=zbx-agent01
HostnameItem=system.hostname
Include=/etc/zabbix/zabbix_agent2.d/*.conf
ControlSocket=/tmp/agent.sock
Click [Host] in [Configuration] on the left menu bar to refresh. After a period of time, the automatically discovered client hosts will be refreshed.
Zabbix logs can be viewed on the server side
tail -f /var/log/zabbix/zabbix_server.log
......
6601:20210922:225044.115 enabling Zabbix agent checks on host "zbx-agent01": host became available
Add autodiscover:
Just default
Look at the logs and zabbix logs to see if they are automatically added.
If it cannot be discovered automatically, change the name.
Three are consistent:
Configuration file line 136: Name web page host name and host name must be consistent
2. Zabbix’s proxy function:
The core of the proxy function: collects client data on behalf of the server, and then transmits the data to the server.
1. Workflow
2. Installation and deployment
Client: 20.0.0.44 20.0.0.46
Proxy server: 20.0.0.21
Server: 20.0.0.45
Deploy zabbix proxy server
The role of distributed monitoring:
●Share the centralized pressure of the server
●Solve the network delay problem between multiple computer rooms
agent --> proxy --> server
systemctl disable --now firewalld
setenforce 0
hostnamectl set-hostname zbx-proxy
//Set the download source of zabbix according to zabbix-proxy
rpm -ivh https://mirrors.aliyun.com/zabbix/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
cd /etc/yum.repos.d
sed -i 's#http://repo.zabbix.com#https://mirrors.aliyun.com/zabbix#' /etc/yum.repos.d/zabbix.repo
yum install -y zabbix-proxy-mysql zabbix-get
#Install Zabbix proxy (zabbix-proxy-mysql) and Zabbix client tool (zabbix-get)
Install the database required by zabbix
yum install -y mariadb-server mariadb
systemctl enable --now mariadb
mysql_secure_installation #Initialize the database and set a password, such as 123456
//Add database user and database information required by zabbix
mysql -u root -p123456
CREATE DATABASE zabbix_proxy character set utf8 collate utf8_bin;
GRANT all ON zabbix_proxy.* TO 'zabbix'@'%' IDENTIFIED BY 'zabbix';
flush privileges;
//Import database information
rpm -ql zabbix-proxy-mysql #Query the location of the sql file
zcat /usr/share/doc/zabbix-proxy-mysql-5.0.40/schema.sql.gz | mysql -uroot -p123456 zabbix_proxy
//Modify zabbix-proxy configuration file
because /etc/zabbix/zabbix_proxy.conf
Server=192.168.233.10 #30 line, specify the IP address of the zabbix server
Hostname=zbx-proxy #49 line, specifies the host name of the current zabbix proxy server
DBPassword=zabbix #196 line, specify the password of the current database zabbix user
//Start zabbix-proxy
systemctl start zabbix-proxy
systemctl enable zabbix-proxy
//Configure hosts resolution on all hosts
vim /etc/hosts
20.0.0.45 test1
20.0.0.46 test2
20.0.0.44 test3
20.0.0.21 zbx-proxy
Configure the agent proxy on the web page
Click [Action] in [Configuration] on the left menu bar, check the automatic registration rules, and click Disable
Click [Host] in [Configuration] on the left menu bar, check the original client host, and click Delete
Click [Agent] in [Management] on the left menu bar, and click [Create Agent]
[agent agent name] is set to zbx-proxy
[System Agent Mode] Select Active
[Proxy address] is set to 192.168.233.40
Click [Add]
Configure agent to use proxy
1. Modify the agent2 configuration file on the client
because /etc/zabbix/zabbix_agent2.conf
......
Server=192.168.233.40 #80 line, specify the IP address of the zabbix proxy server
ServerActive=192.168.233.40 #120 line, specify the IP address of zabbix proxy server
2. Configure on the Web page
Click [Host] in [Configuration] on the left menu bar, and click [Create Host]
[Host name] is set to zbx-agent01
[Visible name] is set to zbx-agent01
[Group] Select Linux server
The [IP address] of [Interfaces] is set to 192.168.233.30
[Monitored by agent] Select zbx-proxy
Then click [Template] on the upper menu bar
【Link new tamplates】Search for Linux and select Template OS Linux by Zabbix agent
Click [Add]
3. Restart the service on the client and proxy server respectively
systemctl restart zabbix-agent2
systemctl restart zabbix-proxy
Click [Host] in [Configuration] on the left menu bar to refresh and check that the client host monitoring status is normal.
View logs on the server
tail -f /var/log/zabbix/zabbix_proxy.log
3. zabbix-snmp monitoring
1. Concept
SNMP, Simple Network Management Protocol
SNMP (Simple Network Management Protocol) is a standard protocol for monitoring and managing network devices.
Device monitoring: SNMP allows network administrators to monitor various devices on the network, such as routers, switches, servers, and printers.
Through SNMP, administrators can obtain information about device status, performance, and health.
Performance management: SNMP provides a mechanism that enables administrators to monitor performance indicators of network devices, such as bandwidth utilization, CPU utilization, memory utilization, etc.
This helps administrators understand the load and performance conditions of the network so they can better plan and optimize network resources.
Troubleshooting: SNMP enables administrators to monitor the status of network devices in real time, including connection status, error rate, etc.
When a device failure or problem occurs, SNMP can provide alerts and information about the problem, helping administrators diagnose and repair problems faster.
Configuration management: SNMP can be used to configure network devices, such as modifying routing tables, changing device settings, etc.
This enables administrators to manage devices remotely over the network without direct physical access to the device.
Security Management: SNMP provides security features including simple authentication based on community strings.
This helps ensure that only authorized users can access and manage network devices, thereby improving network security.
Overall, SNMP is a standard protocol for monitoring, managing, and maintaining network devices
2. Installation and deployment
1. Install snmp monitoring program on the server
yum install -y net-snmp net-snmp-utils
2. Modify the snmp configuration file and start the service
because /etc/snmp/snmpd.conf
......
view systemview included .1 #57 line, add this configuration
#Can monitor all snmp protocol trees
systemctl start snmpd
3. Use snmp command to test
snmpwalk -v 2c -c public 127.0.0.1 sysname
SNMPv2-MIB::sysName.0 = STRING: zbx-server
-------------------------------------------------------
–v 1|2c|3: Specify SNMP protocol version
–c: Specify community string
sysname: key for snmp
-------------------------------------------------------
4. Configure snmp mode monitoring on the Web page
Click [Host] in [Configuration] on the left menu bar and click Zabbix server
[Interface] Click [Add] to select SNMP and set the port to 161
Click [Template] on the upper menu bar, select all agent templates in [Linked Templates] and select Unlink and Clean
Then search for Linux SNMP in [Link new templates] and select Template OS Linux SNMP
Click [Update] and wait for a period of time before the Zabbix server's availability changes to SNMP monitoring.
4. Summary:
zabbix: It is software that monitors service programs, network equipment, and secretaries. But it cannot monitor the running of the container very well.
Zabbix is a mature monitoring software on the market, with all template scripts, yaml files for docker and k8s container running
Components of zabbix:
zabbix server (collection and monitoring)
zabbix agent (client, sending data to the server)
zabbix proxy (proxy server, the proxy server also needs to install a database, save the client's data, and then send it to the server (receiver))
Zabbix configuration:
First there is the host, then the template, set the application set in the template, set the application set in the template, then configure the monitoring items in the application set, and configure after the monitoring items Trigger, finally configure the graph (optional)