Process monitoring method and system based on qemu-guest-agent plug-in

The qemu-guest-agent plug-in based process monitoring system addresses the challenge of locating abnormal processes in cloud servers by using lock files to manage function switches, enabling efficient resource monitoring and data reporting without server login.

CN119201604APending Publication Date: 2024-12-27SHANDONG LANGCHAO YUNTOU INFORMATION TECH CO LTD
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202411224936.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-03
Publication Date
2024-12-27

AI Technical Summary

Technical Problem

Traditional monitoring methods for cloud servers focus on CPU and memory usage at the machine level, making it difficult to locate abnormal processes, and process monitoring in virtual machines consumes virtual machine resources.

Method used

A process monitoring method and system based on the qemu-guest-agent plug-in, utilizing lock files to control function switches, which includes monitoring and collection modules for Linux and Windows systems, and uses /proc virtual file system and PDH library to gather process data without logging into the server.

Benefits of technology

Enables precise resource monitoring of high CPU occupancy processes in cloud servers, reducing resource consumption and allowing data reporting to external systems for persistence, visualization, and alarm systems, with a switch function to conserve resources.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119201604A_ABST
    Figure CN119201604A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of data processing, in particular to a process monitoring method and system based on a qemu-guest-agent plugin, and the method comprises the following steps: monitoring collection, function switch setting and function state query, the monitoring collection part is divided into linux system monitoring collection and Windows system monitoring collection; function switch setting and function state query are realized based on a lock file, and whether a function is started or not is judged by setting and deleting the lock file and controlling a switch of the function and detecting whether the lock file exists or not; the process monitoring method and system based on the qemu-guest-agent plug-in have the advantages that on the premise that a user does not log in a cloud server, the process occupied by a high CPU in the cloud server is obtained, and finer resource monitoring is achieved; the process monitoring data in the cloud server is reported to an interface outside the virtual machine, and the interface can be in butt joint with external services such as a monitoring data persistence system, a monitoring data visualization system and a monitoring alarm system outside the cloud server.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of data processing, and in particular to a process monitoring method and system based on a qemu-guest-agent plug-in. Background Art

[0002] When running a cloud server, programmers or operation and maintenance personnel will pay attention to the server's CPU and memory usage to determine whether the server is running normally. However, in the case of abnormal operation, the problem must ultimately be located in the process. Traditional monitoring based on the entire machine's CPU and memory is not conducive to locating the problem process. Therefore, process monitoring is needed to supplement it.

[0003] The effect of process monitoring is similar to the top command (Unix system) and task manager (Windows system) in the virtual machine. The difference is that the monitoring acquisition in the cloud server is real-time, historical data is not saved by default, and if the monitoring data is saved in the virtual machine, it will occupy the virtual machine resources. Summary of the invention

[0004] The object of the present invention is to provide a process monitoring method and system based on qemu-guest-agent plug-in to solve the problems raised in the above background technology.

[0005] To achieve the above object, the present invention provides the following technical solution: a process monitoring method based on qemu-guest-agent plug-in, the method comprising the following steps:

[0006] Monitoring and collection, function switch setting and function status query. The monitoring and collection part is divided into Linux system monitoring and collection and Windows system monitoring and collection. Function switch setting and function status query are based on a lock file. By setting and deleting the lock file, the function switch is controlled. By detecting whether the lock file exists, it is determined whether the function is enabled.

[0007] Preferably, the specific operations of Linux system monitoring and collection include:

[0008] Traverse the / proc path and obtain all folders whose names are only numbers. Such folders are virtual file paths mapped to processes. Each folder represents a process. Recording the names of all such folders is the process ID list in the cloud server.

[0009] For each process, do the following: Get / proc / <pid>The contents of the / stat file, record the 1st to 3rd and 22nd fields, which respectively represent: process id, process name, process status code, jeffis time of process startup since system startup, obtain and calculate the sum of the 14th to 17th fields as the process CPU time, and the four fields represent: process kernel state time, process user state time, process child kernel state time, process child user state time; read / proc / stat at the same time, the file is the overall CPU information of the system, read the first line of the file, and sum the values ​​in it to get the CPU running time in jeffis, and store this value and the process CPU time just obtained in the same structure;

