Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How does Docker monitor other machines?

2025-01-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces "how Docker monitors other machines". In daily operation, I believe many people have doubts about how Docker monitors other machines. Xiaobian consulted various materials and sorted out simple and easy operation methods. I hope to help you answer the doubts about "how Docker monitors other machines"! Next, please follow the small series to learn together!

deployment

Suppose we have two application servers in the actual project. In order to monitor them, we need to install zabbix-agent service on them respectively, and then configure them to connect with zabbix server. All monitoring data and monitoring configuration data are saved in mysql by zabbix server. The deployment situation is as follows:

The real scenario is to install zabbix agent service on the application server, but the process and steps of installing agent are not the focus of this practice. In order to quickly experience the service, this article uses zabbix official agent image, which is actually installed on ubuntu14.(The process of installing zabbix agent on the server is not detailed in this article. Readers interested in installing zabbix agent can go online to search for relevant information.)

docker-compose.yml file

According to the deployment situation shown in the previous image, our docker-compose.yml content is as follows, mysql and zabbix server are required, and two zabbix agent containers are added, named zabbix-agent-a and zabbix-agent-b respectively:

version: '2'services: zabbix-mysql-service: image: daocloud.io/library/mysql:8 container_name: zabbix-mysql-service environment: - MYSQL_ROOT_PASSWORD=888888 restart: always zabbix-server-service: image: monitoringartist/zabbix-xxl:3.2.6 links: - zabbix-mysql-service:mysqlhost container_name: zabbix-server-service restart: always depends_on: - zabbix-mysql-service ports: - "8888:80" environment: - ZS_DBHost=mysqlhost - ZS_DBUser=root - ZS_DBPassword=888888 zabbix-agent-a: image: zabbix/zabbix-agent:ubuntu-3.2.6 links: - zabbix-server-service:zabbixserverhost container_name: zabbix-agent-a restart: always depends_on: - zabbix-server-service environment: - ZBX_HOSTNAME=zabbix-agent-service-a - ZBX_SERVER_HOST=zabbixserverhost zabbix-agent-b: image: zabbix/zabbix-agent:ubuntu-3.2.6 links: - zabbix-server-service:zabbixserverhost container_name: zabbix-agent-b restart: always depends_on: - zabbix-server-service environment: - ZBX_HOSTNAME=zabbix-agent-service-b - ZBX_SERVER_HOST=zabbixserverhost

As shown above, zabbix agent needs to use ip information of zabbix server in the configuration process. Here, we add ip information of zabbix server to host file of zabbix agent through links parameter, host name is zabbixserverhost;

In addition, ZBX_HOSTNAME and ZBX_SERVER_HOST are two environment variables that have been described in the official documentation of zabbix agent mirror, as shown in the following figure. ZBX_HOSTNAME is used to indicate your identity, and ZBX_SERVER_HOST is used to indicate the ip information of zabbix server. Here, you can directly find the ip of zabbix server by using alias in the link parameter:

Start docker container

Open the console and execute docker-compose up -d in the directory where the docker-compose.yml file is located, as shown in the figure:

enter the console

Wait for about 1 minute, let zabbix server complete initialization, and then you can log in to the management page. For details, please refer to the article "Docker actual zabbix trilogy: speed experience". After logging in, enter the hosts page, as shown below:

Get monitoring machine ip

According to the deployment on the deployment description diagram above, there are two machines equipped with zabbix agent service, and then want to join the monitoring, the first step is to determine the ip of the machine, execute the docker exec -it zabbix-agent-a ip addr command on the console, you can see the following output, the ip of the first machine is 172.31.0.4:

Execute docker exec -it zabbix-agent-b ip addr command on the console, you can see that the ip of the second machine is 172.31.0.5;

Add Machine Monitoring

Click the Create host button in the upper right corner of the hosts page to add monitoring machines, as shown below:

On the page of adding machines, the main parameters are as follows: a. Host name: the machine environment variable ZBX_HOSTNAME value: zabbix-agent-service-a; b. Visible name: Same value as Host name; c. Groups : Machine grouping, select Linux servers here; d. Agent interfaces: only need to fill in IP address here, which is the IP: 172.31.0.4 we just got through the command docker exec -it zabbix-agent-a ip addr; this page only needs to fill in the above four points, and the rest are kept at default values. After filling in, click the "Add" button at the bottom, as shown below:

After successful addition, you can see the newly added machines in the list, as shown below:

Add monitoring items

In the machine list page, click the machine name, as shown in the red box below:

Click "Templates" on the opened page, as shown in the red box below:

Then click the "Select" button, as shown in the red box below:

In the pop-up page, check "Template OS Linux", and then click the "Select" button at the bottom, so that the linux service commonly used monitoring items to batch added, as shown below:

Note that in the returned page, you must click "Add" to add the selection just now, as shown below:

Then click "Update" to complete the batch addition of monitoring items, as shown in the following figure:

In the same way, add the monitoring of another machine;

Wait for about 1-2 minutes, then refresh the hosts page, you can see that the "ZBX" icon in the list has turned green, indicating that the monitoring has taken effect;

View monitoring information

Let's take a look at the monitoring graph. Click on the "Graphs" in the red box below:

You can see that there are 5 graphs that can be viewed, as shown below. Let's take a look at the cpu load:

In the jump page, click "Previdew", you can see the cpu load curve, as shown below:

At this point, the study of "how Docker monitors other machines" is over, hoping to solve everyone's doubts. Theory and practice can better match to help you learn, go and try it! If you want to continue learning more relevant knowledge, please continue to pay attention to the website, Xiaobian will continue to strive to bring more practical articles for everyone!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report