Container status monitoring method, device, system and medium
By embedding resident programs in container image files, real-time monitoring and analysis of container status information, the status monitoring problem in multi-container environment is solved, and timely detection and feedback of container status is achieved, ensuring that operation and maintenance personnel can handle abnormalities in a timely manner and avoid losses .
Patent Information
- Application Number
- CN202110834128.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-07-22
- Publication Date
- 2024-11-22
- Estimated Expiration
- 2041-07-22
AI Technical Summary
In a multi-container environment, it is difficult for the prior art to realize real-time monitoring and abnormal detection of container status, which makes it difficult for operation and maintenance personnel to detect and deal with container failures in a timely manner, which may cause traffic, users or economic losses.
By embedding the resident program in the container's image file, the container status information is monitored in real time, and the container status is judged based on the update time of the status information. The preset thresholds detect the frequency and update time differences are used to realize the status monitoring of multiple containers and Exception feedback.
Real-time management and status monitoring of multiple containers are realized, and container abnormalities are detected and alarmed in a timely manner to ensure that operation and maintenance personnel can intervene quickly and avoid potential losses.
Smart Images

Figure CN113485896B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure generally relates to the field of container technology, and specifically relates to container status monitoring, and more particularly to a container status monitoring method, device, system and medium. Background Art
[0002] Container-based virtualization technology represented by Docker is a hot topic in current virtualization technology. It implements lightweight virtualization by isolating processes and resources. As an open source reference container engine, Docker provides a solution for rapid and automated deployment of applications. Multiple containers can be deployed using Docker images. The containers are isolated from each other and the environment inside the containers is consistent, making development and deployment simple. Under microservices, there will be many containers that collaborate with each other to jointly support upper-level businesses. A large number of containers are difficult to manage, and container service status monitoring is indispensable. Summary of the invention
[0003] In view of the above-mentioned defects or deficiencies in the prior art, it is desirable to provide a method, device, system and medium for monitoring the status of a container, which can realize status monitoring of multiple containers, and visualization and feedback of status information.
[0004] In a first aspect, an embodiment of the present application provides a method for monitoring a container status, comprising:
[0005] receiving status information of the container operation, wherein the status information is acquired through monitoring by a daemon program, and the daemon program is written in an image file used to deploy the container;
[0006] Obtaining the update time of the status information;
[0007] It is determined, according to the update time, that an abnormal state of the container occurs.
[0008] In some embodiments, determining that the container is in an abnormal state according to the update time includes:
[0009] Obtain the time difference between the current time and the update time;
[0010] When the time difference is greater than a preset threshold, it is determined that an abnormal state occurs in the container.
[0011] In some embodiments, the state information further includes identification information of the container, and obtaining the update time of the state information includes:
[0012] extracting the identification information from the status information;
[0013] The status information of the container corresponding to the identification information is updated according to the identification information, and the update time is generated.
[0014] In some embodiments, the image file also includes a business function program for deploying the container, and the daemon program is configured as a pre-program for executing the business function program.
[0015] In a second aspect, an embodiment of the present application provides a method for monitoring a container, wherein a business function program and a daemon program are written in an image file for deploying the container, and the method further includes:
[0016] Executing the daemon program to obtain status information of a container deployed based on the business function;
[0017] The state information is reported to a container state server, so that the container state server identifies whether a state abnormality occurs in the container according to the state information.
[0018] In some embodiments, the daemon program is configured as a pre-processor for executing the business function program.
[0019] In a third aspect, an embodiment of the present application provides a container status receiving device, including a receiving module, for receiving status information of a container operation, wherein the status information is acquired through monitoring by a daemon program, and the daemon program is written in an image file for deploying the container;
[0020] An acquisition module, used to acquire the update time of the status information;
[0021] A determination module is used to determine whether an abnormal state of the container occurs according to the update time.
[0022] In a fourth aspect, an embodiment of the present application provides a container status detection device, wherein a business function program and a daemon program are written in an image file for deploying a container, and the container status detection device includes:
[0023] An execution module, configured to execute the daemon program to obtain status information of a container deployed based on the business function;
[0024] The reporting module is used to report the status information to the container status server, so that the container status server can identify whether the container has a status abnormality according to the status information.
[0025] In a fifth aspect, an embodiment of the present application provides a container status monitoring system, including:
[0026] A container state detection device, the container state detection device is used to execute the method described in the embodiment of the present application;
[0027] The container status receiving device is communicatively connected to the container status detecting device, and the container status server is used to execute the method as described in the embodiment of the present application.
[0028] In a sixth aspect, an embodiment of the present application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the method for monitoring the status of a container as described in the embodiment of the present application.
[0029] Therefore, the container status monitoring method proposed in the embodiment of the present application can realize real-time management of the container by running a daemon program to detect the container status and thereby obtain the status information of the container operation. By forming identification information in the status information, the containers are distinguished by the identification information, thereby realizing simultaneous management of multiple containers. In addition, the container status monitoring method proposed in the embodiment of the present application adds the corresponding update time to the status information, and judges whether the running status of the container is normal by detecting the status information and update time of the container at a predetermined frequency and analyzing whether there is a regular change in the update time, so that the container can obtain manual intervention in time when an abnormal status occurs.
[0030] Additional aspects and advantages of the present invention will be given in part in the following description and in part will be obvious from the following description, or will be learned through practice of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0031] Other features, objects and advantages of the present application will become more apparent by reading the detailed description of non-limiting embodiments made with reference to the following drawings:
[0032] Figure 1 A schematic diagram of a scenario of a container status monitoring method provided by an embodiment of the present invention;
[0033] Figure 2 A flowchart of a container status monitoring method proposed in an embodiment of the present application;
[0034] Figure 3 A flowchart of another container status monitoring method proposed in an embodiment of the present application;
[0035] Figure 4 A schematic diagram of the structure of an image file proposed in an embodiment of the present application;
[0036] Figure 5 A flowchart of another container status monitoring method proposed in an embodiment of the present application;
[0037] Figure 6 A flowchart of another container status monitoring method proposed in an embodiment of the present application;
[0038] Figure 7 A flowchart of another container status monitoring method proposed in an embodiment of the present application;
[0039] Figure 8 A schematic diagram of a container status monitoring interface proposed in an embodiment of the present application;
[0040] Fig. 9 A schematic diagram of another container status monitoring interface proposed in an embodiment of the present application;
[0041] Fig.10 A schematic diagram of another container status monitoring interface proposed in an embodiment of the present application;
[0042] Fig.11 A schematic diagram of another container status monitoring interface proposed in an embodiment of the present application;
[0043] Fig.12 A block diagram of a container status receiving device proposed in an embodiment of the present application;
[0044] Fig.13 A block diagram of a container status detection device proposed in an embodiment of the present application;
[0045] Fig.14 A schematic diagram of the structure of a computer system of an electronic device or server suitable for implementing an embodiment of the present application is shown. DETAILED DESCRIPTION
[0046] The present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It is to be understood that the specific embodiments described herein are only used to explain the relevant invention, rather than to limit the invention. It is also necessary to explain that, for ease of description, only the parts related to the invention are shown in the accompanying drawings.
[0047] It should be noted that, in the absence of conflict, the embodiments and features in the embodiments of the present application can be combined with each other. The present application will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.
[0048] In recent years, container technology has swept the world, subverting the development, delivery and operation mode of applications, and has been widely used in cloud computing, the Internet and other fields. With the growth of business and technology, more and more container services are being deployed. The increase in containers makes it difficult for operation and maintenance personnel to monitor the status of containers in real time. Once the container is suspended or stopped, it is easy to cause unpredictable traffic, user, or economic losses. Therefore, the detection and monitoring of the status of container services is an indispensable part.
[0049] Based on this, embodiments of the present application provide a method, device, system and medium for monitoring the status of a container.
[0050] See also Figure 1, is a scenario diagram of the container status monitoring method provided by an embodiment of the present invention, and the scenario may include a container status detection device and a container status receiving device. Among them, the container status detection device is a place for creating and running containers, detecting container status, generating container status information, and sending container status information to the container status receiving device. The container status receiving device is a place for receiving, persisting and visualizing container status information, and issuing an alarm when the container status is abnormal. Specifically, after the container status detection device downloads the image file including the daemon program and the business function program, it first starts the daemon program, monitors whether the container is running, and then starts the business function program to create and start the container. When the container starts, that is, starts running, the daemon program detects the container status, generates container status information, and periodically sends the container status information to the container status receiving device, and the business daemon program supports the running container to complete its function. The container status receiving device includes an information receiving module, a database, a status determination module and a visualization module. The information receiving module is used to receive the container status information transmitted by the container status detection device and store the container status information in the database. The status determination module reads the container status information in the database and compares the current time with the time when the container status detection device last transmitted the container status information, determines whether the container status is abnormal, and displays the determination result in a visual manner in the visualization module. If the determination result is that the container status is abnormal, the visualization module will also trigger an alarm to warn.
[0051] Among them, the container status detection device can be set on the user's local physical machine, such as a local terminal device, etc., and the container status receiving device can be set on the manufacturer's remote physical machine, such as a server, or can be set on the user's local physical machine. It should be understood that when the container status receiving device is set on a local physical machine, it is usually not set on the same physical machine as the container status detection device.
[0052] In order to describe this application more clearly, the following is an explanation of relevant technical terms:
[0053] Mirroring: A file storage format in which data on one disk is created as an identical copy on another disk. In the present invention, the mirror file is downloaded by the container status detection device from the cloud mirror repository and is used to deploy containers in the container status detection device. It is a prerequisite for supporting container operation. It provides a standard template for the virtual environment in which the container runs, and uses a specific mirror to create a specific virtual environment, so that multiple containers can run independently of each other in this virtual environment.
[0054] Database: A warehouse that organizes, stores and manages data according to a certain data structure. Users can add, filter, update, delete and other operations on the data in the database. In the present invention, the database is set in the container status receiving device and can be used to store the container status information to facilitate further analysis of whether the container status is abnormal or not.
[0055] Persistence: A technology that saves data to a device that can store data permanently (e.g., a database). In the present invention, the container state information is stored in a database to achieve persistence of the container state information.
[0056] Visualization: Visualization is the theory, method and technology of using computer graphics and image processing technology to convert data into graphics or images and display them on the screen for interactive processing. In the present invention, the data of whether the container is operating abnormally is visualized and displayed on the screen. When the abnormal operation information is displayed, an alarm is triggered, and manual intervention is expected, thereby realizing interaction.
[0057] Figure 2 This is a flow chart of a container status monitoring method proposed in an embodiment of the present application. It should be noted that the execution subject of the container status monitoring method of this embodiment is a container status receiving device, which can be implemented by software and / or hardware. The container status receiving device in this embodiment can be configured in an electronic device or in a server for controlling the electronic device.
[0058] like Figure 2 As shown, the container status monitoring method includes the following steps:
[0059] Step 101, receiving the status information of the container operation, the status information is obtained through monitoring by a daemon program, and the daemon program is written in the image file used to deploy the container.
[0060] It should be noted that
[0061] The daemon is developed in golang and compiled into an executable binary file under the Linux system. It is built into the image and started and stopped together with the container. The daemon is used to collect container status information including but not limited to container name, container number, container IP address, host IP address, CPU, memory, processes in the container, GPU, etc., and uses grpc or http protocol to push the collected status information to the data collection interface for subsequent container status monitoring. Optionally, the push message format is as follows:
[0062]
[0063]
[0064] The container status receiving device may be provided with a status service interface for receiving the status information of the container operation sent by the daemon program.
[0065] Among them, the container status detection device can download the image file containing the daemon program from the cloud image repository, and the container status detection device uses the downloaded image file to create and run at least one container locally in the container status detection device. After the container is created, the daemon program monitors the running status of each container in real time. When the container starts running, the daemon program periodically detects the running status information of each container and sends the detected running status information of each container to the container status receiving device. For example, the daemon program detects the running status information of the container at a fixed period of 1.5 seconds, and sends the detection result to the container status receiving device, that is, when the daemon program detects that a container starts running, it detects the running status information of the container for the first time and sends the detection result to the container status receiving device. Thereafter, the daemon program detects the running status information of the container once every 1.5 seconds, and sends the detection result to the container status receiving device.
[0066] Step 102: Obtain the update time of the status information.
[0067] The container status receiving device obtains the update time corresponding to the status information when receiving the status information. For example, the container status receiving device may obtain the current time when receiving the status information, and mark the current time as the update time corresponding to the status information. Optionally, the status information itself may also carry time, that is, the time when the daemon detects the status information of the container operation. In this case, the container status receiving device may read the time carried by the status information when receiving the status information, and mark the time as the update time corresponding to the status information.
[0068] Among them, taking the time when the status information is received as the update time corresponding to the status information as an example, the container status receiving device obtains the first current time, that is, the update time of the status information, when receiving the status information, wherein the first current time can be the local time when the container status receiving device receives the status information of the container operation.
[0069] Here, take the time mark carried by the state information itself as the update time corresponding to the state information as an example, such as Figure 3As shown, the daemon of the container status detection device obtains the second current time when detecting the status information of the container operation, wherein the second current time may be the local time when the daemon detects the status information of the container operation. The daemon then uses the second current time as the time carried by the status information itself, that is, the update time corresponding to the status information, and sends it to the container status receiving device together with the status information.
[0070] Step 103: Determine whether the container is in an abnormal state according to the update time.
[0071] Among them, the container status receiving device determines whether the container has an abnormal state according to whether the update time of the status information of the container operation changes. For example, if the update time of the status information of the container operation changes with time, or changes according to the detection frequency of the daemon program, it means that the operation status of the container is normal. Otherwise, it means that the operation status of the container is abnormal.
[0072] Specifically, after receiving the status information of the container operation, the container status receiving device parses the status information of the container operation to obtain the update time of the status information, then detects the update time of the status information according to a preset frequency, and records the update time of the current detection. If the update time of the current detection is the same as the update time of the previous detection, it is determined that the container status is abnormal; if the update time of the current detection is different from the update time of the previous detection, it is determined that the container status is not abnormal.
[0073] Furthermore, if Figure 4 As shown, the image file also includes a business function program for deploying the container, and the daemon program is set as a pre-program for executing the business function program.
[0074] It should be noted that the business function program is used to create containers, start containers, and support running containers to complete their functions.
[0075] Among them, Figure 5As shown, the container status detection device downloads an image file containing a daemon and a business function program from a cloud image repository, wherein the daemon is written in front of the business function program in the image file. Specifically, when the container status detection device executes the image file, the content in the image file is read from the starting position. Therefore, the container status detection device first reads the daemon written at the front end of the image file, and after starting the daemon according to the daemon file, it continues to read the business function program used to create and start the container to achieve the purpose of container deployment. Optionally, when multiple containers are deployed on a container status detection device, it can repeatedly return to the starting position of directly reading the business function program, or it can directly return to the starting position of the daemon. For example, the container status detection device first reads the daemon, starts the daemon according to the daemon file, and then reads the business function program to create and start the first container. Subsequently, the daemon program can repeatedly return to the starting position of the direct read business function program to create and start the second and third containers, and the previously started daemon program will detect the status of multiple containers. It can also directly return to the starting position of the daemon program, start the second daemon program, and then read the business function program to create and start the second container, so that the daemon program can detect the container status one by one.
[0076] Therefore, the container status monitoring method proposed in the embodiment of the present application can ensure that the daemon program is already in the running state when the container starts running by starting the daemon program before the business function program. Therefore, the daemon program can fully detect the status information of the container from the beginning to the end of the operation.
[0077] Furthermore, the status information may also include identification information of the container.
[0078] It should be noted that the identification information is the identity information of the container, and is the "identity card number" that distinguishes each container from other containers. For example, the identification information can be composed of two parts: the IP address of the container state detection device where the container is located and the container number of the container in the container state detection device. At this time, even if there are multiple container state detection devices at the same time and each container state detection device has multiple containers running simultaneously, the identification information can be parsed to locate which container state detection device the identification information points to. In addition to the identification information, the status information also includes indicator information. Indicator information is one or more pieces of information that measure the status of the container, such as the container name, CPU, memory, processes in the container, GPU, etc. Unlike the identification information, the content of the indicator information can be repeated.
[0079] like Figure 6 As shown, get the update time of status information, including,
[0080] Step 1021, receiving status information.
[0081] Step 1022: extract identification information from the status information.
[0082] The container status receiving device extracts the identification information in the status information after receiving the status information. Optionally, the container can generate identification information by itself when it is created and send it to the daemon, and the daemon can also assign identification information to the specific container when it detects the status information for the first time.
[0083] Specifically, the container status receiving device extracts identification information consisting of an IP address and a container number from the status information, and determines according to the identification information that the status information comes from the container pointed to by the container number in the container status detecting device identified by the IP.
[0084] Step 1023, query whether the container status receiving device has stored status information containing the same identification information.
[0085] Step 1024: Update the status information of the container corresponding to the identification information according to the identification information, and generate an update time.
[0086] Among them, the container status receiving device first queries the server whether the status information containing the same identification information has been stored according to the extracted identification information. If it has been stored, the stored status information is replaced by the received status information. If it has not been stored, the received status information is stored. In addition, the container status receiving device obtains the local time of the container status receiving device when receiving the status information as the update time, and stores it together with the status information. Optionally, the container status receiving device can also read the time carried by the status information itself, that is, the time when the daemon detects the status information of the container operation as the update time, and stores it together with the status information.
[0087] As an optional embodiment, an information receiving module is set in the container status receiving device, and the information receiving module extracts the identification information in the status information, and updates the status information corresponding to the identification information according to the identification information, and generates an update time. Specifically, a database is first built in the container status receiving device, and the database creates a first data table for storing status information and update time. When receiving the status information, the information receiving module extracts the identification information in the status information, and queries whether the status information containing the same identification information has been stored in the first data table according to the extracted identification information. If it has been stored, the status information stored in the first data table is replaced with the received status information. If it has not been stored, the received status information is stored in the first data table. In addition, when receiving the status information, the information receiving module obtains the local time of the container status receiving device as the update time, and stores it in the first data table together with the status information.
[0088] Therefore, the container status monitoring method proposed in the embodiment of the present application can distinguish the status information of different containers by the identification information by adding identification information to the container. At the same time, the stored status information is updated according to the identification information, so as to ensure that for a specific container, no duplicate data is generated in the container status receiving device, thereby avoiding storing multiple data for the same container, which may lead to errors in container status determination.
[0089] Furthermore, if Figure 7 As shown, the abnormal state of the container is determined according to the update time, including:
[0090] Step 1031, read a preset threshold, and obtain a detection frequency according to the preset threshold.
[0091] It should be noted that the container status receiving device detects the update time according to a certain preset threshold value, so as to determine whether the container has an abnormal state. For example, if the preset threshold value corresponding to a certain container is 2 seconds, the container status receiving device detects the update time of the container at a detection frequency of 2 seconds / time. In the present invention, the preset threshold value is the maximum time interval allowed from the time when a certain identification information generates a corresponding update time to the time when the same identification information generates a corresponding update time next time. The preset threshold value can be pre-set by the user, can be obtained through a limited number of experiments, or can be obtained through a limited number of computer simulations.
[0092] Step 1032, periodically obtain the current time according to the detection frequency.
[0093] Specifically, if the detection frequency obtained according to the preset threshold is 2 seconds / time, the container status receiving device will repeat the behavior of detecting the update time of a container every 2 seconds after the first detection of the update time of the container.
[0094] Step 1033, obtaining the time difference between the current time and the update time.
[0095] As an optional embodiment, a database is built in the container state receiving device, and the database creates a second data table for storing different identification information and preset thresholds corresponding to the identification information. When it is detected that the identification information and the corresponding preset threshold are stored in the second data table, the state determination module in the container state receiving device first reads the identification information and the corresponding preset threshold from the second data table, and obtains the corresponding detection frequency according to the preset threshold. For example, if the preset threshold is 2 seconds, the detection frequency is 2 seconds / time. At the same time, the state determination module obtains a third current time, that is, the current time. After obtaining the current time, the state determination module reads the update time corresponding to the identification information from the first data table according to the identification information, and calculates the time difference between the current time and the update time. For example, the state determination module reads the update time corresponding to a certain identification information in the first data table as 22 hours, 22 minutes and 22 seconds, and the state determination module obtains the current time as 22 hours, 22 minutes and 32 seconds, then the state determination module calculates that the time difference between the update time of the state information corresponding to the identification information and the current time is 10 seconds.
[0096] After acquiring the current time for the first time, the state determination module continues to acquire the current time at the obtained detection frequency, reads the corresponding update time in the first data table according to the identification information, and calculates the time difference between the current time and the update time.
[0097] Step 1034: When the time difference is greater than a preset threshold, it is determined that the container is in an abnormal state.
[0098] It should be noted that, since the preset threshold is the maximum time interval allowed between two update times generated for the same identification information, when the container status receiving device obtains the current time according to the detection frequency corresponding to the preset threshold, and calculates that the time difference between the current time and the update time is greater than the preset threshold, it means that since the generation of the most recent update time, the maximum time interval has been exceeded but the next update time has not yet been generated, so it can be determined that the container status is abnormal.
[0099] After calculating the time difference between the current time and the update time, the container status receiving device compares it with a preset threshold. When the time difference is less than or equal to the preset threshold, the container status receiving device determines that the container status is normal. Otherwise, the container status is abnormal. The container status receiving device then visualizes the determination result and displays it in a visual interface, and issues an alarm when determining that the container status is abnormal. Optionally, the container status receiving device can also display the status information and update time in the visual interface.
[0100] As an optional embodiment, after calculating the time difference between the current time and the update time, the state determination module in the container state receiving device compares the preset threshold value with the time difference. When the time difference is less than or equal to the preset threshold value, the container state receiving device determines that the container state is normal. Otherwise, the container state is abnormal. After obtaining the determination result, the state determination module transmits it to the visualization module, and displays the normal or abnormal result of the container state on the screen visible to the user in a visual manner, and triggers an alarm when the abnormal result is displayed. In addition, the state determination module transmits the state information and the update time to the visualization module, and the visualization module displays the state information and the update time on the screen visible to the user.
[0101] As an optional embodiment, the container state detection device can create and run multiple containers that support the same type of business functions. For example, the container state detection device can create and run three containers m1, m2, and m3 that support face recognition business functions (represented by m). Optionally, the container state detection device can create and run multiple containers that support multiple types of business functions, and the same type of business function corresponds to a specific container. For example, the container state detection device can create and run a container m1 that supports face recognition business functions (represented by m), a container n1 that supports identity authentication business functions (represented by n), and a container k1 that supports industry analysis business functions (represented by k). Optionally, multiple containers supporting multiple types of business functions can be created and run in the container status detection device, and the same type of business function corresponds to multiple containers. For example, three containers m1, m2, and m3 supporting face recognition business functions (represented by m), two containers n1 and n2 supporting identity authentication business functions (represented by n), and four containers k1, k2, k3, and k4 supporting industry analysis business functions (represented by k) can be created and run in the container status detection device.
[0102] The following is a specific embodiment of the present invention. Assume that the container state detection device with an IP address of "1.1.1.1" downloads an image file containing a daemon program and a business function program from a cloud image warehouse. Subsequently, the container state detection device starts to execute the image file and reads the content of the image file from the starting position. Since the daemon program is written in front of the business function program in the image file, the container state detection device first reads the daemon program file and starts the daemon program according to the daemon program file. The daemon program monitors in real time whether a container starts running. Subsequently, the container state detection device reads the business function program file, and after the business function program runs, it creates and starts a container for realizing the face recognition business function. At this time, the daemon program monitors that the container starts running, so it detects its state for the first time, and obtains the container name "xbrain-api", the CPU occupancy percentage is "0.3", the memory occupancy percentage is "2.9" and the specific data (i.e., container log data) "eye distance 6.3cm" obtained when the container runs its face recognition function. The daemon uses the above information as indicator information and assigns the container number 101 to the container, thereby obtaining identification information "1.1.1.1:101" in the format of "IP address: container number".
[0103] After obtaining the identification information and the indicator information, the daemon sends the status information including the identification information and the indicator information to the container status receiving device, and at the same time sends the preset threshold value of 2 seconds set by the user for the container to the container status receiving device. Assuming that there is a maximum network delay of 0.1 seconds between the container status detection device and the container status receiving device, the daemon can repeatedly perform the behavior of detecting the status information of the container operation and sending the detection result to the container status receiving device every 1.9 seconds after the first detection of the container status, so as to ensure that the container status receiving device can receive the status information of the container at most once every 2 seconds under the premise that the container is running normally.
[0104] Before receiving the status information from the daemon of the container status detection device, the container status receiving device pre-builds a database and creates a blank container status data table in the database, and sets three data items, namely, the identification information field id, the indicator information field info, and the update time field update_time, in the container status data table, specifically in accordance with the following rules:
[0105]
[0106]
[0107] After the data table is created, the information receiving module in the container status receiving device receives the status information from the daemon of the container status detection device and extracts the identification information "1.1.1.1:101" in the status information. The information receiving module then queries the container status data table based on the identification information "1.1.1.1:101" contained in the status information and finds that no data containing the same identification information is found in the data table. Therefore, the status information is stored in the container status data table according to the corresponding field as follows:
[0108]
[0109] When the state information is received from the daemon of the container state detection device, the information receiving module parses the state information and determines that the state information itself does not carry time, so the local time of the container state receiving device when receiving the state information is obtained. Assuming that there is no network delay between the container state detection device and the container state receiving device at this time, and the time when the container state detection device sends the state information is 22:22:22, then this time is the local time obtained by the information receiving module, that is, the update time of the state information. The information receiving module stores the update time in the column corresponding to the state information in the container state data table according to the corresponding field as follows:
[0110]
[0111] 1.9 seconds after the first detection of the running status of container 101, the daemon program detected the running status of the container again and obtained indicator information of the container name "xbrain-api", CPU occupancy percentage "0.4", memory occupancy percentage "1.2" and specific data "face width 14.1cm" obtained when the container was running its face recognition function. The daemon program then sent the status information containing the indicator information and identification information "1.1.1.1:101" to the container status receiving device.
[0112] The information receiving module in the container status receiving device receives the status information from the daemon of the container status detection device and extracts the identification information "1.1.1.1:101" in the status information. Then the information receiving module queries the container status data table based on the identification information "1.1.1.1:101" contained in the status information and finds that data containing the same identification information can be queried in the data table. Therefore, the status information of the data queried in the data table is replaced as follows:
[0113]
[0114] When the state information is received from the daemon of the container state detection device, the information receiving module parses the state information and determines that the state information itself does not carry time, so it obtains the local time when the container state receiving device receives the state information. Assuming that a network delay of 0.1 seconds occurs between the container state detection device and the container state receiving device at this time, the time when the container state detection device sends the state information is 22:22:23.9 seconds, and the local time obtained by the information receiving module is 22:22:24 seconds, which is the update time of the state information. The information receiving module replaces the original update time "22:22:22" corresponding to the state information in the container state data table according to the corresponding field as follows:
[0115]
[0116] Before receiving the status information from the daemon of the container status detection device, the container status receiving device creates a blank preset threshold data table in the pre-built database, and sets two data items, the identification information field id and the preset threshold field threshold_time, in the preset threshold data table, specifically in accordance with the following rules:
[0117]
[0118] Since the daemon sends the preset threshold of 2 seconds to the container status receiving device, after receiving the preset threshold sent by the daemon, the container status receiving device calculates the corresponding detection frequency as 2 seconds / time, and writes the preset threshold into the data column of the corresponding identification information in the preset threshold data table as follows:
[0119] id Threshold_time 1.1.1.1:101 2 ... ...
[0120] After detecting that the preset threshold data table stores identification information and corresponding preset threshold, the status determination module of the container status receiving device reads the identification information "1.1.1.1:101" and the preset threshold of 2 seconds, thereby calculating the corresponding detection frequency as 2 seconds / time.
[0121] Assume that the status determination module obtains the current time as 22:22:25 at a certain moment. After obtaining the current time, the status determination module reads the corresponding update time of 22:22:24 in the container status data table based on the identification information "1.1.1.1:101", and calculates the time difference between the current time and the update time to be 1 second. Then the status determination module compares the time difference of 1 second with the preset threshold of 2 seconds, determines that the time difference is less than the preset threshold, and thus determines that the identification information indicates that the container operation status is normal, and sends the determination result of the normal container operation status to the visualization module.
[0122] The visualization module can present the visualized information on the host screen, such as Figure 8 As shown in the figure, the visualization module is visualized on the host screen in the form of a table consisting of four columns. The four columns of the table are, from left to right, the identification information column, the indicator information column, the update time column, and the normal / abnormal status column. The visualization module directly reads the identification information, indicator information, and update time from the container status data table of the database and fills them into the corresponding columns of the table to intuitively present the container status information to the user.
[0123] When the visualization module receives the result that the container is running normally, it searches the table for data with the identification information "1.1.1.1:101" and displays a check mark in the corresponding normal / abnormal status column to indicate that the container is running normally and no manual intervention is required.
[0124] Since the detection frequency is 2 seconds / time, after the last current time is 22:22:25, the status determination module waits for 2 seconds and then obtains the current time again as 22:22:27. Assuming that the container with container number 101 is abnormal at this time, the daemon fails to detect the status information of the container and send it to the container status receiving device, so the update time corresponding to the identification information "1.1.1.1:101" in the container status data table is still "22:22:24". At this time, the status determination module reads the corresponding update time in the container status data table based on the identification information "1.1.1.1:101", which is still 22:22:24. The time difference between the current time and the update time is calculated to be 3 seconds. After comparison, it is determined that the time difference is greater than the preset threshold. The status determination module determines that the identification information points to an abnormal container operation state, and sends the determination result to the visualization module.
[0125] like Fig. 9 As shown, when the visualization module receives the result of the abnormal operation status of the container, it searches the table for the data with the identification information "1.1.1.1:101" and displays an exclamation mark in the corresponding normal / abnormal status column to indicate that the container is abnormal. In addition, a dark dialog box pops up on the interface, which displays the identification information corresponding to the abnormal container and the prompt "The operation status of the container is abnormal! Please handle it in time!" to help users quickly locate the abnormal container. At the same time, the visualization module sounds an alarm in order to obtain manual intervention as soon as possible.
[0126] In addition, the visualization module can also present the visualized information on the mobile screen, so that monitoring personnel can view it during non-working hours. Fig.10As shown in the figure, the visualization module is visualized on the mobile screen in the form of a table consisting of four columns. The four columns of the table are, from left to right, the identification information column, the indicator information column, the update time column, and the normal / abnormal status column. The visualization module directly reads the identification information, indicator information, and update time from the container status data table of the database and fills them into the corresponding columns of the table to intuitively present the container status information to the user.
[0127] When the visualization module receives the result that the container is running normally, it searches the table for data with the identification information "1.1.1.1:101" and displays a check mark in the corresponding normal / abnormal status column to indicate that the container is running normally and no manual intervention is required.
[0128] Since the detection frequency is 2 seconds / time, after the last current time is 22:22:25, the status determination module waits for 2 seconds and then obtains the current time again as 22:22:27. Assuming that the container with container number 101 is abnormal at this time, the daemon fails to detect the status information of the container and send it to the container status receiving device, so the update time corresponding to the identification information "1.1.1.1:101" in the container status data table is still "22:22:24". At this time, the status determination module reads the corresponding update time in the container status data table based on the identification information "1.1.1.1:101", which is still 22:22:24. The time difference between the current time and the update time is calculated to be 3 seconds. After comparison, it is determined that the time difference is greater than the preset threshold. The status determination module determines that the identification information points to an abnormal container operation state, and sends the determination result to the visualization module.
[0129] like Fig.11 As shown, when the visualization module receives the result of the abnormal operation status of the container, it searches the table for the data with the identification information "1.1.1.1:101" and displays an exclamation mark in the corresponding normal / abnormal status column to indicate that the container is abnormal. In addition, a dark dialog box pops up on the interface, which displays the identification information corresponding to the abnormal container and the prompt "The operation status of the container is abnormal! Please handle it in time!" to help users quickly locate the abnormal container. At the same time, the visualization module sounds an alarm in order to obtain manual intervention as soon as possible.
[0130] In summary, the present application can realize timely detection and feedback of multiple container states by using a container state receiving device to receive state information sent from a container state detection device and perform persistence and visualization processing, so as to facilitate relevant personnel to monitor and manage a large number of containers at the same time and perform manual intervention in time for abnormal container conditions.
[0131] Fig.12 This is a block diagram of a container status receiving device proposed in an embodiment of the present application. Fig.12 As shown, the container status receiving device 10 includes:
[0132] A receiving module 11 is used to receive status information of the container operation, the status information is obtained through monitoring by a daemon program, and the daemon program is written in the image file used to deploy the container;
[0133] An acquisition module 12 is used to acquire the update time of the status information;
[0134] The determination module 13 is used to determine whether the container is in an abnormal state according to the update time.
[0135] In some embodiments, the determination module 13 is configured to:
[0136] Get the time difference between the current time and the update time;
[0137] When the time difference is greater than a preset threshold, it is determined that the container is in an abnormal state.
[0138] In some embodiments, the acquisition module 12 is used to:
[0139] Extracting identification information from the status information;
[0140] The status information of the container corresponding to the identification information is updated according to the identification information, and an update time is generated.
[0141] In some embodiments, the image file also includes a business function program for deploying the container, and the daemon program is configured as a pre-program for executing the business function program.
[0142] In summary, the present application can realize timely detection and feedback of multiple container states by using a container state receiving device to receive state information sent from a container state detection device and perform persistence and visualization processing, so as to facilitate relevant personnel to monitor and manage a large number of containers at the same time and perform manual intervention in time for abnormal container conditions.
[0143] Fig.13 This is a block diagram of a container status detection device proposed in an embodiment of the present application. Fig.13 As shown, the container state detection device is used to deploy the image file of the container with the business function program and the daemon program written therein, wherein the container state detection device 20 includes:
[0144] An execution module 21 is used to execute a daemon program to obtain status information of a container deployed based on a business function;
[0145] The reporting module 22 is used to report the status information to the container status receiving device, so that the container status receiving device can identify whether the container has an abnormal status according to the status information.
[0146] In some embodiments, the daemon program is configured as a pre-processor for executing the business function program.
[0147] It should be understood that the units or modules described in the container status receiving device are similar to those described in the reference Figure 2 The steps in the described method correspond to each other. Therefore, the operations and features described above for the method are also applicable to the container state receiving device and the units contained therein, and will not be repeated here. The container state receiving device can be pre-implemented in the browser or other security application of the electronic device, or loaded into the browser or its security application of the electronic device by downloading or the like. The corresponding units in the container state receiving device can cooperate with the units in the electronic device to implement the solution of the embodiment of the present application.
[0148] For the several modules or units mentioned in the above detailed description, this division is not mandatory. In fact, according to the embodiments of the present disclosure, the features and functions of two or more modules or units described above can be embodied in one module or unit. On the contrary, the features and functions of one module or unit described above can be further divided into multiple modules or units to be embodied.
[0149] It should be noted that for details not disclosed in the container status receiving device and the container status detecting device in the embodiments of the present application, please refer to the details disclosed in the above embodiments of the present application, which will not be repeated here.
[0150] Reference below Fig.12 , Fig.12 A schematic diagram of the structure of a computer system of an electronic device or server suitable for implementing an embodiment of the present application is shown.
[0151] like Fig.12 As shown, the computer system includes a central processing unit (CPU) 1001, which can perform various appropriate actions and processes according to the program stored in the read-only memory (ROM) 1002 or the program loaded from the storage part 1008 into the random access memory (RAM) 1003. In the RAM 1003, various programs and data required for the operation instructions of the system are also stored. The CPU 1001, the ROM 1002, and the RAM 1003 are connected to each other through a bus 1004. An input / output (I / O) interface 1005 is also connected to the bus 1004.
[0152] The following components are connected to the I / O interface 1005: an input section 1006 including a keyboard, a mouse, etc.; an output section 1007 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 1008 including a hard disk, etc.; and a communication section 1009 including a network interface card such as a LAN card, a modem, etc. The communication section 1009 performs communication processing via a network such as the Internet. A drive 1010 is also connected to the I / O interface 1005 as needed. A removable medium 1011, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 1010 as needed, so that a computer program read therefrom is installed into the storage section 1008 as needed.
[0153] In particular, according to an embodiment of the present application, the above reference flow chart Figure 2 The described process can be implemented as a computer software program. For example, an embodiment of the present application includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flow chart. In such an embodiment, the computer program includes a program code for executing the method shown in the flow chart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 1009, and / or installed from the removable medium 1011. When the computer program is executed by the central processing unit (CPU) 1001, the above-mentioned functions defined in the system of the present application are executed.
[0154] It should be noted that the computer-readable medium shown in the present application may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present application, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present application, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium such as a computer-readable storage medium that can send, propagate or transmit a program for use by or in conjunction with an instruction execution system, device or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.
[0155] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, functions and operating instructions of the system, method and computer program product according to various embodiments of the present application. In this regard, each box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the aforementioned module, program segment or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some implementations as replacements, the functions marked in the box can also occur in a sequence different from that marked in the accompanying drawings. For example, the boxes represented by two connections can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flow chart, and the combination of the boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operating instruction, or can be implemented with a combination of dedicated hardware and computer instructions.
[0156] The units or modules involved in the embodiments described in the present application may be implemented by software or hardware. The units or modules described may also be set in a processor. For example, they may be described as: a processor includes an information receiving module and a status determination module. The names of these units or modules do not, in some cases, constitute limitations on the units or modules themselves. For example, the status determination module may also be described as "obtaining the time difference between the current time and the update time, and determining that the container is in an abnormal state when the time difference is greater than a preset threshold."
[0157] As another aspect, the present application further provides a computer-readable storage medium, which may be included in the electronic device described in the above embodiment, or may exist independently without being assembled into the electronic device. The above computer-readable storage medium stores one or more programs, and when the above programs are used by one or more processors to execute the container status monitoring method described in the present application.
[0158] The above description is only a preferred embodiment of the present application and an explanation of the technical principles used. Those skilled in the art should understand that the scope of disclosure involved in the present application is not limited to the technical solution formed by a specific combination of the above technical features, but should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the aforementioned disclosed concept. For example, the above features are replaced with the technical features with similar functions disclosed in this application (but not limited to) by each other to form a technical solution.
Claims
1. A method for monitoring container status, characterized in that: include: Receive status information of at least one container operation, the status information is acquired through monitoring by a daemon program, the daemon program is written in an image file for deploying the container, the image file also includes a business function program for deploying the container, the daemon program is configured as a pre-program for executing the business function program, so that after starting the daemon program according to the daemon program file when starting the first container, the business function program for creating and starting the container is read; when starting the subsequent container, the daemon program corresponding to each business function program is started by returning to the starting position of the daemon program, or a plurality of business function programs corresponding to the started daemon programs are started by returning to the starting position of the business function program; Obtaining an update time of the status information, where the update time is the time when the daemon obtains the status information of the container operation, or the current time obtained when the status information is received; According to the update time, it is determined that the state of the container is abnormal, wherein: When the update time is the first current time obtained when the status information is received, the time difference between the current time and the update time is obtained; when the time difference is greater than a preset threshold, it is determined that the state of the container is abnormal; the daemon performs container state detection based on the maximum network delay between the container state detection device and the container state receiving device; When the update time is the second current time at which the daemon program obtains the status information of the container operation, it is determined whether the container has a status abnormality according to the detection frequency of the daemon program.
2. The method according to claim 1, characterized in that The state information also includes identification information of the container, and obtaining the update time of the state information includes: extracting the identification information from the status information; The status information of the container corresponding to the identification information is updated according to the identification information, and the update time is generated.
3. A method for monitoring container status, characterized in that: The image file used to deploy the container contains a business function program and a daemon program. The method further includes: Executing the daemon program to obtain status information of a container deployed based on the business function; The state information is reported to a container state receiving device, so that the container state receiving device identifies whether the state of the container is abnormal according to the state information, and the daemon is set as a pre-program for executing the business function program, so that after starting the daemon according to the daemon file when starting the first container, the business function program for creating and starting the container is read; when starting the subsequent container, the daemon corresponding to each business function program is started by returning to the starting position of the daemon, or a plurality of business function programs corresponding to the started daemon are started by returning to the starting position of the business function program; The container status receiving device obtains the update time of the status information, and the update time is the time when the daemon obtains the status information of the container operation, or the current time obtained when the status information is received; According to the update time, it is determined that the state of the container is abnormal, wherein: When the update time is the first current time obtained when the status information is received, the time difference between the current time and the update time is obtained; when the time difference is greater than a preset threshold, it is determined that the state of the container is abnormal; the daemon performs container state detection based on the maximum network delay between the container state detection device and the container state receiving device; When the update time is the second current time at which the daemon program obtains the status information of the container operation, it is determined whether the container has a status abnormality according to the detection frequency of the daemon program.
4. A container status receiving device, characterized in that: include: A receiving module, used for receiving status information of at least one container operation, the status information is acquired through monitoring of a daemon program, the daemon program is written in an image file used to deploy the container, the image file also includes a business function program for deploying the container, the daemon program is configured as a pre-program for executing the business function program, so that after starting the daemon program according to the daemon program file when starting the first container, the business function program for creating and starting the container is read; when starting the subsequent container, the daemon program corresponding to each business function program is started by returning to the starting position of the daemon program, or a plurality of business function programs corresponding to the started daemon programs are started by returning to the starting position of the business function program; an acquisition module, configured to acquire an update time of the status information, wherein the update time is the time when the daemon acquires the status information of the container operation, or the current time acquired when the status information is received; A determination module is used to determine, based on the update time, that the container has an abnormal state, wherein: When the update time is the first current time obtained when the status information is received, the time difference between the current time and the update time is obtained; when the time difference is greater than a preset threshold, it is determined that the state of the container is abnormal; the daemon performs container state detection based on the maximum network delay between the container state detection device and the container state receiving device; When the update time is the second current time at which the daemon program obtains the status information of the container operation, it is determined whether the container has a status abnormality according to the detection frequency of the daemon program.
5. A container status detection device, characterized in that: The image file used to deploy the container contains a business function program and a daemon program. The container status detection device includes: An execution module, configured to execute the daemon program to obtain status information of a container deployed based on the business function and an update time of the status information, wherein the update time is a time when the daemon program obtains the status information of the container operation; a reporting module, configured to report the status information to a container status receiving device, so that the container status receiving device can identify whether the container has a status abnormality according to the status information, wherein the daemon is configured as a pre-program for executing the business function program, so that after starting the daemon according to the daemon file when starting the first container, the business function program for creating and starting the container is read; when starting the subsequent containers, the daemon corresponding to each business function program is started by returning to the starting position of the daemon, or a plurality of business function programs corresponding to the started daemon are started by returning to the starting position of the business function program; The container status receiving device obtains the update time of the status information, and the update time is the time when the daemon obtains the status information of the container operation, or the current time obtained when the status information is received; According to the update time, it is determined that the state of the container is abnormal, wherein: When the update time is the first current time obtained when the status information is received, the time difference between the current time and the update time is obtained; when the time difference is greater than a preset threshold, it is determined that the state of the container is abnormal; the daemon performs container state detection based on the maximum network delay between the container state detection device and the container state receiving device; When the update time is the second current time at which the daemon program obtains the status information of the container operation, it is determined whether the container has a status abnormality according to the detection frequency of the daemon program.
6. A container status monitoring system, characterized in that: include: A container state detection device, the container state detection device is used to perform the method according to claim 3; A container status receiving device communicatively connected to the container status detecting device, wherein the container status receiving device is used to execute the method according to any one of claims 1-2.
7. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the method for monitoring the container status as described in any one of claims 1 to 2 or the method for monitoring the container status as described in claim 3 is implemented.
8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method for monitoring the container status as described in any one of claims 1 to 2 or the method for monitoring the container status as described in claim 3 is implemented.
Citation Information
Patent Citations
Docker Container monitoring method and system
CN108509254A
Application container cluster alarm implementation method, system and device and storage medium
CN110262941A
Monitoring method and system for enhancing high availability of container cluster and terminal equipment
CN110798375A
Abnormal task processing method based on container technology, server and cloud platform
CN112148420A
Micro-service state detection method and device, electronic equipment and storage medium
CN112486629A
