Virtual machine monitoring method, storage medium and electronic equipment
By introducing a one-to-one connection mechanism between the monitoring component and the controller, and a hash function to assign tasks in the cloud platform virtual machine monitoring system, the problems of data source limitations and insufficient real-time performance in virtual machine monitoring are solved, and efficient and accurate virtual machine monitoring is achieved.
Patent Information
- Application Number
- CN202511090429.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-04
- Publication Date
- 2025-11-21
AI Technical Summary
In cloud computing environments, existing virtual machine monitoring methods suffer from limitations in data sources and poor real-time performance, making it difficult to adapt to the needs of large-scale, high-concurrency cloud environments, resulting in inaccurate monitoring data and insufficient real-time performance.
By introducing a one-to-one connection mechanism between monitoring components and monitoring controllers in the cloud platform virtual machine monitoring system, the monitoring controller is only started when the virtual machine is running to obtain memory, processor, disk and network data. Monitoring tasks are allocated using a hash function, and the intelligent triggering mechanism of multiple components and controllers is used to ensure real-time monitoring.
It improves the accuracy and real-time performance of virtual machine monitoring, saves resources, provides a comprehensive monitoring perspective, and ensures the real-time acquisition and monitoring efficiency of virtual machine data.
Smart Images

Figure CN120994492A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computers, and more particularly to a method for monitoring virtual machines, a storage medium, and an electronic device. Background Technology
[0002] Against the backdrop of the rapid development of cloud computing, virtual machine monitoring on cloud platforms has become a key link in ensuring service quality, improving resource utilization, and maintaining system stability. Virtual machine monitoring methods in related technologies rely on a single data source for data monitoring, which has problems such as large data source limitations and poor real-time performance. In multi-cloud and hybrid cloud architectures with a large number of virtual machines and dynamic changes, these limitations affect the effectiveness of monitoring data and make it difficult to adapt to the needs of large-scale, high-concurrency cloud environments. Summary of the Invention
[0003] This application provides a virtual machine monitoring method, storage medium, and electronic device to at least solve the problems of inaccurate monitoring data and insufficient real-time performance in virtual machine monitoring in related technologies.
[0004] This application provides a virtual machine monitoring method applied to a cloud platform virtual machine monitoring system. The cloud platform virtual machine monitoring system includes multiple monitoring components, multiple virtual machines, and monitoring controllers configured within the multiple virtual machines. The multiple monitoring components are connected one-to-one with the multiple monitoring controllers. The method includes: when a target virtual machine among the multiple virtual machines is determined to be running, triggering the startup of a target monitoring controller among the multiple monitoring controllers through a target monitoring component, and performing monitoring operations on the target virtual machine through the target monitoring controller to obtain monitoring data of the target virtual machine. The target monitoring component is a component among the multiple monitoring components that is correspondingly connected to the target monitoring controller. The monitoring operation includes the following steps: obtaining memory data in the target virtual machine through a first component and a second component; obtaining processor data in the target virtual machine; obtaining disk data in the target virtual machine using disk information in the target virtual machine; and obtaining network data in the target virtual machine through a network interface.
[0005] This application also provides a virtual machine monitoring device applied to a cloud platform virtual machine monitoring system. The cloud platform virtual machine monitoring system includes multiple monitoring components, multiple virtual machines, and monitoring controllers disposed within the multiple virtual machines. The multiple monitoring components are connected one-to-one with the multiple monitoring controllers. The device includes: a monitoring module, used to, when determining that a target virtual machine among the multiple virtual machines is running, trigger the startup of a target monitoring controller among the multiple monitoring controllers through a target monitoring component, and perform monitoring operations on the target virtual machine through the target monitoring controller to obtain monitoring data of the target virtual machine. The target monitoring component is a component among the multiple monitoring components that is correspondingly connected to the target monitoring controller. The monitoring operation includes the following steps: obtaining memory data in the target virtual machine through a first component and a second component; obtaining processor data in the target virtual machine; obtaining disk data in the target virtual machine using disk information in the target virtual machine; and obtaining network data in the target virtual machine through a network interface.
[0006] According to yet another embodiment of this application, a computer program product is also provided, including a computer program that, when executed by a processor, implements the steps in any of the above method embodiments.
[0007] According to yet another embodiment of this application, a computer-readable storage medium is also provided, wherein a computer program is stored in the computer-readable storage medium, and the computer program is configured to perform the steps in any of the above method embodiments when it is run.
[0008] According to yet another embodiment of this application, an electronic device is also provided, including a memory and a processor, wherein the memory stores a computer program and the processor is configured to run the computer program to perform the steps in any of the above method embodiments.
[0009] This application addresses a cloud platform virtual machine monitoring system that includes multiple monitoring components, multiple virtual machines, and monitoring controllers configured within those virtual machines. When a target virtual machine is detected to be running, the target monitoring component activates its corresponding target monitoring controller. The target monitoring controller then performs monitoring operations on the target virtual machine, acquiring monitoring data including memory data, processor data, disk data, and network data. By introducing a one-to-one dynamic connection mechanism between the monitoring controller and the monitoring components, the monitoring controller is activated only when the virtual machine is running, saving resources and improving efficiency. Simultaneously, it acquires memory, processor, disk, and network data, providing a comprehensive monitoring perspective. Through intelligent triggering of monitoring operations, it ensures that virtual machine data can be monitored in real-time as long as the virtual machine is running. Therefore, it solves the technical problems of inaccurate monitoring data and insufficient real-time performance in related technologies for virtual machine monitoring, achieving the technical effect of improving the accuracy and real-time performance of virtual machine monitoring. Attached Figure Description
[0010] To more clearly illustrate the embodiments of this application, the accompanying drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0011] Figure 1 A schematic diagram of the hardware environment for a virtual machine monitoring method provided in an embodiment of this application;
[0012] Figure 2 A flowchart illustrating a virtual machine monitoring method provided in this application embodiment;
[0013] Figure 3 A flowchart illustrating a deployment method for a cloud platform virtual machine monitoring system provided in this application embodiment;
[0014] Figure 4 A flowchart illustrating a cloud platform virtual machine monitoring method provided in this application embodiment;
[0015] Figure 5 This is a structural block diagram of a virtual machine monitoring device provided in an embodiment of this application. Detailed Implementation
[0016] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the protection scope of this application.
[0017] It should be noted that, in the description of this application, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. The terms "first," "second," etc., in this application are used to distinguish similar objects and are not used to describe a specific order or sequence.
[0018] To enable those skilled in the art to better understand the present application, the present application will be further described in detail below with reference to the accompanying drawings and specific embodiments.
[0019] The methods and embodiments provided in this application can be executed on a server device or a similar computing device. Taking running on a server device as an example, Figure 1 This is a schematic diagram of the hardware environment for a virtual machine monitoring method according to an embodiment of this application. Figure 1 As shown, the server device may include one or more ( Figure 1 Only one is shown in the diagram. A processor 102 (which may include, but is not limited to, a microprocessor MCU or a programmable logic device FPGA, etc.) and a memory 104 for storing data are also shown. The server device may further include a transmission device 106 for communication functions and an input / output device 108. Those skilled in the art will understand that... Figure 1 The structure shown is for illustrative purposes only and does not limit the structure of the server equipment described above. For example, the server equipment may also include components that are more... Figure 1 The more or fewer components shown, or having the same Figure 1 The different configurations shown.
[0020] The memory 104 can be used to store computer programs, such as application software programs and modules, like the computer program corresponding to a disk anomaly determination method in this embodiment. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, thus implementing the aforementioned method. The memory 104 may include high-speed random access memory and non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include memory remotely located relative to the processor 102, and these remote memories can be connected to server devices via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.
[0021] The transmission device 106 is used to receive or send data via a network. Specific examples of the network described above may include a wireless network provided by a communication provider for the server device. In one example, the transmission device 106 includes a Network Interface Controller (NIC), which can connect to other network devices via a base station to communicate with the Internet. In another example, the transmission device 106 may be a Radio Frequency (RF) module used for wireless communication with the Internet.
[0022] This embodiment provides a method for monitoring virtual machines. Figure 2 This is a flowchart of a virtual machine monitoring method according to an embodiment of this application. The method is applied to a cloud platform virtual machine monitoring system, which includes multiple monitoring components, multiple virtual machines, and monitoring controllers disposed in the multiple virtual machines. The multiple monitoring components are connected one-to-one with the multiple monitoring controllers, such as... Figure 2 As shown, the process includes the following steps:
[0023] Step S202: When it is determined that the target virtual machine among the multiple virtual machines is in a running state, the target monitoring controller among the multiple monitoring controllers is triggered to start through the target monitoring component, and the target monitoring controller performs monitoring operations on the target virtual machine to obtain the monitoring data of the target virtual machine. The target monitoring component is the component among the multiple monitoring components that is connected to the target monitoring controller. The monitoring operation includes the following steps: obtaining memory data in the target virtual machine through the first component and the second component, obtaining processor data in the target virtual machine, obtaining disk data in the target virtual machine using disk information in the target virtual machine, and obtaining network data in the target virtual machine through the network interface.
[0024] Optionally, the application scenarios of the solution in this embodiment include, but are not limited to, large cloud platforms under multi-cloud and hybrid cloud architectures, such as: large cloud data centers with thousands or even tens of thousands of virtual machines, cloud platforms based on Kubernetes, and cloud platforms with multiple tenants.
[0025] Optionally, the cloud platform virtual machine monitoring system in this embodiment is a system used to monitor and analyze the running status of virtual machines in real time in a cloud computing environment. It consists of multiple monitoring components and a monitoring controller, and collects and analyzes the performance indicators of virtual machines (such as memory, central processing unit (CPU) utilization, disk input / output (I / O), network traffic, etc.).
[0026] Optionally, the multiple virtual machines in this embodiment are deployed on multiple host machines.
[0027] Optionally, the monitoring component in this embodiment is a component of the cloud platform virtual machine monitoring system, used to trigger the startup of the monitoring controller to collect monitoring data of the virtual machine.
[0028] Optionally, the monitoring controller in this embodiment is responsible for performing monitoring operations on the target virtual machine and analyzing and processing the collected monitoring data. By setting monitoring thresholds, the resource allocation of the target virtual machine can be automatically adjusted, and alarms can be triggered when data anomalies occur. For example, when the CPU utilization is detected to reach 90%, the monitoring controller can automatically adjust the CPU allocation of the virtual machine to prevent resource overload.
[0029] Optionally, Figure 3 This is a flowchart illustrating a deployment method for a cloud platform virtual machine monitoring system according to an embodiment of this application. In practical use, the cloud platform virtual machine monitoring system in this embodiment can be a Kubernetes-based cloud platform virtual machine monitoring system, with the Telegraf container image equivalent to the aforementioned monitoring component, such as... Figure 3 As shown, the process includes the following steps:
[0030] Step S302: Select CentOS 8.2 as the base image for the virtual machines in the cloud platform virtual machine monitoring system;
[0031] Step S304: Compile the target binary file (i.e., the telegraf executable file) and copy it into the telegraf container image;
[0032] Step S306: Add the cloud platform virtual machine monitoring algorithm to the Telegraf container image;
[0033] Step S308: Push the target container image (i.e., the Telegraf container image mentioned above) to the private image repository of the cloud platform;
[0034] Step S310: Add a switch to enable or disable the virtual machine monitoring service in the global variable control file to help determine whether the Telegraf container image (i.e., the monitoring component mentioned above) triggers the startup of the target monitoring controller among multiple monitoring controllers.
[0035] Step S312: Specify the service deployment node through the target file (i.e., the inventory file);
[0036] Step S314: Deploy and start the telgraf service on the cloud platform (i.e., the cloud platform virtual machine monitoring system mentioned above);
[0037] Step S316: Determine whether the target node (i.e., the node where the above Telegraf service is located) is a compute node. If yes, proceed to step S318; otherwise, proceed to step S320.
[0038] Step S318: Start the virtual machine monitoring service. The Telegraf container instance triggers the Telegraf service to start in the Telegraf container of the node where the Telegraf service is located (that is, the target monitoring component triggers the start of the target monitoring controller among multiple monitoring controllers), and performs monitoring operations on the target virtual machine through the target monitoring controller to obtain the monitoring data of the target virtual machine.
[0039] Step S320: Do not start the virtual machine monitoring service (i.e., the target monitoring component does not trigger the start of the target monitoring controller among multiple monitoring controllers).
[0040] Through steps S302 to S306 above, a Telegraf container image is built. The built Telegraf container image is then uploaded to the cloud platform's private image repository. Subsequently, global variables in the Helm code are modified to control whether the Telegraf service enables virtual machine monitoring. This step ensures that the target monitoring component can start the corresponding monitoring service as needed. By specifying the inventory file, the Telegraf service can be deployed on specific nodes (such as compute nodes), establishing a corresponding connection between the monitoring component and the monitoring controller (i.e., the Telegraf instance).
[0041] For example, in a large-scale cloud data center, a target virtual machine is running a high-load database service. To ensure the stable operation of this service, the monitoring components and monitoring controller in the cloud platform's virtual machine monitoring system are activated. The monitoring controller obtains memory data through the first and second components (such as QGA and Libvirt), acquires CPU usage data from the target virtual machine itself, collects disk data through disk information, and monitors network traffic in real time from the network interface. During this process, if QGA is temporarily unavailable, the system automatically switches to Libvirt to obtain memory data, ensuring the continuity of monitoring data. In this way, the operating status of the target virtual machine can be monitored in real time, and potential performance bottlenecks or faults can be detected in a timely manner, such as excessively high CPU utilization, increased disk I / O latency, or abnormal network latency. Corresponding resource adjustments or fault handling measures can then be taken to ensure the continuous operation of the service and optimize resource utilization efficiency.
[0042] In this embodiment, the entity executing the above steps can be a management node or monitoring agent in the cloud platform virtual machine monitoring system, but is not limited to these. For example, the kubelet component in a Kubernetes cluster, or the Nova monitoring service in an OpenStack environment.
[0043] Through the above steps, for a cloud platform virtual machine monitoring system with multiple monitoring components, multiple virtual machines, and monitoring controllers configured within those virtual machines, when a target virtual machine is detected to be running, the target monitoring component activates its corresponding target monitoring controller. The target monitoring controller then performs monitoring operations on the target virtual machine, acquiring monitoring data including memory data, processor data, disk data, and network data. By introducing a one-to-one dynamic connection mechanism between the monitoring controller and the monitoring components, the monitoring controller is activated only when the virtual machine is running, saving resources and improving efficiency. Simultaneously, it acquires memory, processor, disk, and network data, providing a comprehensive monitoring perspective. Through intelligent triggering of monitoring operations, it ensures that virtual machine data can be monitored in real time as long as the virtual machine is running. Therefore, it can solve the technical problems of inaccurate monitoring data and insufficient real-time performance in related technologies for virtual machine monitoring, achieving the technical effect of improving the accuracy and real-time performance of virtual machine monitoring.
[0044] In an exemplary embodiment, before starting the target monitoring controller among the multiple monitoring controllers by triggering the target monitoring controller among the multiple monitoring controllers through the target monitoring component, and performing monitoring operations on the target virtual machine through the target monitoring controller to obtain the monitoring data of the target virtual machine, the method further includes: processing the identifiers of the multiple virtual machines using a hash function to allocate multiple monitoring tasks corresponding to the multiple virtual machines to multiple monitoring processes, wherein the monitoring process is a process in the target monitoring controller, and the monitoring process corresponds one-to-one with the monitoring component.
[0045] Optionally, the hash function in this embodiment is a function that maps data of arbitrary size to a fixed-size output, the output value of which is often referred to as a hash value or hash code. In this embodiment, the hash function is used to process the identification of virtual machines, determine which monitoring process should be assigned to each virtual machine's monitoring task, and ensure balanced distribution and efficient processing of tasks. The hash functions used include, but are not limited to, consistent hashing (such as using hash rings) and simple modulo operations (such as MD5 or SHA-256).
[0046] For example, assuming there are currently 5 monitoring processes (IDs from 0 to 4), when the UUID of the virtual machine is abc123, a modulo hash algorithm such as MD5 or SHA-256 can be used to convert it into a large integer, such as 123456789. Then, take the modulo 5 of this integer. If the result is 2, then the monitoring task of this virtual machine will be assigned to the monitoring process with ID 2.
[0047] Optionally, in this embodiment, the virtual machine identifier refers to a unique identifier (ID) for each virtual machine, such as a universally unique identifier (UUID). In multi-cloud and hybrid cloud architectures, this identifier is used to accurately identify and locate each virtual machine in order to effectively monitor, manage, and allocate resources to it.
[0048] Optionally, the monitoring task in this embodiment is the process of collecting and analyzing virtual machine performance data, including but not limited to memory usage, CPU load, disk I / O, network traffic, etc.
[0049] Optionally, in this embodiment, the monitoring component is responsible for data collection, while the monitoring process is responsible for the preliminary processing and analysis of the data.
[0050] For example, suppose an enterprise is operating a Kubernetes-based hybrid cloud environment with over 1000 virtual machines (VMs). Each VM needs real-time monitoring to ensure efficient resource utilization and business continuity. On each compute node, a Telegraf container is deployed as the target monitoring controller. Multiple monitoring processes run within the Telegraf container, each focusing on handling monitoring tasks for a specific range of VMs. To efficiently manage a large number of monitoring requests, a hash function is used to process the UUIDs of all VMs. After hashing, the VM's UUID is mapped to a specific numerical range, which is related to the monitoring process ID and determines which monitoring process will be responsible for monitoring that VM. Once tasks are assigned, after the target monitoring component triggers the startup of the target monitoring controller among the multiple monitoring controllers, the monitoring process begins executing the corresponding monitoring tasks, such as memory monitoring and CPU monitoring. By using a hash function to allocate monitoring tasks, the challenge of monitoring large-scale VM clusters can be effectively solved, achieving balanced distribution and efficient processing of monitoring tasks, thus improving the overall operational efficiency and resource utilization of the cloud platform.
[0051] Through the steps described above, a hash function is used to process the virtual machine identifier, and monitoring tasks are assigned to monitoring processes, with each process corresponding to one monitoring component. Using a hash function to allocate monitoring tasks for virtual machines achieves dynamic balancing, preventing overburdening a single process. Multiple monitoring processes process in parallel, reducing monitoring latency and improving the real-time performance of data monitored from virtual machines.
[0052] In one exemplary embodiment, a hash function is used to process the identifiers of multiple virtual machines to allocate monitoring tasks corresponding to the multiple virtual machines to multiple monitoring processes. This includes: calculating the value of a preset bit of the identifiers of the multiple virtual machines using the hash function to obtain multiple first values; mapping the multiple first values to an integer space within a target value range to generate multiple first hash values; and for each first hash value, searching clockwise on a hash ring for the first virtual node that is greater than or equal to the first hash value to allocate the monitoring task to the monitoring process, wherein the virtual node and the monitoring process have a one-to-one correspondence.
[0053] Optionally, when calculating the hash value, specific bits of the hash value (e.g., the first 32 bits) are usually selected as the basis for task allocation, so that the hash value can be mapped to a specific numerical range on the hash ring later.
[0054] Optionally, in this embodiment, the integer space within the target numerical range refers to the integer range set for task allocation after the first numerical mapping. For example, if the goal is to allocate the monitoring tasks of the virtual machine to 10 monitoring processes, then the target numerical range may be an integer space from 0 to 9.
[0055] Optionally, the hash ring in this embodiment is a core concept in the consistent hashing algorithm; it is a virtual, cyclic numerical ring. Each monitoring process is assigned one or more virtual nodes on this ring, and the positions of these nodes determine which virtual machine tasks the monitoring process is responsible for monitoring.
[0056] Optionally, in this embodiment, the virtual node is on the hash ring and represents a tag or location of the monitoring process.
[0057] For example, in a Kubernetes-based hybrid cloud environment, an enterprise is running a large-scale cluster of virtual machines to provide high-performance computing services. To ensure service quality, real-time monitoring of virtual machine resource usage is required, including memory, CPU, disk I / O, and network traffic. The system first processes the UUID of each virtual machine using a hash function (such as SHA-256) to obtain a hash value. Then, only the first 32 bits of this hash value are selected as preset bit values to reduce the value range and facilitate subsequent operations. Next, the first 32 bits of each virtual machine identifier are mapped to an integer space from 0 to 9999 to obtain the first hash value, which will be used to locate the virtual machine on the hash ring. Assuming there are 10 monitoring processes (IDs 0 to 9) in the system, each process occupies multiple virtual nodes on the hash ring to increase the granularity of load balancing. When a monitoring task for a virtual machine needs to be assigned, the system searches clockwise on the hash ring based on its first hash value until the first virtual node is found. The monitoring process corresponding to this virtual node will then be responsible for the monitoring task of that virtual machine. For the hash value of the virtual machine UUID 1234567890abcdef1234567890abcdef, the first 32 bits are selected and mapped to the integer space within the target value range. Assuming the first hash value obtained after processing is 1234, then searching clockwise from 1234 on the hash ring, the first virtual node encountered may be the node of the monitoring process with ID 2 (e.g., node position 1500). Therefore, this monitoring task will be assigned to the monitoring process with ID 2. If the number or position of monitoring processes in the system changes (e.g., a new monitoring process is added), only the virtual nodes need to be added or adjusted accordingly on the hash ring without affecting a large number of already assigned monitoring tasks, ensuring the stability and dynamic adaptability of the cloud platform virtual machine monitoring system.
[0058] Through the above steps, the first hash value corresponding to the virtual machine identifier is calculated. Then, the first matching virtual node is found clockwise on the hash ring, and the monitoring task is assigned. Utilizing hash ring technology effectively solves the problem of balanced distribution of virtual machine monitoring tasks in large-scale, dynamically changing cloud environments. This ensures that each monitoring process can fairly share the monitoring load, improving the overall monitoring efficiency of the system. Furthermore, if the number of monitoring processes changes subsequently, the task load can be easily adjusted by adding or deleting virtual nodes, enabling a smooth transition and maintaining the system's high availability and flexibility.
[0059] In an exemplary embodiment, for each of the aforementioned hash values, the first virtual node greater than or equal to the aforementioned hash value is searched clockwise on the hash ring. Before assigning the aforementioned monitoring task to the aforementioned monitoring process, the method further includes: numbering the plurality of aforementioned monitoring processes to construct a plurality of aforementioned virtual nodes and a plurality of numbers for the plurality of aforementioned virtual nodes; calculating the numerical values of the numbers of the plurality of aforementioned virtual nodes using the aforementioned hash function to obtain a plurality of second values; mapping the plurality of aforementioned second values to the aforementioned integer space respectively to generate a plurality of second hash values; and arranging the plurality of aforementioned second hash values to obtain the aforementioned hash ring.
[0060] Optionally, in this embodiment, to improve the load balancing capability of the consistent hashing algorithm, multiple virtual nodes are typically constructed on the hash ring for each actual node (in this case, the monitoring process). The introduction of virtual nodes allows for improved data distribution uniformity and reduced hotspot issues even when the number of actual nodes is small, by increasing the number of virtual nodes.
[0061] Optionally, in this embodiment, the second value refers to the output value calculated by using the virtual node's number (and other optional parameters, such as additional information about the virtual node) as input and a selected hash function (such as MD5, SHA-256, etc.), which is used to map the virtual node to a specific position on the hash ring.
[0062] Optionally, in actual use, a monitoring process can be used to execute multiple monitoring tasks, and each monitoring task can be further subdivided into monitoring the memory data of the target virtual machine, monitoring the processor data of the target virtual machine, etc.
[0063] For example, suppose there are 5 monitoring processes (numbered 1 to 5) in a cloud platform. The number of virtual machines each process needs to monitor is not fixed, and the total number of virtual machines in the system may dynamically change with business needs. To achieve load balancing and efficient allocation of monitoring tasks, a consistent hashing algorithm is used. Multiple virtual nodes are constructed for each monitoring process. Assuming each actual monitoring process constructs 4 virtual nodes, there will be a total of 20 virtual nodes. The numbers of these virtual nodes can be based on the actual monitoring process number and an auto-incrementing sequence. For example, the virtual node numbers for monitoring process 1 could be 1-1, 1-2, 1-3, 1-4. The SHA-256 hash function is used to calculate the number of each virtual node, resulting in a series of second values. These values are used to determine the position of the virtual node on the hash ring. These second values are then mapped to a number from 0 to 2. 32Within an integer space between -1, a second hash value is generated. All generated second hash values are arranged in ascending order on a hash ring. This allows subsequent monitoring tasks based on their hash values to be assigned to the virtual nodes closest to them, achieving balanced task distribution. When the number of monitoring processes changes, for example, a new monitoring process 6 is added, a virtual node is constructed for monitoring process 6, and its position on the hash ring is recalculated. Only the affected virtual machine monitoring tasks (those closer to the new node than the original node) need to be reassigned to monitoring process 6, while other tasks remain unchanged, significantly reducing the cost of task reallocation. This method effectively achieves balanced distribution of virtual machine monitoring tasks in dynamically changing monitoring processes, avoiding the problem of single process overload and improving the overall performance and stability of the monitoring system.
[0064] Through the above steps, a hash function is used to calculate and map the monitoring process number to an integer space, resulting in multiple second hash values. These second hash values are then sorted to obtain a hash ring structure for allocating monitoring tasks to virtual machines. This clarifies the relationship between monitoring processes and virtual nodes, facilitating system management and debugging. The hash ring provides an intuitive and effective mode for allocating monitoring tasks, enhancing the system's flexibility and efficiency.
[0065] In one exemplary embodiment, obtaining memory data in the target virtual machine through a first component and a second component includes: obtaining first memory data of the target virtual machine through the first component; obtaining second memory data through the second component when the first component malfunctions or the first memory data is abnormal; and determining the first memory data or the second memory data as the memory data, wherein the first component is set in the target virtual machine, the second component is set in the host machine where the target virtual machine is located, and the performance parameter of the first component in obtaining data is greater than the performance parameter of the second component in obtaining data.
[0066] Optionally, the first and second components in this embodiment can be QGA (QEMU Guest Agent) and Libvirt, respectively, in actual use. QGA is a daemon running inside the virtual machine, which can directly access the resource status inside the virtual machine. Libvirt is a virtualization management toolkit running on the host machine, which can obtain the resource usage of the virtual machine. In virtual machine memory monitoring, QGA is used first to obtain more accurate memory data. If QGA is unavailable or the data is abnormal, the system automatically switches to the Libvirt data source to ensure the continuity of monitoring and the integrity of the data. For example, when the QGA service is temporarily interrupted, the system automatically switches to Libvirt to continue monitoring the memory status until the QGA service is restored.
[0067] Optionally, the performance parameters in this embodiment are used to measure metrics such as the speed, accuracy, and reliability of memory data acquisition. If QGA is used as the first component, its performance parameters, such as response time and data accuracy, are superior to Libvirt, which is used as the second component.
[0068] Suppose a target virtual machine (ID VM1234) in an enterprise cloud platform is performing a computationally intensive task, and its memory usage needs to be monitored in real time. The target monitoring controller (possibly an instance of Telegraf) first attempts to obtain initial memory data for VM1234 via QGA (the first component mentioned above). However, if QGA is temporarily unable to provide data for some reason (such as a network failure within the virtual machine, an unexpected termination of the QGA daemon, or a configuration error), the system will automatically detect this situation. In this case, the target monitoring controller will attempt to obtain secondary memory data using Libvirt (the second component mentioned above). Once the data is successfully obtained, regardless of whether it is obtained through QGA or Libvirt, the system will determine the final memory data based on the data quality and performance parameters of each. If the QGA data is normal and the performance parameters are high, then the initial memory data it provides will be adopted; conversely, if the QGA data is abnormal or cannot be obtained, the system will switch to relying on the secondary memory data provided by Libvirt. Once the memory data is determined, it is used by the monitoring system for real-time analysis and display. This helps system administrators promptly identify and address memory usage anomalies, such as memory leaks and excessive memory consumption, enabling them to take measures to optimize resource allocation and prevent performance degradation or service interruptions caused by memory resource contention. Through this mechanism, even if monitoring components inside or outside the virtual machine encounter problems, the monitoring system can still obtain necessary performance data through the backup solution (second component), maintaining the stability and accuracy of monitoring.
[0069] Through the above steps, the first component prioritizes acquiring the target virtual machine's memory data. If the first component malfunctions or the memory data it acquires is invalid, the system switches to the second component to acquire the memory data. By setting up two methods for acquiring the target virtual machine's memory data, timely and effective acquisition of memory data can be ensured, improving the stability of the monitoring system.
[0070] In one exemplary embodiment, obtaining processor data in the target virtual machine includes: collecting the working time of the processor in the target virtual machine according to a preset time period to obtain multiple working times, wherein the working time is used to represent the time when the processor performs data processing; and determining the utilization rate of the processor based on the multiple working times to determine the processor data.
[0071] Optionally, the preset time period in this embodiment is a time interval pre-set by the system, such as 1 second, 5 seconds, or 1 minute. During this time, the monitoring system will collect data to achieve periodic monitoring and update the monitoring data.
[0072] Optionally, the processor's working time in this embodiment refers to the time that the CPU (Central Processing Unit) in the target virtual machine uses to execute computing tasks, including CPU usage time in user mode and kernel mode.
[0073] Optionally, the multiple working times in this embodiment are the processor's working times collected multiple times by the monitoring system within a preset time period. This can be used to analyze the processor's usage patterns and trends, and provide more accurate utilization calculations.
[0074] Optionally, in this embodiment, based on the collected multiple working times, the CPU utilization within a preset time period can be determined by a certain calculation method (such as the difference method, the averaging method, etc.). In addition, the collected multiple working time data can not only determine the CPU utilization, but also further analyze and determine other CPU-related performance indicators and data, including but not limited to the average CPU load, the idle time of the CPU waiting for I / O operations to complete, the CPU usage frequency, etc.
[0075] Optionally, the processor data in this embodiment includes, but is not limited to, processor utilization, load, core status, etc.
[0076] Assuming a target virtual machine on a cloud platform is an instance running a critical business application, the monitoring system monitors processor utilization using the following steps: The monitoring controller continuously collects processor operating time within a 1-second interval (the aforementioned preset time period). Assume the processor operating time collected in the first second is 1000ms, and in the second second it is 1200ms. By calculating the difference between the two collections (1200ms - 1000ms = 200ms), the incremental processor usage time within that second is obtained. Since the total length of this second is 1000ms, the processor utilization rate is 200ms / 1000ms = 20%. The monitoring system compares this 20% utilization rate with the target virtual machine's performance requirements, historical data, and the cloud platform's resource allocation strategy to determine whether resource allocation needs adjustment. For example, if the processor utilization rate consistently exceeds 80%, more CPU resources may need to be allocated to the virtual machine; conversely, if the utilization rate is below 30%, some resources may need to be reclaimed for other virtual machines to achieve dynamic resource optimization. By using the methods described above, the cloud platform can monitor the processor's usage status in real time, make timely resource adjustment decisions, ensure that the performance of virtual machines meets application requirements, avoid resource waste, and improve the overall resource utilization efficiency and economic benefits of the cloud platform.
[0077] By following the steps above, the CPU usage time of the target virtual machine is collected periodically, and CPU utilization is calculated based on the time difference between multiple consecutive collections. Using time-increment calculation provides more accurate CPU utilization data and improves the real-time performance of monitoring data.
[0078] In one exemplary embodiment, obtaining disk data in the target virtual machine using disk information includes: obtaining disk information of the target virtual machine through a target interface, wherein the disk information includes multiple disk identifiers and snapshot chain information, and the snapshot chain information includes the sequential dependency relationship and storage mapping information of snapshot nodes between the initial disk and the disk used when the last snapshot operation was performed; based on the disk information, performing a snapshot operation on the target virtual machine through the target interface to obtain multiple snapshot disk files, wherein the snapshot disk files correspond one-to-one with the disks in the target virtual machine, the data in the snapshot disk files is data that has been written to the disks, and the data is in a read-only state; and combining the multiple snapshot disk files based on the snapshot chain information to obtain the disk data.
[0079] Optionally, the target interface in this embodiment allows the monitoring system to access and manage virtual machine resources, including disk information.
[0080] Optionally, the disk information in this embodiment includes multiple identifiers of the virtual machine disk (such as device name, UUID, etc.) and snapshot chain information. The disk identifier is used to uniquely identify different disks in the virtual machine; the snapshot chain information describes the sequential dependencies and storage mappings between all snapshot nodes since the initial disk creation of the virtual machine (i.e., how each snapshot is physically stored on the host disk or cloud storage).
[0081] Optionally, in this embodiment, after performing a snapshot operation, the system creates a snapshot file for each disk in the virtual machine. These files contain all data that has been written to the disk at the time of the snapshot, and this data is in a read-only state within the snapshot files. There is a one-to-one correspondence between the snapshot disk files and the disks in the target virtual machine, and each disk has its own snapshot file.
[0082] Optionally, in this embodiment, disk data refers to all data on the target virtual machine disk, including application data such as file systems and databases, as well as snapshot information. Combining snapshot disk files involves parsing snapshot chain information, merging multiple snapshot disk files according to their dependencies, and reconstructing the complete data state of the disk.
[0083] Suppose a critical database application service is running on the cloud platform of Company XX. To ensure high data availability and reduce the risk of data loss, it is decided to use snapshot technology to periodically back up the database disk. The specific steps are as follows: First, the cloud platform virtual machine monitoring system obtains the disk information of the target virtual machine (the virtual machine running the database service) through a target interface (such as the Kubernetes API), including disk identifiers (such as sda, sdb) and snapshot chain information. Based on the obtained disk information, the monitoring system performs snapshot operations on the disks in the target virtual machine through the target interface, creating a snapshot disk file for each disk. To completely restore the database disk state, the monitoring system needs to combine multiple snapshot disk files sequentially according to the dependencies in the snapshot chain information to generate a complete disk data state. For example, if there are snapshots A, B, and C, where B depends on A and C depends on B, then during data recovery, A needs to be read first, and then the states of B and C need to be overlaid to generate the latest disk data.
[0084] For example, suppose that every Friday at 5 PM, the system automatically creates a snapshot of the main disk of the database virtual machine for data backup before the weekend. The monitoring system obtains the disk snapshot chain information through the Kubernetes API and finds that the node Snap_20230707 in the snapshot chain depends on Snap_20230630. After the snapshot is created on Friday, the system combines the two snapshot files, that is, based on Snap_20230630, it overlays the incremental data in Snap_20230707 to generate a complete database disk data state. If abnormal data is found in the database on Tuesday of the following week, the data recovery can be performed using the snapshot disk file from the previous Friday. The recovery process will recombine multiple snapshot files in sequence according to the dependencies in the snapshot chain information to restore the data to a normal state. Through the above process, the cloud platform can not only achieve regular backup of virtual machine disk data, but also efficiently manage and recover data, ensuring the security and continuity of critical business data.
[0085] Through the above steps, disk information, including disk identifier and snapshot chain information, is obtained through the target interface. Then, a snapshot operation is performed to generate a read-only snapshot disk file. The snapshot disk file is then reconstructed using the snapshot chain information to obtain the disk data. The read-only snapshot mechanism ensures data security, and the snapshot chain information maintains the integrity of the disk state. The steps provided in this embodiment can reduce the storage cost of disk data and accelerate the acquisition speed of disk data.
[0086] In one exemplary embodiment, obtaining network data from the target virtual machine via a network interface includes: determining the source port of the virtual network interface card (NIC) of the target virtual machine based on the configuration information of the target virtual machine; capturing network data packets at the source port to obtain multiple network data packets of the virtual NIC; and performing a filtering operation on the multiple network data packets using the network address information of the target virtual machine to obtain the network data.
[0087] Optionally, the configuration information of the target virtual machine in this embodiment is specific configuration data about the target virtual machine stored in the virtual machine manager (such as Kubernetes or OpenStack) of the cloud platform virtual machine monitoring system. This includes, but is not limited to, the virtual machine's specifications (CPU, memory size), hard disk type, network interface information (IP address, MAC address, subnet mask, etc.), and virtual network card configuration (port number, driver type, etc.). This information is usually the basis for the creation, configuration, and operation of the virtual machine, and is also a prerequisite for the monitoring system to perform network monitoring on the virtual machine.
[0088] Optionally, in a virtualization environment, each virtual machine has at least one virtual network interface card (NIC) for network communication. In this embodiment, the source port of the virtual NIC refers to the port used by the virtual machine when sending network data packets.
[0089] Optionally, the network data packets in this embodiment include, but are not limited to, information such as the active Internet Protocol (IP), the destination IP address, the Transmission Control Protocol (TCP) or User Datagram Protocol (UDP) port, the protocol type, and the data payload. By capturing and analyzing the network data packets generated by the target virtual machine, the monitoring system can obtain the network usage status of the virtual machine, including traffic statistics, connection status, and response time.
[0090] Optionally, the network address information in this embodiment mainly includes the IP address and port number of the target virtual machine, and may sometimes include information such as the Media Access Control (MAC) address, which is used to uniquely identify the target virtual machine in a complex network environment so that the monitoring system can accurately capture and process the network data packets of the virtual machine.
[0091] Optionally, the network data in this embodiment includes, but is not limited to, information such as network traffic statistics, latency, and packet loss rate of the target virtual machine.
[0092] Suppose a high-traffic server virtual machine is running on XX company's cloud platform. To monitor and optimize network performance, the monitoring system needs to perform detailed monitoring of the virtual machine's network traffic. The monitoring system queries the target virtual machine's configuration information via the Kubernetes API, extracting the source port information of the virtual network interface card (NIC). For example, the virtual machine's network configuration shows that its NIC uses port eth0. At the identified source port (eth0), the monitoring system uses various network monitoring tools (such as tcpdump and Wireshark) to capture network packets. The monitoring system uses the target virtual machine's network address information (such as IP address 192.168.1.100, port numbers 80 and 443) to filter packets, ensuring that all processed packets are relevant to the target virtual machine. The filtered network packets are further analyzed to extract network performance metrics such as network throughput, latency, packet loss rate, and the number of established and disconnected connections, thus obtaining network data. When a large number of retransmission requests (such as TCP retransmissions), high latency, or packet loss are detected in the network packets of a virtual machine, an alert and troubleshooting process can be triggered. This includes checking the health status of network devices, optimizing routing policies, or adjusting the network configuration of the virtual machine to improve network performance. If network packet analysis reveals frequent communication between the virtual machine and suspicious external IP addresses, this could be an indication of a DDoS attack. Immediate measures can be taken to isolate the affected virtual machine and update firewall rules to block malicious traffic and protect the security of the cloud environment. By monitoring and analyzing the network packets of the target virtual machine, the cloud platform can not only grasp the network usage of the virtual machine in real time but also quickly respond to network performance issues and security threats.
[0093] By following the steps above, the source port of the virtual network adapter is determined based on the target virtual machine's configuration information. Network packets are then captured and filtered at the source port to obtain network data. Network address filtering allows for direct acquisition of network data relevant to the target virtual machine, improving data relevance.
[0094] The above method will be illustrated with a specific example below. Figure 4 This is a flowchart illustrating a cloud platform virtual machine monitoring method according to an embodiment of this application. The cloud platform virtual machine monitoring system includes multiple monitoring components, multiple virtual machines, and monitoring controllers configured within the multiple virtual machines. The multiple monitoring components are connected one-to-one with the multiple monitoring controllers, such as... Figure 4 As shown, the process includes the following steps:
[0095] Step S402: Start the virtual machine monitoring service;
[0096] Step S404: Obtain host information for multiple target virtual machines;
[0097] Step S406: Obtain monitoring process information for multiple virtual machines based on the aforementioned host information;
[0098] Step S408: Determine the configuration information of multiple virtual machines based on the monitoring process information of multiple virtual machines, and traverse multiple virtual machines;
[0099] Step S410: Detect whether the target virtual machine is running, wherein the target virtual machine is one of the multiple virtual machines mentioned above;
[0100] Step S412: When it is determined that the target virtual machine is running, the target monitoring controller among multiple monitoring controllers is started through the target monitoring component, and the target monitoring controller performs monitoring operations on the target virtual machine to obtain the monitoring data of the target virtual machine. For the memory data of the target virtual machine, memory data is first acquired through QGA. If QGA acquisition fails, it is acquired through libvirt. For the disk data of the target virtual machine, it is collected through the block device information of the virtual machine. For the network data of the target virtual machine, it is collected through the source port of the virtual network card. For the CPU data of the target virtual machine, the CPU working time of the target virtual machine is collected for the first time. After a preset time interval, the CPU working time of the target virtual machine is acquired for the second time. The current CPU utilization rate is obtained through the CPU time increment of the target virtual machine to obtain the processor data of the target virtual machine.
[0101] By intelligently triggering monitoring operations, it ensures that virtual machine data can be monitored in real time as long as the virtual machine is running. Furthermore, by utilizing technologies such as QGA, Libvirt, and CPU time increment calculation to obtain virtual machine memory, processor, disk, and network data, it ensures the comprehensiveness, accuracy, and real-time nature of the monitoring data, and achieves efficient deployment and operation of the cloud platform virtual machine monitoring system.
[0102] It should be noted that, through the above description of the embodiments, those skilled in the art can clearly understand that the methods according to the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes several instructions to cause a terminal device (which may be a mobile phone, computer, server, or network device, etc.) to execute the methods described in the various embodiments of this application.
[0103] This embodiment also provides a virtual machine monitoring device, which is used to implement the above embodiments and preferred embodiments; details already described will not be repeated. As used below, the term "module" can be a combination of software and / or hardware that implements a predetermined function. Although the device described in the following embodiments is preferably implemented in software, hardware implementation, or a combination of software and hardware, is also possible and contemplated.
[0104] Figure 5 This is a structural block diagram of a virtual machine monitoring device according to an embodiment of this application. The device is applied to a cloud platform virtual machine monitoring system, which includes multiple monitoring components, multiple virtual machines, and monitoring controllers disposed in the multiple virtual machines. The multiple monitoring components are connected one-to-one with the multiple monitoring controllers, such as... Figure 5 As shown, the device includes:
[0105] The monitoring module 52 is used to, when it is determined that the target virtual machine among the multiple virtual machines is in a running state, trigger the startup of the target monitoring controller among the multiple monitoring controllers through the target monitoring component, and perform monitoring operations on the target virtual machine through the target monitoring controller to obtain the monitoring data of the target virtual machine. The target monitoring component is a component among the multiple monitoring components that is connected to the target monitoring controller. The monitoring operation includes the following steps: obtaining memory data in the target virtual machine through the first component and the second component, obtaining processor data in the target virtual machine, obtaining disk data in the target virtual machine using disk information in the target virtual machine, and obtaining network data in the target virtual machine through the network interface.
[0106] In an exemplary embodiment, the monitoring module 52 is further configured to, when determining that a target virtual machine among a plurality of virtual machines is in a running state, trigger the startup of a target monitoring controller among a plurality of monitoring controllers through a target monitoring component, and perform monitoring operations on the target virtual machine through the target monitoring controller to obtain monitoring data of the target virtual machine, process the identifiers of the plurality of virtual machines using a hash function, so as to allocate the plurality of monitoring tasks corresponding to the plurality of virtual machines to a plurality of monitoring processes, wherein the monitoring process is a process in the target monitoring controller, and the monitoring process corresponds one-to-one with the monitoring component.
[0107] In an exemplary embodiment, the monitoring module 52 is further configured to calculate the value of a preset bit of the identifier of the plurality of virtual machines using the hash function to obtain a plurality of first values; map the plurality of first values to an integer space within a target value range to generate a plurality of first hash values; and for each first hash value, search for the first virtual node greater than or equal to the first hash value clockwise on the hash ring to allocate the monitoring task to the monitoring process, wherein the virtual node and the monitoring process have a one-to-one correspondence.
[0108] In an exemplary embodiment, the monitoring module 52 is further configured to number the multiple monitoring processes to construct multiple virtual nodes and multiple numbers of the virtual nodes; calculate the numerical values of the numbers of the multiple virtual nodes using the hash function to obtain multiple second values; map the multiple second values to the integer space to generate multiple second hash values; and arrange the multiple second hash values to obtain the hash ring.
[0109] In an exemplary embodiment, the monitoring module 52 is further configured to acquire first memory data of the target virtual machine through the first component; acquire second memory data through the second component when the first component malfunctions or the first memory data is abnormal; and determine the first memory data or the second memory data as the memory data, wherein the first component is set in the target virtual machine, the second component is set in the host machine where the target virtual machine is located, and the performance parameter of the first component in acquiring data is greater than the performance parameter of the second component in acquiring data.
[0110] In an exemplary embodiment, the monitoring module 52 is further configured to collect the working time of the processor in the target virtual machine according to a preset time period to obtain a plurality of the working times, wherein the working times are used to represent the time when the processor performs data processing; and to determine the utilization rate of the processor based on the plurality of the working times to determine the processor data.
[0111] In an exemplary embodiment, the monitoring module 52 is further configured to obtain disk information of the target virtual machine through a target interface, wherein the disk information includes multiple disk identifiers and snapshot chain information, and the snapshot chain information includes the sequential dependency relationship and storage mapping information of snapshot nodes between the initial disk and the disk used when the last snapshot operation was performed in the target virtual machine; based on the disk information, a snapshot operation is performed on the target virtual machine through the target interface to obtain multiple snapshot disk files, wherein the snapshot disk files correspond one-to-one with the disks in the target virtual machine, the data in the snapshot disk files is data that has been written to the disks, and the data is in a read-only state; and the multiple snapshot disk files are combined based on the snapshot chain information to obtain the disk data.
[0112] In an exemplary embodiment, the monitoring module 52 is further configured to determine the source port of the virtual network card of the target virtual machine based on the configuration information of the target virtual machine; capture network data packets at the source port to obtain multiple network data packets of the virtual network card; and perform filtering operations on the multiple network data packets using the network address information of the target virtual machine to obtain the network data.
[0113] For a description of the features of the embodiment of a virtual machine monitoring device, please refer to the relevant description of the embodiment of a virtual machine monitoring method, which will not be repeated here.
[0114] Embodiments of this application also provide an electronic device, including a memory and a processor, wherein the memory stores a computer program and the processor is configured to run the computer program to perform the steps in any of the above method embodiments.
[0115] Embodiments of this application also provide a computer-readable storage medium storing a computer program, wherein the computer program is configured to execute the steps in any of the above method embodiments when it is run.
[0116] In one exemplary embodiment, the aforementioned computer-readable storage medium may include, but is not limited to, various media capable of storing computer programs, such as a USB flash drive, read-only memory (ROM), random access memory (RAM), portable hard disk, magnetic disk, or optical disk.
[0117] Embodiments of this application also provide a computer program product, which includes a computer program that, when executed by a processor, implements the steps in any of the above method embodiments.
[0118] Embodiments of this application also provide another computer program product, including a non-volatile computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps in any of the above method embodiments.
[0119] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0120] The foregoing has provided a detailed description of a virtual machine monitoring method, storage medium, and electronic device provided in this application. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the embodiments above are merely for the purpose of helping to understand the method and its core ideas. It should be noted that those skilled in the art can make various improvements and modifications to this application without departing from its principles, and these improvements and modifications also fall within the protection scope of the claims of this application.
Claims
1. A method for monitoring virtual machines, characterized in that, An application is made in a cloud platform virtual machine monitoring system, the cloud platform virtual machine monitoring system including multiple monitoring components, multiple virtual machines, and monitoring controllers disposed in the multiple virtual machines, wherein the multiple monitoring components are connected one-to-one with the multiple monitoring controllers, the method comprising: When it is determined that the target virtual machine among multiple virtual machines is in a running state, the target monitoring controller among multiple monitoring controllers is triggered to start through the target monitoring component, and the target monitoring controller performs monitoring operations on the target virtual machine to obtain the monitoring data of the target virtual machine. The target monitoring component is the component among multiple monitoring components that is connected to the target monitoring controller. The monitoring operation includes the following steps: obtaining memory data in the target virtual machine through the first component and the second component, obtaining processor data in the target virtual machine, obtaining disk data in the target virtual machine using disk information in the target virtual machine, and obtaining network data in the target virtual machine through the network interface.
2. The method according to claim 1, characterized in that, Before determining that a target virtual machine among multiple virtual machines is running, and before triggering the startup of a target monitoring controller among multiple monitoring controllers through a target monitoring component, and performing monitoring operations on the target virtual machine through the target monitoring controller to obtain monitoring data of the target virtual machine, the method further includes: The identifiers of multiple virtual machines are processed using a hash function to allocate multiple monitoring tasks corresponding to the multiple virtual machines to multiple monitoring processes, wherein the monitoring process is a process in the target monitoring controller and the monitoring process corresponds one-to-one with the monitoring component.
3. The method according to claim 2, characterized in that, The identifiers of multiple virtual machines are processed using a hash function to distribute the monitoring tasks corresponding to the multiple virtual machines to multiple monitoring processes, including: The hash function is used to calculate the value of a preset bit of the identifier of a plurality of virtual machines to obtain a plurality of first values; The multiple first values are respectively mapped to the integer space within the target value range to generate multiple first hash values; For each of the first hash values, the first virtual node greater than or equal to the first hash value is searched clockwise on the hash ring to assign the monitoring task to the monitoring process, wherein the virtual node and the monitoring process have a one-to-one correspondence.
4. The method according to claim 3, characterized in that, For each hash value, the method further includes searching clockwise on the hash ring for the first virtual node greater than or equal to the hash value before assigning the monitoring task to the monitoring process: The monitoring processes are numbered to construct multiple virtual nodes and the numbering of the multiple virtual nodes; The hash function is used to calculate the numerical values of the numbers of the multiple virtual nodes to obtain multiple second values; The multiple second values are respectively mapped to the integer space to generate multiple second hash values; Arrange multiple second hash values to obtain the hash ring.
5. The method according to claim 1, characterized in that, Obtaining memory data from the target virtual machine through the first and second components includes: The first component is used to obtain the first memory data of the target virtual machine; In the event of an anomaly in the first component or an anomaly in the first memory data, the second memory data is obtained through the second component. The first memory data or the second memory data is determined as the memory data, wherein the first component is set in the target virtual machine, the second component is set in the host machine where the target virtual machine is located, and the performance parameter of the first component in acquiring data is greater than the performance parameter of the second component in acquiring data.
6. The method according to claim 1, characterized in that, Obtaining processor data from the target virtual machine includes: The working time of the processor in the target virtual machine is collected according to a preset time period to obtain multiple working times, wherein the working time is used to represent the time the processor spends processing data; The processor utilization is determined based on multiple said operating times to determine the processor data.
7. The method according to claim 1, characterized in that, Obtaining disk data in the target virtual machine using disk information in the target virtual machine includes: The target virtual machine's disk information is obtained through the target interface. The disk information includes multiple disk identifiers and snapshot chain information. The snapshot chain information includes the sequential dependency relationship and storage mapping information of snapshot nodes between the target virtual machine from the initial disk to the disk used when the last snapshot operation was performed. Based on the disk information, a snapshot operation is performed on the target virtual machine through the target interface to obtain multiple snapshot disk files. The snapshot disk files correspond one-to-one with the disks in the target virtual machine. The data in the snapshot disk files is data that has been written to the disk and is in a read-only state. The disk data is obtained by combining multiple snapshot disk files based on the snapshot chain information.
8. The method according to claim 1, characterized in that, Obtaining network data from the target virtual machine via the network interface includes: Based on the configuration information of the target virtual machine, determine the source port of the virtual network card of the target virtual machine; Capture network packets at the source port to obtain multiple network packets of the virtual network card; The network data is obtained by filtering multiple network data packets using the network address information of the target virtual machine.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, wherein the computer program, when executed by a processor, implements the steps of the method described in any one of claims 1 to 8.
10. 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 computer program, it implements the steps of the method described in any one of claims 1 to 8.