[0010] After all processes have completed statistics, sleep for 1 second;

[0011] Traverse the process list again, repeat the previous step for each process, obtain the CPU time occupied by the process and the system CPU running time again, and calculate the CPU utilization of each process using the following formula:

[0012]

[0013] Sort all process information by CPU utilization;

[0014] Get the process information of the top N processes. If all processes are monitored, the resource consumption will be too large. Therefore, only the processes that occupy the top N resources are selected for monitoring.

[0015] Preferably, the process information of the first N processes is supplemented:

[0016] By reading / proc / <pid> / status obtains the process memory usage, UID, and number of threads;

[0017] Get the total system memory through / proc / meminfo, and calculate the process memory usage rate with the memory occupied by the process;

[0018] Get the user name of the user to which the process belongs through UID;

[0019] The theoretical maximum CPU usage of the process is calculated by the number of threads, which corrects the situation where the sampling result is greater than the theoretical upper limit due to sampling error in occasional cases.

[0020] Accessing / proc / <pid> / fd directory, obtain the total number of files in it, and record it as the number of files opened by the process.

[0021] Preferably, the specific operations of Windows system monitoring and collection include:

[0022] Through the pdh library, first obtain and refresh the pdh object, then obtain all process names, and synchronize all process names to the process information structure list. When initialized, other values ​​in the structure are set to 0. The process information structure includes: process name, process index number, and process CPU utilization;

[0023] Sort all processes in alphabetical order by process name, traverse all process names, if a process name is the same as the previous one, set the process index number to the process index number of the previous process + 1, and construct the process CPU utilization monitor with the process name and index number through the pdh library. If the index number is 0, no index number is added, and if the index number is not zero, it is recorded in the form of "process name#index number". When constructing the monitor, the process names "_Total", "Idle" and empty process names need to be excluded;

[0024] Call the pdh monitor collection twice with an interval of 1 second;

[0025] Read and store the CPU utilization of each process, sort all process information according to CPU utilization, and obtain the process information of the top N processes.

[0026] Preferably, for the N processes taken out, monitors of other indicators are constructed:

[0027] The process memory usage, process ID, number of process open handles, and process running time are collected by calling the pdh monitor;

[0028] The process memory usage is calculated by dividing the process memory usage by the total system memory;

[0029] By using the number of open handles of a process instead of the number of open files of a process;

[0030] Use the current time to subtract the process running time to get the process start time;

[0031] Open the process handle with the "limited data query" permission according to the process ID, obtain the process token through the process handle, obtain the user Sid of the process through the process token, and finally obtain the user name through the user Sid.

[0032] A process monitoring system based on a qemu-guest-agent plug-in, the system consists of a monitoring and acquisition module, a function switch setting module and a function status query module, the monitoring and acquisition module is divided into a Linux system monitoring and acquisition module and a Windows system monitoring and acquisition module; the function switch setting module and the function status query module are implemented based on a lock file, the function switch is controlled by setting and deleting the lock file, and whether the function is turned on is judged by detecting whether the lock file exists.

[0033] Preferably, the Linux system monitoring and acquisition module traverses the / proc path to obtain all folders whose names are only numbers. Such folders are virtual file paths mapped to processes. Each folder represents a process. Recording the names of all such folders is a list of process IDs in the cloud server.

[0034] For each process, do the following: Get / proc / <pid>The contents of the / stat file, record the 1st to 3rd and 22nd fields, which respectively represent: process id, process name, process status code, jeffis time of process startup since system startup, obtain and calculate the sum of the 14th to 17th fields as the process CPU time, and the four fields represent: process kernel state time, process user state time, process child kernel state time, process child user state time; read / proc / stat at the same time, the file is the overall CPU information of the system, read the first line of the file, and sum the values ​​in it to get the CPU running time in jeffis, and store this value and the process CPU time just obtained in the same structure;

[0035] After all processes have completed statistics, sleep for 1 second;

[0036] Traverse the process list again, repeat the previous step for each process, obtain the CPU time occupied by the process and the system CPU running time again, and calculate the CPU utilization of each process using the following formula:

