Virtual machine monitoring method and device, storage medium and electronic equipment
By obtaining monitoring instructions sent by the virtual machine management platform on the host, obtaining the target memory image file of the target virtual machine, and extracting the data to be monitored based on the monitoring item list, the problem of low monitoring efficiency of virtual machine is solved, and the effect of still being able to monitor normally when there is a problem with the virtual machine.
Patent Information
- Application Number
- CN202411826562.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-11
- Publication Date
- 2025-03-28
AI Technical Summary
In the prior art, the monitoring efficiency of virtual machines is inefficient and cannot run normally when the virtual machines are stuck or crashed due to lack of resources or errors, resulting in the inability to monitor the virtual machines.
By obtaining monitoring instructions sent by the virtual machine management platform on the host, obtaining the target memory image file of the target virtual machine, and extracting the data to be monitored from the memory image file according to the monitoring item list to monitor the status of the virtual machine.
It realizes monitoring of virtual machines without relying on internal software of virtual machines, improves the efficiency and reliability of virtual machine monitoring, and can still extract memory images normally for analysis when there is lag or error in the virtual machine.
Smart Images

Figure CN119718541A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the computer field, and in particular, to a monitoring method, device, storage medium and electronic device for a virtual machine. Background Art
[0002] In the related art, cloud computing management platforms mostly monitor the operation status of virtual machines by installing specific software inside the virtual machines under the platform. This type of software reports various data inside the virtual machine to the platform, so that the platform can grasp the resource usage and other information of the virtual machine in real time, which is convenient for users to view and adjust resources. However, when the virtual machine freezes or crashes due to lack of relevant resources or errors, the monitoring software cannot run normally, resulting in the inability to monitor the virtual machine.
[0003] It can be seen from this that the related technology has the problem of low efficiency in monitoring virtual machines.
[0004] Currently, no effective solution has been proposed for the above-mentioned problems existing in the related technologies. Summary of the invention
[0005] The embodiments of the present application provide a method, device, storage medium and electronic device for monitoring a virtual machine, so as to at least solve the problem of low efficiency in monitoring virtual machines existing in the related art.
[0006] According to one embodiment of the present application, a method for monitoring a virtual machine is provided, which is applied to a host machine, in which a virtual machine is running, and the host machine is connected to a virtual machine management platform, comprising: upon receiving a monitoring instruction sent by the virtual machine management platform, obtaining a target memory image file of a target virtual machine indicated by the monitoring instruction; determining a list of monitoring items for monitoring the target virtual machine; extracting data to be monitored from the target memory image file according to the list of monitoring items; and monitoring the status of the target virtual machine based on the data to be monitored.
[0007] In an exemplary embodiment, obtaining the target memory image file of the target virtual machine indicated by the monitoring instruction includes: determining whether the memory image file exists in the host machine; when it is determined that the memory image file exists in the host machine, determining the target time identifier of the memory image file, and when the target time identifier satisfies a preset time condition, determining the memory image file as the target memory image file, and when the target time identifier does not satisfy the preset time condition, extracting the target memory image file from the target virtual machine; when it is determined that the memory image file does not exist in the host machine, extracting the target memory image file from the target virtual machine.
[0008] In an exemplary embodiment, extracting the target memory image file from the target virtual machine includes: creating a target memory snapshot file of the target virtual machine when the target virtual machine is in a running state; and determining the target memory image file in the target memory snapshot file.
[0009] In an exemplary embodiment, determining the target memory image file in the memory snapshot file includes: determining a virtual machine configuration file included in the memory snapshot file; and determining files included in the memory snapshot file other than the virtual machine configuration file as the target memory image file.
[0010] In an exemplary embodiment, before determining whether a memory image file exists in the host machine, the method further includes: obtaining a memory snapshot file from the target virtual machine according to a predetermined time period; determining the memory image file from the memory snapshot file; adding a time stamp to the memory image file; and saving the memory image file with the time stamp added to the host machine.
[0011] In an exemplary embodiment, determining a list of monitoring items for monitoring the target virtual machine includes: determining the operating system type of the target virtual machine; determining a monitoring policy for the virtual machine management platform to monitor the target virtual machine, wherein the monitoring policy allows modification through the virtual machine management platform; determining a target policy supported by the operating system type included in the monitoring policy; and setting the list of monitoring items according to the target policy.
[0012] In an exemplary embodiment, monitoring the state of the target virtual machine based on the data to be monitored includes: classifying the monitoring data to obtain classified data of multiple categories; converting the multiple classified data into a target format to obtain target data; determining an analysis strategy corresponding to the target data; and analyzing the target data according to the analysis strategy to determine the state of the virtual machine.
[0013] According to another embodiment of the present application, a monitoring device for a virtual machine is provided, including: a host machine applied thereto, wherein a virtual machine is running in the host machine, and the host machine is connected to a virtual machine management platform, and includes: an acquisition module, for acquiring, upon receiving a monitoring instruction sent by the virtual machine management platform, a target memory image file of a target virtual machine indicated by the monitoring instruction; a determination module, for determining a list of monitoring items for monitoring the target virtual machine; an extraction module, for extracting data to be monitored from the target memory image file according to the list of monitoring items; and a monitoring module, for monitoring the state of the target virtual machine based on the data to be monitored.
[0014] According to another embodiment of the present application, a computer-readable storage medium is provided, in which a computer program is stored, wherein the computer program is configured to execute the steps of any of the above method embodiments when run.
[0015] According to another embodiment of the present application, an electronic device is 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 execute the steps in any one of the above method embodiments.
[0016] According to another embodiment of the present application, a computer program product is provided, including a computer program, and when the computer program is executed by a processor, the steps in any of the above method embodiments are implemented.
[0017] Through this application, when a monitoring instruction sent by a virtual machine management platform is received, the target memory image file of the target virtual machine indicated by the monitoring instruction is obtained; a list of monitoring items for monitoring the target virtual machine is determined; data to be monitored is extracted from the target memory image file according to the list of monitoring items; and the state of the target virtual machine is monitored based on the data to be monitored. Since the target memory image file of the target virtual machine can be obtained, monitoring data can be extracted from the target memory image file according to the list of monitoring items to monitor the state of the target virtual machine, and there is no need to monitor the virtual machine using software installed inside the virtual machine. Therefore, the problem of low efficiency in monitoring virtual machines in the related art can be solved, and the effect of improving the efficiency of monitoring virtual machines can be achieved. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] Figure 1 It is a hardware structure block diagram of a server device of a virtual machine monitoring method according to an embodiment of the present application;
[0019] Figure 2 is a flowchart of a method for monitoring a virtual machine according to an embodiment of the present application;
[0020] Figure 3 is a schematic diagram of the operating architecture of the monitoring system according to an embodiment of the present application;
[0021] Figure 4 This is a flow chart of obtaining a target memory image file according to an embodiment of the present application;
[0022] Figure 5 A flow chart of extracting data to be monitored from a target memory image file according to a monitoring item list according to an embodiment of the present application;
[0023] Figure 6 is a state flow chart of monitoring a target virtual machine based on data to be monitored according to an embodiment of the present application;
[0024] Figure 7 It is a structural block diagram of a monitoring device for a virtual machine according to an embodiment of the present application. DETAILED DESCRIPTION
[0025] The embodiments of the present application will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.
[0026] It should be noted that the terms "first", "second", etc. in the specification and claims of this application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence.
[0027] The method embodiments provided in the embodiments of the present application can be executed in a server device or a similar computing device. Taking running on a server device as an example, Figure 1 1 is a hardware structure block diagram of a server device of a virtual machine monitoring method according to an embodiment of the present application. Figure 1 As shown, the server device may include one or more ( Figure 1 Only one is shown in the figure) a processor 102 (the processor 102 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA) and a memory 104 for storing data, wherein the server device may also include a transmission device 106 and an input / output device 108 for communication functions. It can be understood by those skilled in the art that Figure 1 The structure shown is only for illustration and does not limit the structure of the above server device. Figure 1 More or fewer components as shown, or with Figure 1 Different configurations shown.
[0028] The memory 104 can be used to store computer programs, for example, software programs and modules of application software, such as the computer program corresponding to the monitoring method of the virtual machine in the embodiment of the present application. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, that is, to implement the above method. The memory 104 may include a high-speed random access memory, and may also include a 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 a memory remotely arranged relative to the processor 102, and these remote memories may be connected to the server device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0029] The transmission device 106 is used to receive or send data via a network. The specific example of the above network may include a wireless network provided by a communication provider of the server device. In one example, the transmission device 106 includes a network adapter (Network Interface Controller, referred to as NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission device 106 can be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.
[0030] In this embodiment, a method for monitoring a virtual machine is provided, which is applied to a host machine, wherein a virtual machine is running on the host machine, and the host machine is connected to a virtual machine management platform. Figure 2 is a flow chart of a method for monitoring a virtual machine according to an embodiment of the present application, such as Figure 2 As shown, the process includes the following steps:
[0031] Step S202, when receiving the monitoring instruction sent by the virtual machine management platform, obtaining the target memory image file of the target virtual machine indicated by the monitoring instruction;
[0032] In this embodiment, a virtual machine management platform can be connected to multiple host machines, and one host machine can run one or more virtual machines. The virtual machine can be a qemu virtual machine. The virtual machine management platform can collect information such as memory usage, network IP access, and active process status of the virtual machine without intruding into the virtual machine operating system. And perform visualization processing based on the collected information. The target virtual machine can be built through virtualization technology, which can virtualize a physical machine into multiple independent virtual machines, each of which runs on its own operating system and has its own hardware resources. Virtualization technology can enable multiple virtual machines to run on a physical server, reducing resource waste. The virtual machine built by virtualization technology can achieve resource isolation between different systems, ensure the independence of different system resources, and at the same time achieve resource reuse between heterogeneous systems to improve resource utilization efficiency. The virtual machine management platform can monitor the status of the virtual machine in real time during the operation of the virtual machine to detect whether the virtual machine is running normally. The status information of the virtual machine may include: whether the virtual machine is running normally, and the system call, thread status, process status, memory usage, CPU usage, disk I / O usage, etc. when the virtual machine is running. The status information of the virtual machine can be determined by the memory image file of the virtual machine.
[0033] In this embodiment, the target memory image file can be obtained according to a predetermined time period, and the acquisition time of the target memory image file can be marked, and the acquisition time and the target memory image file can be saved in the host machine. By obtaining the target image file of the target virtual machine, data analysis and extraction can be realized from the outside of the virtual machine without installing relevant monitoring software inside the virtual machine. When a freeze or error occurs inside the virtual machine, the memory image can still be extracted normally for analysis. Malicious programs inside the virtual machine cannot interfere with the platform's extraction and analysis of the virtual machine's memory image. The virtual machine management platform can obtain the target memory image information of the target virtual machine from the outside without occupying the resources allocated to the target virtual machine. In the scenario where there are a large number of virtual machines on the platform, virtual machine management can directly collect and analyze in batches without installing monitoring software for the virtual machines one by one, saving time.
[0034] Step S204, determining a list of monitoring items for monitoring the target virtual machine;
[0035] In this embodiment, the list of monitoring items for monitoring the target virtual machine may be determined according to the operating system type of the target virtual machine, and the user may also generate the list of monitoring items through the virtual machine management platform according to monitoring requirements.
[0036] Step S206, extracting the data to be monitored from the target memory image file according to the monitoring item list;
[0037] In this embodiment, after obtaining the monitoring item list, the target image file can be extracted through the monitoring item list to obtain monitoring data. The data to be monitored may include whether the virtual machine is running normally, and the system call, thread status, process status, memory usage, CPU usage, disk I / O usage, etc. when the virtual machine is running.
[0038] Step S208: monitor the state of the target virtual machine based on the data to be monitored.
[0039] In this embodiment, the state of the target virtual machine can be determined based on the data to be monitored. When the value in the data to be monitored does not meet the preset parameter value, it can be determined that the target virtual machine is in an abnormal state. When the target virtual machine is in an abnormal state, an alarm operation can be performed. For example, a process blacklist is set, and when there is a process in the blacklist in the virtual machine memory image, the virtual machine management platform will generate an alarm.
[0040] The execution subject of the above steps may be a server, a host machine, a processor of the host machine, etc., but is not limited thereto.
[0041] Through this application, when a monitoring instruction sent by a virtual machine management platform is received, the target memory image file of the target virtual machine indicated by the monitoring instruction is obtained; a list of monitoring items for monitoring the target virtual machine is determined; data to be monitored is extracted from the target memory image file according to the list of monitoring items; and the state of the target virtual machine is monitored based on the data to be monitored. Since the target memory image file of the target virtual machine can be obtained, monitoring data can be extracted from the target memory image file according to the list of monitoring items to monitor the state of the target virtual machine, and there is no need to monitor the virtual machine using software installed inside the virtual machine. Therefore, the problem of low efficiency in monitoring virtual machines in the related art can be solved, and the effect of improving the efficiency of monitoring virtual machines can be achieved.
[0042] In an exemplary embodiment, the target memory image file of the target virtual machine indicated by the monitoring instruction is obtained, including: determining whether the memory image file exists in the host machine; determining the target time mark of the memory image file when it is determined that the memory image file exists in the host machine, determining the memory image file as the target memory image file when the target time mark satisfies the preset time condition, and extracting the target memory image file from the target virtual machine when the target time mark does not satisfy the preset time condition; extracting the target memory image file from the target virtual machine when it is determined that the memory image file does not exist in the host machine. In this embodiment, the host machine can obtain the memory image file of the target virtual machine at a predetermined time interval, so it can be determined first whether the memory image file exists in the host machine, and if it exists, determine the acquisition time of the memory image file, that is, the target time mark. When the target time mark satisfies the preset time condition, the memory image file is determined as the target memory image file. When the target time mark does not satisfy the preset time condition or the memory image file does not exist in the host machine, the target memory image file can be extracted from the target virtual machine. Among them, the preset time condition can be the time set by the user through the virtual machine management platform according to needs.
[0043] In the above embodiment, the virtual machine management platform can send the target virtual machine information to be monitored to the host machine. The host machine first queries whether there is a memory image file of the target virtual machine based on the target virtual machine information sent by the virtual machine management platform. If it exists, it queries whether the time stamp of the memory image file meets the policy set by the platform, such as within 1 day, 1 hour, etc.; if it meets the requirements, the latest memory image file is output to the memory image data extraction module of the host machine, and the extraction success status is reported to the platform; if it does not meet the requirements or does not exist, the target memory image file is obtained from the target virtual machine.
[0044] In the above embodiment, the virtual machine management platform, the host machine and the target virtual machine can constitute a monitoring system. The schematic diagram of the monitoring system operation architecture can be found in the attached Figure 3 ,like Figure 3 As shown, the virtual machine management platform can be a cloud computing management platform, and the host machine can include a memory image export module, a memory image data extraction module, and a memory image data analysis module. The cloud computing management platform will send a virtual machine information collection instruction to the memory image export module. The memory image export module can first query whether there is a latest memory image file that meets the time range. If it exists, the image file is time-stamped; if it does not exist, the memory image of the virtual machine is extracted and time-stamped by executing relevant instructions on the host machine where the target virtual machine is located. The memory image export module inputs the image file with the latest time stamp to the memory image data extraction module. The memory image data analysis module extracts various data from the memory image file and passes the data to the memory image data analysis module. The memory image data analysis module classifies, organizes and saves the extracted memory-related information data, and reports abnormal values to the platform.
[0045] In the above embodiment, when there exists a memory image file in the host machine whose acquisition time meets the preset time condition, the memory image file is directly determined as the target memory image file. If it does not exist, the target memory image file is obtained from the target virtual machine. This can ensure that the acquired memory image file is the latest and the speed of acquiring the target memory image file can be guaranteed, thereby improving the timeliness and accuracy of monitoring. It is suitable for scenarios where frequent monitoring of the virtual machine status is required, such as virtual machine performance optimization, troubleshooting, etc.
[0046] In an exemplary embodiment, extracting the target memory image file from the target virtual machine includes: creating a target memory snapshot file of the target virtual machine when the target virtual machine is in a running state; and determining the target memory image file from the target memory snapshot file. In this embodiment, the host machine can query the running state of the target virtual machine. Since the memory image file can only be extracted when the virtual machine is in a running state, when there is no memory image file that meets the requirements in the host machine and the target virtual machine is in a non-running state, the host machine will stop the export operation and report the extraction failure status to the platform. When there is no memory image file that meets the requirements in the host machine, but the target virtual machine is in a running state, the host machine will create a target memory snapshot file of the target virtual machine; and determine the target memory image file from the target memory snapshot file.
[0047] In the above embodiment, when the target virtual machine is in operation, the target memory image file can be obtained by creating a target memory snapshot file, thereby obtaining the memory image file without affecting the normal operation of the virtual machine.
[0048] In an exemplary embodiment, determining the target memory image file in the memory snapshot file includes: determining a virtual machine configuration file included in the memory snapshot file; and determining a file other than the virtual machine configuration file included in the memory snapshot file as the target memory image file. In this embodiment, the target memory snapshot file can be trimmed to retain only the content in the target memory snapshot file that is related to the target memory image file of the target virtual machine.
[0049] In the above embodiment, the flowchart of obtaining the target memory image file can be found in the attached Figure 4 ,like Figure 4 As shown, the process includes:
[0050] Step S402: The platform sends a monitoring request.
[0051] Step S404, determine whether there is a memory image file, if the determination result is yes, execute step S406, if the determination result is no, execute step S408.
[0052] Step S406, determining whether the latest memory image creation time is within a set range, if the determination result is yes, executing step S416, if the determination result is no, executing step S408.
[0053] Step S408, determining whether the virtual machine is in a running state, if the determination result is yes, executing step S410, if the determination result is no, executing step S418.
[0054] Step S410: creating a virtual machine memory snapshot file.
[0055] Step S412, cutting the memory snapshot file into a target memory image file.
[0056] Step S414, record the creation time of the memory image file.
[0057] Step S41, 6, output the target memory image file to the memory image data extraction module.
[0058] Step S418, returning the execution status to the platform.
[0059] In the above embodiment, the memory image file of the virtual machine can be exported through the memory image export module. When a new memory image file needs to be generated, libvirt can be used to create a memory snapshot file of the virtual machine, and then the memory snapshot file is trimmed to remove the header information related to the virtual machine hardware configuration of the snapshot file, and the memory image file that can be parsed is transmitted to the memory image data extraction module.
[0060] In the above embodiment, by separating the virtual machine configuration file and the memory image file, the virtual machine memory state can be monitored more accurately, which is suitable for scenarios that require in-depth analysis of the virtual machine memory state, such as memory leak detection, memory performance optimization, etc.
[0061] In an exemplary embodiment, before determining whether a memory image file exists in the host machine, the method further includes: obtaining a memory snapshot file from the target virtual machine according to a predetermined time period; determining the memory image file from the memory snapshot file; adding a time stamp to the memory image file; and saving the memory image file with the time stamp added to the host machine. In this embodiment, a time stamp can be added to the trimmed target memory image file, and then passed to the memory image data extraction module, and finally the extraction success status is reported to the platform.
[0062] In the above embodiment, the memory image file can be regularly acquired and saved to establish a history record of the virtual machine state, thereby realizing historical backtracking and trend analysis of the virtual machine state.
[0063] In an exemplary embodiment, the determination of the list of monitoring items for monitoring the target virtual machine includes: determining the operating system type of the target virtual machine; determining the monitoring strategy for the virtual machine management platform to monitor the target virtual machine, wherein the monitoring strategy allows modification through the virtual machine management platform; determining the target strategy supported by the operating system type included in the monitoring strategy; and setting the list of monitoring items according to the target strategy. In this embodiment, after receiving the memory image file output by the memory image export module, the memory image data extraction module can first set a list of monitoring items according to the monitoring strategy set by the platform and the operating system type of the virtual machine. The list of monitoring items can be the intersection of the monitoring items included in the platform strategy and the monitoring items that can be extracted by the virtual machine operating system. The memory image data extraction module can extract and save relevant data from the image file in sequence according to the content of the monitoring item list. After the content in the monitoring item list is extracted, the memory image data extraction module integrates the data and outputs it to the memory image data analysis module, and finally reports the execution result to the platform.
[0064] In the above embodiment, after determining the monitoring item list, the data to be monitored can be extracted from the target memory image file according to the monitoring item list, wherein the flow chart of extracting the data to be monitored from the target memory image file according to the monitoring item list can be found in the attached Figure 5 ,like Figure 5 As shown, the process includes:
[0065] Step S502, receiving a target memory image file.
[0066] Step S504, setting a monitoring item list according to the platform policy (corresponding to the above monitoring policy) and the virtual machine operating system type.
[0067] Step S506, extracting relevant data from the target memory image file according to the monitoring items and saving it.
[0068] Step S508, determine whether the current item is the last item in the monitoring item list. If the judgment result is yes, execute step S510, if the judgment result is no, execute step S512.
[0069] Step S510, output monitoring data to the memory mirror data analysis module.
[0070] Step S512, select the next monitoring item.
[0071] Step S514: Return the execution status to the platform.
[0072] In the above embodiment, the memory image data extraction module can set the monitoring item list according to the relevant policies set by the platform and the memory extraction method supported by the virtual machine operating system, and extract the corresponding monitoring information through the extraction tool. For example, the instruction windows.pslist of the volatility3 tool extracts the running process information of the virtual machine memory image file of the Windows operating system, and transmits the extracted results to the memory image data analysis module.
[0073] In the above embodiment, the monitoring items can be dynamically adjusted according to the operating system type of the target virtual machine and the policy of the management platform. This is suitable for scenarios where customized monitoring of different types of operating systems is required, such as performance monitoring of Windows systems and Linux systems, and can more effectively discover and solve problems.
[0074] In an exemplary embodiment, the monitoring of the state of the target virtual machine based on the data to be monitored includes: classifying the monitoring data to obtain classified data of multiple categories; converting the multiple classified data into a target format to obtain target data; determining an analysis strategy corresponding to the target data; analyzing the target data according to the analysis strategy to determine the state of the virtual machine. In this embodiment, the memory mirror data analysis module can convert the incoming text into a corresponding json format file according to the relevant type and save it, and report abnormal information if it meets the platform alarm strategy. For example, according to the process information, a process is converted into an object according to the key-value pair information such as process ID, parent process ID, process name, number of threads, number of handles, creation date, etc., and all process objects are converted into json format and saved in an array. Then, according to the corresponding strategy formulated by the platform, detect whether there is abnormal information, such as abnormal process name, large number of occupied handles, etc. If it exists, report it to the platform.
[0075] It should be noted that the json format is only one format included in the target format, and the target format may also include other formats, which is not limited in the present invention.
[0076] In the above embodiment, the state flow chart of monitoring the target virtual machine based on the data to be monitored can be found in the attached Figure 6 ,like Figure 6 As shown, the process includes:
[0077] Step S602, receiving monitoring data text.
[0078] Step S604, dividing the monitoring data text according to weight and setting the corresponding analysis method.
[0079] Step S606: Use a corresponding method to parse a data text into a json format and save it persistently.
[0080] Step S608, determine whether there is any abnormality in the data according to the platform policy. If the judgment result is yes, execute step S610, if the judgment result is no, execute step S612.
[0081] Step S610: Report abnormal items to the platform.
[0082] Step S612, determine whether it is the last text item, if the judgment result is yes, execute step S614, if the judgment result is no, execute step S616.
[0083] Step S614, returning the execution status to the platform.
[0084] Step S616, select the next text.
[0085] In the above embodiment, the memory image data analysis module receives the data text output by the memory image data extraction module. The corresponding processing method is matched according to the data type, and the processed data is saved in the platform database to facilitate subsequent visualization operations; the processed data is judged according to the strategy set by the platform to determine whether there is an abnormality. If there is, the information is reported, so that the platform generates an alarm to notify the user. Repeat the above operation until all data is processed, and finally return the execution status to the platform.
[0086] In the above embodiments, by classifying and formatting the monitoring data and adopting a preset analysis strategy, the processing efficiency of the monitoring data and the accuracy of the analysis can be improved. In scenarios where a large amount of monitoring data is quickly analyzed, such as performance monitoring and troubleshooting in a large-scale virtualization environment, the level of intelligence of virtual machine management can be significantly improved.
[0087] In an exemplary embodiment, when the host receives the monitoring instruction sent by the virtual machine management platform, the host determines the operating parameters of the host and the virtual machine log file in the host, and determines the state of the target virtual machine based on the operating parameters and the virtual machine log file. The operating parameters may include CPU usage, memory occupancy, disk I / O, network traffic, power supply and temperature, etc. If the CPU usage of the host is very high, it may indicate that the virtual machine is running under high load or that multiple virtual machines are competing for CPU resources. If the memory usage of the host can reflect the memory allocation and usage of the virtual machine. If the memory usage of the host is close to 100%, it may mean that the memory resources of the virtual machine are insufficient. The disk I / O activity of the host can reflect the disk read and write activity of the virtual machine. If the I / O waiting time increases, it may mean that the disk performance of the virtual machine is bottlenecked. The network traffic of the host can reflect the network activity of the virtual machine. If the network traffic is abnormal, it may indicate that the virtual machine is experiencing network problems. The power consumption and temperature of the host can indirectly reflect the operating intensity of the virtual machine, because a highly loaded virtual machine may cause these parameters of the host to increase. The virtual machine log file on the host can provide a detailed log of the virtual machine when it is running, which is helpful for diagnosing problems of the virtual machine. You can indirectly understand the running status of the virtual machine by monitoring the resource usage of the host machine.
[0088] In the above-mentioned embodiment, without relying on the internal software of the virtual machine, the memory snapshot file of the virtual machine is cut into a memory image file, and then the relevant information is extracted. After the extracted information is processed into a standard format, the information is displayed and the abnormal status is reported through the management platform. The virtual machine management platform can achieve the purpose of monitoring the internal operation status of the virtual machine by exporting, extracting, and analyzing the virtual machine memory image file without intruding into the virtual machine. The method has the following advantages: 1. Low invasiveness, no software needs to be installed in the target virtual machine, which is convenient for operation and maintenance personnel to implement, and can also avoid the virtual machine user from having negative emotions due to logging into the system to ask for keys or operation duplication. 2. Resource isolation, the three modules that constitute the monitoring system are all running in an environment outside the virtual machine, do not consume the resources of the virtual machine itself, and do not affect the operation of the virtual machine business. 3. Stable operation, when an abnormality occurs inside the virtual machine or it cannot run normally due to malicious attacks, the monitoring system can still export the virtual machine memory image for analysis, and will not stop monitoring due to the crash of the virtual machine. 4. Resources can be reused, the system can complete the monitoring operation through the existing memory snapshot file; the snapshot file generated by monitoring can also be used as a recovery point for the virtual machine. When the platform sets a periodic snapshot strategy, the generated memory snapshot files can also be reused to complete the monitoring operation. 5. High scalability, the monitoring system can adjust the monitoring cycle, monitoring content and alarm standards according to the strategy set by the platform.
[0089] Through the description of the above implementation methods, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a number of instructions for a terminal device (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods described in each embodiment of the present application.
[0090] In this embodiment, a monitoring device for a virtual machine is also provided, which is applied to a host machine, in which a virtual machine is running, and the host machine is connected to a virtual machine management platform. The device is used to implement the above-mentioned embodiments and preferred implementation modes, and the descriptions that have been made 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 devices described in the following embodiments are preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceivable.
[0091] Figure 7 is a structural block diagram of a monitoring device for a virtual machine according to an embodiment of the present application, such as Figure 7 As shown, the device comprises:
[0092] The acquisition module 72 is used to acquire the target memory image file of the target virtual machine indicated by the monitoring instruction when receiving the monitoring instruction sent by the virtual machine management platform;
[0093] A determination module 74 is used to determine a list of monitoring items for monitoring the target virtual machine;
[0094] The extraction module 76 is used to extract the data to be monitored from the target memory image file according to the monitoring item list; the monitoring module 78 is used to monitor the state of the target virtual machine based on the data to be monitored.
[0095] Among them, the acquisition module corresponds to the above-mentioned memory image export module, the extraction module corresponds to the above-mentioned memory image data extraction module, and the monitoring module corresponds to the above-mentioned memory image data analysis module.
[0096] In an exemplary embodiment, the acquisition module 72 can implement the acquisition of the target memory image file of the target virtual machine indicated by the monitoring instruction in the following manner: determine whether there is a memory image file in the host machine; when it is determined that the memory image file exists in the host machine, determine the target time identifier of the memory image file, and when the target time identifier meets the preset time condition, determine the memory image file as the target memory image file; when the target time identifier does not meet the preset time condition, extract the target memory image file from the target virtual machine; when it is determined that the memory image file does not exist in the host machine, extract the target memory image file from the target virtual machine.
[0097] In an exemplary embodiment, the acquisition module 72 can implement the extraction of the target memory image file from the target virtual machine in the following manner: when the target virtual machine is in a running state, create a target memory snapshot file of the target virtual machine; and determine the target memory image file in the target memory snapshot file.
[0098] In an exemplary embodiment, the acquisition module 72 can implement the determination of the target memory image file in the memory snapshot file in the following manner: determine the virtual machine configuration file included in the memory snapshot file; and determine the files included in the memory snapshot file other than the virtual machine configuration file as the target memory image file.
[0099] In an exemplary embodiment, the device can be used to obtain a memory snapshot file from the target virtual machine according to a predetermined time period before determining whether the memory image file exists in the host machine; determine the memory image file from the memory snapshot file; add a time stamp to the memory image file; and save the memory image file with the time stamp added to the host machine.
[0100] In an exemplary embodiment, the determination module 74 can implement the determination of the list of monitoring items for monitoring the target virtual machine in the following manner: determining the operating system type of the target virtual machine; determining the monitoring strategy of the virtual machine management platform for monitoring the target virtual machine, wherein the monitoring strategy allows modification through the virtual machine management platform; determining the target strategy supported by the operating system type included in the monitoring strategy; and setting the monitoring item list according to the target strategy.
[0101] In an exemplary embodiment, the monitoring module 76 can implement the monitoring of the state of the target virtual machine based on the data to be monitored in the following manner: classifying the monitoring data to obtain classified data of multiple categories; converting the multiple classified data into a target format to obtain target data; determining an analysis strategy corresponding to the target data; and analyzing the target data according to the analysis strategy to determine the state of the virtual machine.
[0102] It should be noted that the above modules can be implemented by software or hardware. For the latter, it can be implemented in the following ways, but not limited to: the above modules are all located in the same processor; or the above modules are located in different processors in any combination.
[0103] An embodiment of the present application further provides a computer-readable storage medium, in which a computer program is stored, wherein the computer program is configured to execute the steps of any of the above method embodiments when run.
[0104] In an exemplary embodiment, the computer-readable storage medium may include, but is not limited to, various media that can store computer programs, such as a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk.
[0105] An embodiment of the present application further provides an electronic device, including a memory and a processor, wherein a computer program is stored in the memory, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.
[0106] In an exemplary embodiment, the electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor, and the input / output device is connected to the processor.
[0107] An embodiment of the present application further provides a computer program product, which includes a computer program. When the computer program is executed by a processor, the steps in any one of the above method embodiments are implemented.
[0108] For specific examples in this embodiment, reference may be made to the examples described in the above embodiments and exemplary implementation modes, and this embodiment will not be described in detail herein.
[0109] Obviously, those skilled in the art should understand that the above modules or steps of the present application can be implemented by a general computing device, they can be concentrated on a single computing device, or distributed on a network composed of multiple computing devices, they can be implemented by a program code executable by a computing device, so that they can be stored in a storage device and executed by the computing device, and in some cases, the steps shown or described can be executed in a different order from that herein, or they can be made into individual integrated circuit modules, or multiple modules or steps therein can be made into a single integrated circuit module for implementation. Thus, the present application is not limited to any specific combination of hardware and software.
[0110] The above description is only the preferred embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the principles of the present application shall be included in the protection scope of the present application.
Claims
1. A method for monitoring a virtual machine, characterized in that: Applied to a host machine, wherein a virtual machine is running on the host machine, and the host machine is connected to a virtual machine management platform, include: Upon receiving the monitoring instruction sent by the virtual machine management platform, obtaining a target memory image file of the target virtual machine indicated by the monitoring instruction; Determine a list of monitoring items for monitoring the target virtual machine; Extracting the data to be monitored from the target memory image file according to the monitoring item list; The state of the target virtual machine is monitored based on the data to be monitored.
2. The method according to claim 1, characterized in that The step of obtaining the target memory image file of the target virtual machine indicated by the monitoring instruction includes: Determine whether a memory image file exists in the host machine; In the case where it is determined that the memory image file exists in the host machine, determining a target time identifier of the memory image file, determining the memory image file as the target memory image file if the target time identifier satisfies a preset time condition, and extracting the target memory image file from the target virtual machine if the target time identifier does not satisfy the preset time condition; When it is determined that the memory image file does not exist in the host machine, the target memory image file is extracted from the target virtual machine.
3. The method according to claim 2, characterized in that The extracting the target memory image file from the target virtual machine comprises: When the target virtual machine is in a running state, creating a target memory snapshot file of the target virtual machine; The target memory image file is determined in the target memory snapshot file.
4. The method according to claim 3, characterized in that Determining the target memory image file in the memory snapshot file includes: Determine a virtual machine configuration file included in the memory snapshot file; The files included in the memory snapshot file except the virtual machine configuration file are determined as the target memory image file.
5. The method according to claim 2, characterized in that: Before determining whether the memory image file exists in the host machine, the method further includes: Obtaining a memory snapshot file from the target virtual machine according to a predetermined time period; Determine the memory image file from the memory snapshot file; Adding a time stamp to the memory image file; The memory image file with the time stamp added is saved in the host machine.
6. The method according to claim 1, characterized in that The determining of a list of monitoring items for monitoring the target virtual machine includes: Determine the operating system type of the target virtual machine; Determining a monitoring strategy for the virtual machine management platform to monitor the target virtual machine, wherein the monitoring strategy allows modification through the virtual machine management platform; Determining a target strategy supported by the operating system type included in the monitoring strategy; The monitoring item list is set according to the target strategy.
7. The method according to claim 1, characterized in that The monitoring the state of the target virtual machine based on the data to be monitored includes: Classifying the monitoring data to obtain classified data of multiple categories; Converting the plurality of classified data into a target format to obtain target data; Determining an analysis strategy corresponding to the target data; The target data is analyzed according to the analysis strategy to determine the state of the virtual machine.
8. A monitoring device for a virtual machine, characterized in that: Applied to a host machine, wherein a virtual machine is running on the host machine, and the host machine is connected to a virtual machine management platform, include: An acquisition module, configured to, upon receiving a monitoring instruction sent by the virtual machine management platform, acquire a target memory image file of a target virtual machine indicated by the monitoring instruction; A determination module, used to determine a list of monitoring items for monitoring the target virtual machine; An extraction module is used to extract the data to be monitored from the target memory image file according to the monitoring item list; a monitoring module is used to monitor the state of the target virtual machine based on the data to be monitored.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein the computer program implements the steps of the method described in any one of claims 1 to 7 when executed by a processor.
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, the steps of the method described in any one of claims 1 to 7 are implemented.