[0037]

[0038] Sort all process information by CPU utilization;

[0039] Get the process information of the top N processes. If all processes are monitored, the resource consumption will be too large. Therefore, only the processes that occupy the top N resources are selected for monitoring.

[0040] Preferably, the Linux system monitoring and acquisition module reads / proc / <pid> / status obtains the process memory usage, UID, and number of threads;

[0041] Get the total system memory through / proc / meminfo, and calculate the process memory usage rate with the memory occupied by the process;

[0042] Get the user name of the user to which the process belongs through UID;

[0043] The theoretical maximum CPU usage of the process is calculated by the number of threads, which corrects the situation where the sampling result is greater than the theoretical upper limit due to sampling error in occasional cases.

[0044] Accessing / proc / <pid> / fd directory, obtain the total number of files in it, and record it as the number of files opened by the process.

[0045] Preferably, the Windows system monitoring and acquisition module first obtains and refreshes the pdh object through the pdh library, then obtains all process names, synchronizes all process names to the process information structure list, and sets other values ​​in the structure to 0 during initialization. The process information structure includes: process name, process index number, and process CPU utilization;

[0046] Sort all processes in alphabetical order by process name, traverse all process names, if a process name is the same as the previous one, set the process index number to the process index number of the previous process + 1, and construct the process CPU utilization monitor with the process name and index number through the pdh library. If the index number is 0, no index number is added, and if the index number is not zero, it is recorded in the form of "process name#index number". When constructing the monitor, the process names "_Total", "Idle" and empty process names need to be excluded;

[0047] Call the pdh monitor collection twice with an interval of 1 second;

[0048] Read and store the CPU utilization of each process, sort all process information according to CPU utilization, and obtain the process information of the top N processes.

[0049] Preferably, the Windows system monitoring and collection module calls the pdh monitor to collect the process memory usage, process ID, number of process open handles, and process running time;

[0050] The process memory usage is calculated by dividing the process memory usage by the total system memory;

[0051] By using the number of open handles of a process instead of the number of open files of a process;

[0052] Use the current time to subtract the process running time to get the process start time;

[0053] Open the process handle with the "limited data query" permission according to the process ID, obtain the process token through the process handle, obtain the user Sid of the process through the process token, and finally obtain the user name through the user Sid.

[0054] Compared with the prior art, the present invention has the following beneficial effects:

[0055] The process monitoring method and system based on the qemu-guest-agent plug-in proposed in the present invention can obtain the processes with high CPU occupancy in the cloud server without logging into the cloud server, so as to realize more precise resource monitoring; the process monitoring data in the cloud server is reported to the interface outside the virtual machine, and outside the cloud server, the interface can be connected to external services such as the monitoring data persistence system, the monitoring data visualization system, and the monitoring alarm system, thereby increasing the expansibility of resource monitoring; a process monitoring switch function is provided, and this function can be turned off in non-essential cloud servers to save resource consumption of monitoring data persistence and reduce unnecessary dirty data pollution reports. BRIEF DESCRIPTION OF THE DRAWINGS

[0056] Figure 1 This is the Linux system monitoring and collection flow chart of the present invention;

[0057] Figure 2 This is a flow chart of monitoring and collecting data for Windows system according to the present invention. DETAILED DESCRIPTION

[0058] In order to make the purpose and technical solution of the present invention clearly and completely described, and the advantages more clearly understood, the embodiments of the present invention are further described in detail with reference to the accompanying drawings. It should be understood that the specific embodiments described herein are part of the embodiments of the present invention, rather than all of the embodiments, and are only used to explain the embodiments of the present invention, and are not used to limit the embodiments of the present invention. All other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0059] Embodiment 1

[0060] See also Figure 1 to Figure 2 The present invention provides a technical solution: a process monitoring method based on a qemu-guest-agent plug-in, the method comprising the following steps:

[0061] The secondary development function based on the open source software qemu-guest-agent is divided into three parts: monitoring and collection, function switch setting, and function status query. The monitoring and collection part is divided into two versions: Unix-like and Windows.

[0062] Function switch setting and function status query are based on a lock file. By setting and deleting the lock file, the function switch is controlled. Whether the function is enabled is determined by detecting whether the lock file exists.

[0063] In the monitoring and collection part, for Unix-like systems, since the kernel exposes the / proc virtual file system, which maps the information of each process, the data of each process can be obtained by accessing the corresponding file; for Windows systems, Windows officially provides the PDH (Performance Data Helper) library, and the monitoring indicators can be obtained by calling the relevant functions of the library to construct the monitor of the relevant indicators.

[0064] 2. Function switch

[0065] The program determines whether the function is enabled or disabled by setting a lock file. For Linux systems, the lock file is set at / usr / local / qemu-ga / process-monitor, and for Windows systems, it is set at C:\ProgramFiles\Qemu-ga\process-monitor.lock.

[0066] If the file exists, the function is enabled; if the file does not exist, the function is disabled.

[0067] Setting the function on will create the file in the corresponding path, and setting the function off will delete the file.

[0068] 3. Linux system monitoring and collection

[0069] Traverse the / proc path and get all the folders whose names are only numbers. Such folders are virtual file paths mapped to processes, and each folder represents a process. Recording the names of all such folders is the process ID list in the cloud server.

[0070] For each process, do the following: Get / proc / <pid> / stat file, record the 1st to 3rd and 22nd fields (the three fields represent: process id, process name, process status code, jeffis time of process startup since system startup), obtain and calculate the sum of the 14th to 17th fields and record them as the process CPU time (the four fields represent: process kernel state time, process user state time, process subprocess kernel state time, process subprocess user state time). At the same time, read / proc / stat, which is the overall CPU information of the system. Read the first line of the file and sum the values ​​in it to get the CPU running time (in jeffis). Add this value to the process CPU time just obtained. Store in the same structure.

[0071] After all processes have completed statistics, sleep for 1 second.

[0072] Traverse the process list again, repeat the previous step for each process, obtain the CPU time occupied by the process and the system CPU running time again, and calculate the CPU utilization of each process using the following formula:

[0073]

[0074] Sort all process information by CPU utilization.

[0075] Get the process information of the top N processes. If all processes are monitored, the resource consumption will be too large. Therefore, only the processes that occupy the top N resources are selected for monitoring. N can be adjusted according to the monitoring coverage requirements.

[0076] Supplement the process information of the first N processes:

[0077] 1) By reading / proc / <pid> / status gets the process memory usage, UID, and number of threads.

[0078] 2) Obtain the total system memory through / proc / meminfo, and calculate the process memory usage rate with the process memory usage;

[0079] 3) Get the user name of the user to which the process belongs through UID;

[0080] 4) Calculate the maximum theoretical CPU usage of the process by the number of threads, and correct the occasional situation where the sampling result is greater than the theoretical upper limit due to sampling error.

[0081] 5) Access / proc / <pid> / fd directory, obtain the total number of files in it, and record it as the number of files opened by the process.

[0082] Summarize all the above process information and return it.

[0083] 4. Windows system monitoring and collection

[0084] Through the pdh library, first obtain and refresh the pdh object. Then obtain all process names. Synchronize all process names to the process information structure list. When initializing, all other values ​​in the structure are set to 0. The process information structure includes: process name, process index number, and process CPU utilization.

[0085] Sort all processes in alphabetical order of process name. Traverse all process names. If the name of a process is the same as the previous one, set the process index to the process index of the previous process + 1. Use the pdh library to construct a process CPU utilization monitor with the process name and index number. If the index number is 0, no index number is added. If the index number is not zero, it is recorded as "process name#index number". When constructing the monitor, exclude the process names: "_Total", "Idle" and empty process names.

[0086] Call the PDH monitor twice with an interval of 1 second.

[0087] Read and store the CPU utilization of each process, sort all process information according to CPU utilization, and obtain the process information of the top N processes.

[0088] For the N processes taken out, construct monitors for other indicators: process memory usage, process ID, number of process open handles, and process running time. Call the pdh monitor to collect data.

[0089] 1) Calculate the process memory usage by dividing the process memory usage by the total system memory;

[0090] 2) By using the number of process open handles instead of the number of process open files.

[0091] 3) Use the current time to subtract the process running time to get the process start time

[0092] 4) Open the process handle with the "limited data query" permission according to the process ID, obtain the process token through the process handle, obtain the user Sid to which the process belongs through the process token, and finally obtain the user name through the user Sid.

[0093] Summarize all the above process information and return it.

[0094] Embodiment 2

[0095] On the basis of Example 1, a process monitoring system based on a qemu-guest-agent plug-in is proposed. The system consists of a monitoring and acquisition module, a function switch setting module and a function status query module. The monitoring and acquisition module is divided into a Linux system monitoring and acquisition module and a Windows system monitoring and acquisition module; the function switch setting module and the function status query module are implemented based on a lock file, and the function switch is controlled by setting and deleting the lock file, and whether the function is turned on is determined by detecting whether the lock file exists.

[0096] The Linux system monitoring and collection module traverses the / proc path and obtains all folders whose names are only numbers. Such folders are virtual file paths mapped to processes. Each folder represents a process. The names of all such folders are the process ID list in the cloud server.

[0097] For each process, do the following: Get / proc / <pid>The contents of the / stat file, record the 1st to 3rd and 22nd fields, which respectively represent: process id, process name, process status code, jeffis time of process startup since system startup, obtain and calculate the sum of the 14th to 17th fields as the process CPU time, and the four fields represent: process kernel state time, process user state time, process child kernel state time, process child user state time; read / proc / stat at the same time, the file is the overall CPU information of the system, read the first line of the file, and sum the values ​​in it to get the CPU running time in jeffis, and store this value and the process CPU time just obtained in the same structure;

[0098] After all processes have completed statistics, sleep for 1 second;

[0099] Traverse the process list again, repeat the previous step for each process, obtain the CPU time occupied by the process and the system CPU running time again, and calculate the CPU utilization of each process using the following formula:

[0100]

[0101] Sort all process information by CPU utilization;

[0102] Get the process information of the top N processes. If all processes are monitored, the resource consumption will be too large. Therefore, only the processes that occupy the top N resources are selected for monitoring.

[0103] By reading / proc / <pid> / status obtains the process memory usage, UID, and number of threads;

[0104] Get the total system memory through / proc / meminfo, and calculate the process memory usage rate with the memory occupied by the process;

[0105] Get the user name of the user to which the process belongs through UID;

[0106] The theoretical maximum CPU usage of the process is calculated by the number of threads, which corrects the situation where the sampling result is greater than the theoretical upper limit due to sampling error in occasional cases.

[0107] Accessing / proc / <pid> / fd directory, obtain the total number of files in it, and record it as the number of files opened by the process.

[0108] The Windows system monitoring and acquisition module first obtains and refreshes the pdh object through the pdh library, then obtains all process names, and synchronizes all process names to the process information structure list. When initialized, other values ​​in the structure are set to 0. The process information structure includes: process name, process index number, and process CPU utilization;

[0109] Sort all processes in alphabetical order by process name, traverse all process names, if a process name is the same as the previous one, set the process index number to the process index number of the previous process + 1, and construct the process CPU utilization monitor with the process name and index number through the pdh library. If the index number is 0, no index number is added, and if the index number is not zero, it is recorded in the form of "process name#index number". When constructing the monitor, the process names "_Total", "Idle" and empty process names need to be excluded;

[0110] Call the pdh monitor collection twice with an interval of 1 second;

[0111] Read and store the CPU utilization of each process, sort all process information according to CPU utilization, and obtain the process information of the top N processes.

[0112] Windows system monitoring and collection module, process memory usage, process ID, number of process open handles, process running time, call pdh monitor to collect;

[0113] The process memory usage is calculated by dividing the process memory usage by the total system memory;

[0114] By using the number of open handles of a process instead of the number of open files of a process;

[0115] Use the current time to subtract the process running time to get the process start time;

[0116] Open the process handle with the "limited data query" permission according to the process ID, obtain the process token through the process handle, obtain the user Sid of the process through the process token, and finally obtain the user name through the user Sid.

[0117] Although embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions and variations may be made to the embodiments without departing from the principles and spirit of the present invention, and that the scope of the present invention is defined by the appended claims and their equivalents.< / pid> < / pid> < / pid> < / pid> < / pid> < / pid> < / pid> < / pid> < / pid> < / pid> < / pid> < / pid>

Claims

1. A process monitoring method based on qemu-guest-agent plug-in, characterized in that: The method comprises the following steps: Monitoring and collection, function switch setting and function status query. The monitoring and collection part is divided into Linux system monitoring and collection and Windows system monitoring and collection. Function switch setting and function status query are based on a lock file. By setting and deleting the lock file, the function switch is controlled. By detecting whether the lock file exists, it is determined whether the function is enabled.

2. A process monitoring method based on qemu-guest-agent plug-in according to claim 1, characterized in that: The specific operations of Linux system monitoring and collection include: Traverse the / proc path and obtain all folders whose names are only numbers. Such folders are virtual file paths mapped to processes. Each folder represents a process. Recording the names of all such folders is the process ID list in the cloud server. For each process, do the following: Get / proc / <pid> The contents of the / stat file, record the 1st to 3rd and 22nd fields, which respectively represent: process id, process name, process status code, jeffis time of process startup since system startup, obtain and calculate the sum of the 14th to 17th fields as the process CPU time, and the four fields represent: process kernel state time, process user state time, process child kernel state time, process child user state time; read / proc / stat at the same time, the file is the overall CPU information of the system, read the first line of the file, and sum the values ​​in it to get the CPU running time in jeffis, and store this value and the process CPU time just obtained in the same structure;< / pid> After all processes have completed statistics, sleep for 1 second; Traverse the process list again, repeat the previous step for each process, obtain the CPU time occupied by the process and the system CPU running time again, and calculate the CPU utilization of each process using the following formula: Sort all process information by CPU utilization; Get the process information of the top N processes. If all processes are monitored, the resource consumption will be too large. Therefore, only the processes that occupy the top N resources are selected for monitoring.

3. A process monitoring method based on qemu-guest-agent plug-in according to claim 2, characterized in that: Supplement the process information of the first N processes: By reading / proc / <pid> / status obtains the process memory usage, UID, and number of threads;< / pid> Get the total system memory through / proc / meminfo, and calculate the process memory usage rate with the memory occupied by the process; Get the user name of the user to which the process belongs through UID; The theoretical maximum CPU usage of the process is calculated by the number of threads, which corrects the situation where the sampling result is greater than the theoretical upper limit due to sampling error in occasional cases. Accessing / proc / <pid> / fd directory, obtain the total number of files in it, and record it as the number of files opened by the process.< / pid> 4. The process monitoring method based on qemu-guest-agent plug-in according to claim 1, characterized in that: The specific operations of Windows system monitoring and collection include: Through the pdh library, first obtain and refresh the pdh object, then obtain all process names, and synchronize all process names to the process information structure list. When initialized, other values ​​in the structure are set to 0. The process information structure includes: process name, process index number, and process CPU utilization; Sort all processes in alphabetical order by process name, traverse all process names, if a process name is the same as the previous one, set the process index number to the process index number of the previous process + 1, and construct the process CPU utilization monitor with the process name and index number through the pdh library. If the index number is 0, no index number is added, and if the index number is not zero, it is recorded in the form of "process name#index number". When constructing the monitor, the process names "_Total", "Idle" and empty process names need to be excluded; Call the pdh monitor collection twice with an interval of 1 second; Read and store the CPU utilization of each process, sort all process information according to CPU utilization, and obtain the process information of the top N processes.

5. A process monitoring method based on qemu-guest-agent plug-in according to claim 4, characterized in that: For the N processes taken out, construct monitors of other indicators: The process memory usage, process ID, number of process open handles, and process running time are collected by calling the pdh monitor; Calculate the process memory usage by dividing the process memory usage by the total system memory; By using the number of open handles of a process instead of the number of open files of a process; Use the current time to subtract the process running time to get the process start time; Open the process handle with the "limited data query" permission according to the process ID, obtain the process token through the process handle, obtain the user Sid of the process through the process token, and finally obtain the user name through the user Sid.

6. A qemu-guest-agent plug-in-based process monitoring system according to the qemu-guest-agent plug-in-based process monitoring method according to any one of claims 1 to 5, characterized in that: The system consists of a monitoring and acquisition module, a function switch setting module and a function status query module. The monitoring and acquisition module is divided into a Linux system monitoring and acquisition module and a Windows system monitoring and acquisition module. The function switch setting module and the function status query module are implemented based on a lock file. By setting and deleting the lock file, the function switch is controlled, and whether the function is turned on is determined by detecting whether the lock file exists.

7. A process monitoring system based on qemu-guest-agent plug-in according to claim 6, characterized in that: The Linux system monitoring and acquisition module traverses the / proc path and obtains all folders whose names are only numbers. Such folders are virtual file paths mapped by processes. Each folder represents a process. The names of all such folders are recorded as a list of process IDs in the cloud server. For each process, do the following: Get / proc / <pid> The contents of the / stat file, record the 1st to 3rd and 22nd fields, which respectively represent: process id, process name, process status code, jeffis time of process startup since system startup, obtain and calculate the sum of the 14th to 17th fields as the process CPU time, and the four fields represent: process kernel state time, process user state time, process child kernel state time, process child user state time; read / proc / stat at the same time, the file is the overall CPU information of the system, read the first line of the file, and sum the values ​​in it to get the CPU running time in jeffis, and store this value and the process CPU time just obtained in the same structure;< / pid> After all processes have completed statistics, sleep for 1 second; Traverse the process list again, repeat the previous step for each process, obtain the CPU time occupied by the process and the system CPU running time again, and calculate the CPU utilization of each process using the following formula: Sort all process information by CPU utilization; Get the process information of the top N processes. If all processes are monitored, the resource consumption will be too large. Therefore, only the processes that occupy the top N resources are selected for monitoring.

8. A process monitoring system based on qemu-guest-agent plug-in according to claim 6, characterized in that: The Linux system monitoring and acquisition module reads / proc / <pid> / status obtains the process memory usage, UID, and number of threads;< / pid> Get the total system memory through / proc / meminfo, and calculate the process memory usage rate with the memory occupied by the process; Get the user name of the user to which the process belongs through UID; The theoretical maximum CPU usage of the process is calculated by the number of threads, which corrects the situation where the sampling result is greater than the theoretical upper limit due to sampling error in occasional cases. Accessing / proc / <pid> / fd directory, obtain the total number of files in it, and record it as the number of files opened by the process.< / pid> 9. A process monitoring system based on qemu-guest-agent plug-in according to claim 6, characterized in that: The Windows system monitoring and acquisition module first obtains and refreshes the pdh object through the pdh library, then obtains all process names, and synchronizes all process names to the process information structure list. When initialized, other values ​​in the structure are set to 0. The process information structure includes: process name, process index number, and process CPU utilization; Sort all processes in alphabetical order by process name, traverse all process names, if a process name is the same as the previous one, set the process index number to the process index number of the previous process + 1, and construct the process CPU utilization monitor with the process name and index number through the pdh library. If the index number is 0, no index number is added, and if the index number is not zero, it is recorded in the form of "process name#index number". When constructing the monitor, the process names "_Total", "Idle" and empty process names need to be excluded; Call the pdh monitor collection twice with an interval of 1 second; Read and store the CPU utilization of each process, sort all process information according to CPU utilization, and obtain the process information of the top N processes.

10. The process monitoring system based on qemu-guest-agent plug-in according to claim 6, characterized in that: The Windows system monitoring and collection module calls the pdh monitor to collect process memory usage, process ID, number of process open handles, and process running time; Calculate the process memory usage by dividing the process memory usage by the total system memory; By using the number of open handles of a process instead of the number of open files of a process; Use the current time to subtract the process running time to get the process start time; Open the process handle with the "limited data query" permission according to the process ID, obtain the process token through the process handle, obtain the user Sid of the process through the process token, and finally obtain the user name through the user Sid.

Citation Information

Cited By

  • Full-system-state process identification method based on linkage of simulator and debugger

    CN120408620A

  • Dynamic memory use monitoring method based on service and process

    CN121050975A