CN117555732A - CPU utilization monitoring method, device, equipment and storage medium - Google Patents

CPU utilization monitoring method, device, equipment and storage medium Download PDF

Info

Publication number
CN117555732A
CN117555732A CN202311580702.7A CN202311580702A CN117555732A CN 117555732 A CN117555732 A CN 117555732A CN 202311580702 A CN202311580702 A CN 202311580702A CN 117555732 A CN117555732 A CN 117555732A
Authority
CN
China
Prior art keywords
cpu
cpu utilization
log data
system environment
preset
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202311580702.7A
Other languages
Chinese (zh)
Inventor
陶菁
何平
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Ecarx Hubei Tech Co Ltd
Original Assignee
Ecarx Hubei Tech Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Ecarx Hubei Tech Co Ltd filed Critical Ecarx Hubei Tech Co Ltd
Priority to CN202311580702.7A priority Critical patent/CN117555732A/en
Publication of CN117555732A publication Critical patent/CN117555732A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/14Error detection or correction of the data by redundancy in operation
    • G06F11/1402Saving, restoring, recovering or retrying
    • G06F11/1415Saving, restoring, recovering or retrying at system level
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/3058Monitoring arrangements for monitoring environmental properties or parameters of the computing system or of the computing system component, e.g. monitoring of power, currents, temperature, humidity, position, vibrations
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/48Program initiating; Program switching, e.g. by interrupt
    • G06F9/4806Task transfer initiation or dispatching
    • G06F9/4843Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system
    • G06F9/4881Scheduling strategies for dispatcher, e.g. round robin, multi-level priority queues
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Quality & Reliability (AREA)
  • Software Systems (AREA)
  • Computing Systems (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The application provides a CPU utilization monitoring method, device, equipment and storage medium. The method comprises the following steps: obtaining the CPU utilization rate of a target Linux system; in response to determining that the CPU utilization is greater than a preset threshold, monitoring at least one process running within a preset time window in a kernel mode of the target Linux system to obtain system environment log data, wherein the system environment log data comprises: at least one process corresponding to the operation related data and a process call chain; the operation-related data includes: the process consumes CPU time, kernel mode stack corresponding to the process and user mode stack, function execution time in the process; and displaying the system environment log data according to a preset form. The running condition of the process and the calling condition of the process can be monitored in more detail, so that more detailed system environment log data can be obtained, the reason of abnormal CPU utilization rate can be rapidly and accurately positioned, and the system environment can be rapidly and effectively recovered in a targeted manner.

Description

CPU utilization monitoring method, device, equipment and storage medium
Technical Field
The present disclosure relates to computer technologies, and in particular, to a method, an apparatus, a device, and a storage medium for monitoring CPU utilization.
Background
At present, a Linux embedded system plays a key role in a modern automobile, and a CPU is used as a core component of the vehicular Linux embedded system, so that the utilization rate of the vehicular Linux embedded system is critical to system performance and resource management.
At present, when the CPU utilization rate is monitored, if the CPU utilization rate is monitored to be abnormal, the reason of the abnormality can only be determined based on the log collected by the user mode.
However, the log collected by the user mode can only reflect the single point problem of abnormal CPU utilization rate, and the reason of the abnormal CPU utilization rate cannot be rapidly and accurately determined by utilizing the single point problem, so that the system environment cannot be rapidly and effectively recovered.
Disclosure of Invention
The application provides a CPU utilization monitoring method, device, equipment and storage medium, which are used for solving the technical problems that logs collected by user states only can reflect single-point problems of abnormal CPU utilization, the reasons of the abnormal CPU utilization cannot be rapidly and accurately determined by the single-point problems, and further the system environment cannot be rapidly and effectively recovered.
In a first aspect, the present application provides a method for monitoring CPU utilization, including:
obtaining the CPU utilization rate of a target Linux system;
in response to determining that the CPU utilization is greater than a preset threshold, monitoring at least one process running within a preset time window in a kernel mode of a target Linux system to obtain system environment log data, wherein the system environment log data comprises: at least one process corresponding to the operation related data and a process call chain; the operation-related data includes: the process consumes CPU time, a kernel mode stack corresponding to the process, a user mode stack and function execution time in the process, and the process call chain is used for representing call relations among the processes; and displaying the system environment log data according to a preset form.
In a second aspect, the present application provides a CPU utilization monitoring apparatus, including:
the acquisition module is used for acquiring the CPU utilization rate of the target Linux system;
the monitoring module is used for monitoring at least one process running in a preset time window in a kernel mode of the target Linux system in response to determining that the CPU utilization rate is greater than a preset threshold value so as to obtain system environment log data, wherein the system environment log data comprises: at least one process corresponding to the operation related data and a process call chain; the operation-related data includes: the process consumes CPU time, kernel mode stack corresponding to the process and user mode stack, function execution time in the process;
and the display module is used for displaying the system environment log data according to a preset form.
In a third aspect, the present application provides an electronic device, comprising: a processor, and a memory and an output device communicatively connected to the processor;
the memory stores computer-executable instructions; the output device is used for displaying data;
the processor executes computer-executable instructions stored in the memory to implement the method as described in the first aspect.
In a fourth aspect, the present application provides a computer-readable storage medium having stored therein computer-executable instructions for performing the method according to the first aspect when executed by a processor.
The CPU utilization monitoring method, the device, the equipment and the storage medium provided by the application are used for acquiring the CPU utilization of the target Linux system; in response to determining that the CPU utilization is greater than a preset threshold, monitoring at least one process running within a preset time window in a kernel mode of a target Linux system to obtain system environment log data, wherein the system environment log data comprises: at least one process corresponding to the operation related data and a process call chain; the operation-related data includes: the process consumes CPU time, a kernel mode stack corresponding to the process, a user mode stack and function execution time in the process, and the process call chain is used for representing call relations among the processes; and displaying the system environment log data according to a preset form. When the CPU utilization rate is determined to be large and the preset threshold value is determined, at least one process running in the preset time window is monitored in the kernel mode, so that the running condition and the process calling condition of the process can be monitored in more detail, more detailed system environment log data can be obtained, the system environment log data is displayed in the preset mode, the running and calling conditions of the process when the CPU is abnormal can be observed more intuitively by a user, the reason of the abnormality of the CPU utilization rate can be positioned rapidly and accurately, and the system environment can be recovered rapidly and effectively in a targeted mode.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the application and together with the description, serve to explain the principles of the application.
FIG. 1 is a network architecture diagram of a CPU utilization monitoring method provided in one embodiment of the present application;
FIG. 2 is a flow chart of a method for monitoring CPU utilization according to an embodiment of the present application;
FIG. 3 is a flowchart illustrating a method for monitoring CPU utilization according to another embodiment of the present disclosure;
FIG. 4 is a schematic diagram of a CPU utilization monitoring device according to an embodiment of the present disclosure;
fig. 5 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
Specific embodiments thereof have been shown by way of example in the drawings and will herein be described in more detail. These drawings and the written description are not intended to limit the scope of the inventive concepts in any way, but to illustrate the concepts of the present application to those skilled in the art by reference to specific embodiments.
Detailed Description
Reference will now be made in detail to exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, the same numbers in different drawings refer to the same or similar elements, unless otherwise indicated. The implementations described in the following exemplary examples are not representative of all implementations consistent with the present application. Rather, they are merely examples of apparatus and methods consistent with some aspects of the present application as detailed in the accompanying claims.
For a clear understanding of the technical solutions of the present application, the prior art solutions will be described in detail first.
At present, when the CPU utilization rate is monitored, if the CPU utilization rate is monitored to be abnormal, if the CPU utilization rate is larger than a preset threshold value, the reason of the CPU abnormality needs to be determined. At present, when determining the cause of the CPU abnormality, the cause is generally determined through a log collected by a user mode. The log collected in the user mode can only reflect the single point problem of CPU abnormality, such as that a certain process occupies a large CPU resource. For the single point problem, the reason for the abnormal CPU utilization rate cannot be accurately positioned. If only a certain process occupies a large CPU resource, but the process link or what cause is not known, the system environment cannot be quickly read and effectively restored.
Therefore, when the technical problem in the prior art is faced, in order to accurately determine the reason of the abnormal CPU utilization rate, the system environment log data needs to be acquired as detailed as possible when the CPU utilization rate is abnormal, the system environment log data can reflect the running condition and the process calling condition of the process running on the CPU, and the detailed system environment log data needs to monitor at least one running process from the kernel state of the Linux system, so that when the CPU utilization rate is determined to be greater than the preset threshold value, the CPU utilization rate abnormality is determined to occur in the scheme, and then the at least one running process in the preset time window is monitored in the kernel state of the target Linux system to acquire the system environment log data. In order to enable a user to rapidly and accurately determine the reason of the abnormal CPU utilization rate, the system environment log data can be displayed in a preset mode, so that the user can more intuitively observe the process operation and calling conditions when the CPU is abnormal, further, the reason of the abnormal CPU utilization rate can be rapidly and accurately located, and further, the system environment can be rapidly and effectively recovered in a targeted mode.
Fig. 1 is a network architecture diagram of a method for monitoring CPU utilization in an embodiment of the present application, and as shown in fig. 1, a network architecture corresponding to the method for monitoring CPU utilization in the embodiment may include a CPU utilization monitoring device 11 and an electronic device 12 loaded with a target Linux system. The CPU utilization monitoring device 11 may be integrated into the electronic device 12 loaded with the target Linux system, to monitor the CPU utilization of the electronic device 12 loaded with the target Linux system. The electronic device 12 loaded with the target Linux system may be an in-vehicle device. The user may configure the CPU utilization rate collection frequency and the preset threshold through the CPU utilization rate monitoring device 11, and then the CPU utilization rate monitoring device 11 may collect the CPU utilization rate of the target Linux system according to the CPU utilization rate collection frequency to obtain the CPU utilization rate. CPU utilization may be denoted as R. Judging whether the CPU utilization rate is abnormal or not according to a preset threshold L, if R > L, monitoring at least one process running in a preset time window in the kernel mode of the target Linux system to acquire system environment log data. And displaying the system environment log data according to a preset form.
Fig. 2 is a flow chart of a method for monitoring CPU utilization in an embodiment of the present application, as shown in fig. 2, an execution body of the embodiment is a CPU utilization monitoring device, where the CPU utilization monitoring device is located in a CPU utilization monitoring device, and the CPU utilization monitoring device may be an electronic device. The method for monitoring the CPU utilization rate provided in this embodiment includes the following steps:
step 201, obtaining the CPU utilization rate of the target Linux system.
The target Linux system is a Linux system needing to monitor the CPU utilization rate. The target Linux system can be a Linux embedded system, and has fewer CPU resources, so that the CPU resources are required to be reasonably distributed and used. For example, the system may be a vehicular Linux embedded system or a Linux embedded system of other application scenarios, which is not limited in this embodiment.
Specifically, in this embodiment, when the CPU utilization of the target Linux system is obtained, the CPU utilization of the target Linux system may be collected according to a preset collection frequency, so as to obtain the CPU utilization of the target Linux system. When the CPU utilization of the target Linux system is collected, the CPU utilization may be collected by a user-state collection tool, or a Proc file system of the Linux system is adopted to collect CPU indexes of the target Linux system, so that the CPU utilization is calculated based on the collected CPU indexes, which is not limited in this embodiment.
Step 202, in response to determining that the CPU utilization is greater than a preset threshold, monitoring, in a kernel mode of the target Linux system, at least one process running within a preset time window to obtain system environment log data, where the system environment log data includes: at least one process corresponding to the operation related data and a process call chain; the operation-related data includes: the process consumes CPU time, kernel mode stack corresponding to the process, user mode stack and function executing time in the process.
Wherein the process call chain indicates call relationships between processes.
In this embodiment, after the CPU utilization rate is obtained each time, it is determined whether the CPU utilization rate is greater than a preset threshold, and if it is determined that the CPU utilization rate is greater than the preset threshold, it is indicated that the CPU utilization rate is too high, and the CPU utilization rate is abnormal. And if the CPU utilization rate is determined to be equal to the preset threshold value, the CPU utilization rate is indicated to be normal. If the CPU utilization rate is determined to be smaller than the preset threshold value, the CPU utilization rate is lower, and the CPU utilization rate can be increased.
And when the CPU utilization rate is determined to be larger than the preset threshold value, determining the reason for the abnormality of the CPU utilization rate. Specifically, at least one process running in a preset time window is monitored in a kernel mode of the target Linux system, and system environment log data during monitoring is obtained.
The preset time window is a preset time period after a time point that the CPU utilization rate is larger than a preset threshold value is determined. For example, if it is determined at point 9 and 26 that the CPU utilization is greater than the preset threshold, 10ms after point 9 and 26 is the preset time window.
In this embodiment, when at least one process running in a preset time window is monitored in a kernel mode, the consumed CPU time and kernel mode stack and user mode stack corresponding to the process and function execution time in the process of the at least one process running in the preset time window are monitored respectively, and a process call chain when calling between processes is monitored. These monitored data constitute system environment log data.
Wherein a chain of process calls is a chain formed when calls are made between processes, each node on the chain representing a process, and a process represented by a node located later on the chain calling a process represented by a node located earlier on the chain. The monitoring process call chain can determine whether a call is made between processes according to a call relationship that should be present.
The process consumes CPU time and can represent the running time of the process, and the kernel-mode stack and the user-mode stack corresponding to the process comprise the calling relation between functions in the kernel mode and the user mode.
The system environment log composed of the above data can comprehensively reflect the running condition and the calling condition of at least one process running within the preset time window.
And 203, displaying the system environment log data according to a preset form.
The preset form is a preconfigured form, for example, may be a flame pattern form or other forms, which is not limited in this embodiment.
Specifically, in this embodiment, the system environment log data may be first converted and processed according to a preset format based on the preset format, so that the processed system environment log data meets the requirement of the preset format in format, and then the processed system environment log data is displayed according to the preset format.
According to the CPU utilization monitoring method provided by the embodiment, the CPU utilization of the target Linux system is obtained; in response to determining that the CPU utilization is greater than a preset threshold, monitoring at least one process running within a preset time window in a kernel mode of the target Linux system to obtain system environment log data, wherein the system environment log data comprises: at least one process corresponding to the operation related data and a process call chain; the operation-related data includes: the process consumes CPU time, kernel mode stack corresponding to the process and user mode stack, function execution time in the process; and displaying the system environment log data according to a preset form. When the CPU utilization rate is determined to be large and the preset threshold value is determined, at least one process running in the preset time window is monitored in the kernel mode, so that the running condition and the process calling condition of the process can be monitored in more detail, more detailed system environment log data can be obtained, the system environment log data is displayed in the preset mode, the running and calling conditions of the process when the CPU is abnormal can be observed more intuitively by a user, the reason of the abnormality of the CPU utilization rate can be positioned rapidly and accurately, and the system environment can be recovered rapidly and effectively in a targeted mode.
As an optional implementation manner, on the basis of the foregoing embodiment, at least one process running in a preset time window is monitored in a kernel mode of a target Linux system to obtain running related data and a process call chain corresponding to the at least one process, where the method includes the following technical scheme:
and executing the KProcbes probe function pre-inserted into the process calling function when executing the process calling function in the kernel mode of the target Linux system within a preset time window. And monitoring the running condition of the process called by the process calling function by adopting the KProcbes probe function so as to obtain running related data and a process calling chain corresponding to at least one process.
The KProcbes probe function is a probe function designed for conveniently tracking the running condition and the calling condition of the process in the kernel state, and is inserted into the process calling function, so that the monitoring of the process by the KProcbes probe function is not influenced by the original execution flow in the kernel state.
In this embodiment, before at least one process running in a preset time window is monitored in a kernel mode of the target Linux system, a KProcbes probe function is inserted into a process call function. Included in the KProcbes probe function is a scheme to perform monitoring of invoked processes. Then the scheme for obtaining system environment log data is started within a preset time window when the CPU utilization is determined to be greater than a preset threshold. Specifically, when a certain process is run within a preset time window, a process call function is executed, and since the KProcbes probe function is inserted into the process call function, the KProcbes probe function is also executed when the process call function is executed. The execution of the KProcbes probe function monitors the running condition of the process called by the process calling function. By writing programs for monitoring CPU time consumption of a process, kernel mode stacks and user mode stacks corresponding to the process, function execution time in the process and a process call chain in the KProcbes probe function, the monitoring of the process operation related data and the process call chain is realized.
According to the CPU utilization monitoring method provided by the embodiment, at least one process running in a preset time window is monitored in a kernel mode of a target Linux system, so that when running related data corresponding to the at least one process and a process call chain are obtained, a KProcbes probe function which is inserted into the process call function in advance is executed when the process call function is executed in the kernel mode of the target Linux system in the preset time window; and monitoring the running condition of the process called by the process calling function by adopting the KProcbes probe function so as to obtain running related data and a process calling chain corresponding to at least one process. Because the KProcbes probe function is inserted into the process calling function in advance, the influence on the original execution flow of the process is effectively reduced while the monitoring of the running condition of the process is realized by adopting the KProcbes probe function.
As an optional implementation manner, when the CPU utilization rate of the target Linux system is obtained on the basis of any one of the above embodiments, the method comprises the following steps:
and acquiring CPU indexes of the target Linux system by adopting the Proc file system. And calculating the CPU utilization rate according to the CPU index.
The Proc file system is a virtual file system, and uses a new mode to communicate between the kernel mode and the user mode of the Linux system.
Specifically, a Proc/stat file system under the Proc file system is adopted to acquire statistical information of the system and the kernel after the system is started. Comprising the following steps: CPU running condition, interrupt condition, start time, running process and other information. For the running condition of the CPU, CPU indexes can be obtained, for example, the method can comprise the following steps: user state occupation time, kernel state occupation time, space time, I/O waiting time, soft interrupt time, hard interrupt time and the like. Based on these CPU indices, the CPU utilization is calculated.
It should be noted that how to calculate the CPU utilization based on the CPU index is the prior art, and is not described here in detail.
In this embodiment, when the CPU utilization of the target Linux system is obtained, programming is performed by using the C language, so that the cycle sentences in the implementation process are reduced, and the CPU utilization can be obtained efficiently.
In the method for monitoring the CPU utilization rate, when the CPU utilization rate of the target Linux system is obtained, a Proc file system is adopted to obtain the CPU index of the target Linux system; and calculating the CPU utilization rate according to the CPU index. The CPU index is acquired by adopting the Proc file system of the target Linux system, and the CPU utilization rate is calculated based on the CPU index, so that the CPU utilization rate can be acquired more conveniently and efficiently.
As an optional implementation manner, on the basis of any one of the above embodiments, the displaying the system environment log data according to a preset form includes the following schemes:
and processing the system environment log data according to the format required by the flame map. And displaying the processed system environment log data in a flame pattern mode.
Wherein, the system environment log data comprises: the process consumes CPU time, kernel mode stack corresponding to the process, user mode stack, function execution time in the process and process call chain.
Specifically, in this embodiment, after the system environment log data is processed according to the format required by the flame map, a perl script may be used to draw a flame map of the cpu utilization rate of the system process. The flame map can intuitively show that each process consumes CPU time, a function call relation in a kernel mode stack, a function call relation in a user mode, execution time of a function in the process and a call chain of the process, so that a user can intuitively determine the abnormal process or process call or abnormal function or function call by looking up the flame map.
Optionally, the function execution time in the process, the CPU time consumed by the process, the kernel mode stack corresponding to the process and the user mode stack can be combined for processing, and the on-CPU type flame diagram is adopted for displaying. Specifically, the intra-process function call relationship in the kernel mode and the time spent by each function call can be determined based on the kernel mode stack corresponding to the process, the function execution time in the process, and the CPU time spent by the process. And determining function calls in the process in the user mode and time spent by each function call based on the user mode stack corresponding to the process, the function execution time and the CPU time spent by the process. Flame plots of the on-cpu type are used to show the relationship of function calls within a process in kernel mode to the time it takes for the function call. And using a flame diagram of the on-cpu type to show the relationship between function calls and the time spent by the function calls in the process in the user state. The function call with longer call time in the function call process can be found through the flame diagram of the on-cpu type, and the abnormal call of the function can be determined based on the function call with longer call time.
Alternatively, the CPU time consumed by the process and the process call chain can be combined for processing, and the call relationship between the processes and the CPU time consumed by the processes are displayed in a flame diagram mode. The abnormal progress or progress call can be intuitively determined by looking at the flame pattern.
According to the CPU utilization monitoring method provided by the embodiment, when the system environment log data are displayed according to the preset form, the system environment log data are processed according to the format required by the flame map; the processed system environment log data is displayed in a flame pattern form, and the flame pattern can more intuitively display the relationship between function call and time consumed by function call and the relationship between call in process and time consumed by function call, so that the flame pattern is adopted to display the system environment log data in the flame pattern form, abnormal processes or functions can be more rapidly positioned, and the efficiency of positioning CPU utilization rate abnormality is further improved.
As an optional implementation manner, on the basis of any one of the above embodiments, after monitoring, in a kernel mode of the target Linux system, at least one process running in a preset time window to obtain system environment log data, the method further includes the following technical scheme:
And transmitting the system environment log data from the kernel mode of the target Linux system to the user mode by adopting a double buffer cache technology. And storing the system environment log data in the user mode according to a preset storage strategy.
Specifically, in this embodiment, a dual buffer is set, which is a process buffer and a kernel buffer, and the system environment log data is written into the kernel buffer from the process buffer by adopting a dual buffer technology, and then is transmitted to the user mode from the kernel buffer, so that the dual buffer technology can improve the system performance, and therefore, the system environment log data can be efficiently transmitted from the kernel mode to the user mode of the target Linux system.
The preset storage strategy is a preset storage strategy for improving the data storage efficiency and reducing the system storage pressure.
Wherein the preset storage policy may include at least one of the following storage policies: a storage strategy for limiting the storage size of data, and the like according to a strategy for storing a preset data structure, a strategy for storing after compressing according to a preset compression mode
The method for monitoring the CPU utilization in this embodiment monitors, in a kernel mode of a target Linux system, at least one process running in a preset time window, so as to obtain system environment log data, and then further includes: transmitting the system environment log data from the kernel mode of the target Linux system to the user mode by adopting a double buffer cache technology; and storing the system environment log data in the user mode according to a preset storage strategy. Because the system environment log data is transmitted to the user mode by adopting the double buffer cache technology, the system environment log data can be efficiently transmitted from the kernel mode of the target Linux system to the user mode. And the data is stored according to a preset storage strategy, so that the data storage efficiency can be effectively improved and the system storage pressure can be reduced.
As an optional implementation manner, on the basis of the foregoing embodiment, the storing, in a user state, the system environment log data according to a preset storage policy includes the following technical scheme:
and processing each data in the system environment log data according to a preset data structure. And compressing the system environment log data to obtain compressed system environment log data. And if the data storage space is full in the storage process, storing in a mode that the system environment log data after the new compression is used for covering the system environment log data after the old compression.
The corresponding preset data structures may also be different based on the different data types. For example, CPU time consumed by a process and function execution time in the process may be stored in an array. And storing the kernel mode stack and the user mode stack corresponding to the process by adopting data or a linked list. A linked list may be employed for the process call chain to store.
Specifically, in this embodiment, after each data in the system environment log data is processed according to a preset data structure, data corresponding to the preset data structure is formed, and each data processed by the preset data structure is compressed by adopting a preset compression algorithm, so as to obtain compressed system environment log data.
The preset compression algorithm may be gzip or zip, which is not limited in this embodiment.
In this embodiment, in the process of storing the compressed system environment log data, in order to save storage resources, a rolling mechanism may be used to store the system environment log data by limiting the size of the data storage space. Specifically, whether the data storage space is full or not can be monitored in the storage process, if so, the storage is performed in a manner that the newly compressed system environment log data which is not stored is covered by the old compressed system environment log data which is stored first, and the storage manner uses a rolling mechanism, so that the data in the data storage space are all newer compressed system environment log data.
According to the CPU utilization monitoring method provided by the embodiment, when the system environment log data is stored according to the preset storage strategy in the user mode, all the data in the system environment log data are processed according to the preset data structure; compressing the system environment log data to obtain compressed system environment log data; and if the data storage space is full in the storage process, storing in a mode that the system environment log data after the new compression is used for covering the system environment log data after the old compression. Because each data in the system environment log data is processed according to the preset data structure, each data can be stored by adopting the most suitable data structure, and the system environment log data is compressed before being stored, so that the data storage space can be effectively reduced, and the storage resources are saved. And if the data storage space is full in the storage process, the new compressed system environment log data is used for storing in a mode of covering the old compressed system environment log data, so that the stored data can be ensured to be newer system environment log data under the condition of limiting the storage space.
As an optional implementation manner, on the basis of any one of the above embodiments, after monitoring, in a kernel mode of the target Linux system, at least one process running in a preset time window to obtain system environment log data, the method further includes the following technical scheme:
a pre-configured CPU load reduction policy is obtained. And regulating the CPU load according to the CPU load reduction strategy. The CPU load reduction policy includes any one or more of the following: adjusting the priority of the process, limiting the number of threads in the process, adjusting the resource allocation condition of a plurality of processes, and adjusting the CPU frequency and the power consumption mode.
In this embodiment, after determining that the CPU utilization is greater than the preset threshold, it is determined that the CPU utilization is abnormal, and then after determining that the system environment log data, the system environment may be restored by reducing the CPU load, so as to reduce the CPU utilization. Specifically, the user may pre-configure at least one CPU load reduction policy. By obtaining at least one CPU load reduction policy that is preconfigured, the CPU load may be reduced in accordance with the at least one CPU load reduction policy.
Optionally, if the CPU load reduction policy includes adjusting the priority of the process, the priority of the running process may be dynamically adjusted by using the punie command in the target Linux system, and the priority of the important process may be adjusted to a higher priority, so as to ensure the priority running of the important process. If the CPU load reduction strategy comprises limiting the number of threads in the process, a physical resource isolation mechanism (abbreviated as a cgroups mechanism) of a target Linux system is adopted to set a CPU quota and a limit for each process in the process group so as to limit the number of threads in the process. If the CPU load reduction strategy comprises adjusting the resource allocation conditions of a plurality of processes, the resource allocation conditions of the processes in the process group can be adjusted in real time according to the CPU load conditions so as to ensure the priority operation of important processes. If the CPU load reduction strategy includes adjusting the CPU frequency and power consumption mode, CPU performance and power consumption may be balanced by adjusting the CPU frequency and power consumption mode, providing more computing power by increasing the CPU frequency when CPU utilization is higher.
The method for monitoring the CPU utilization in this embodiment monitors, in a kernel mode of a target Linux system, at least one process running in a preset time window, so as to obtain system environment log data, and then further includes: acquiring a pre-configured CPU load reduction strategy; regulating the CPU load according to a CPU load reduction strategy; the CPU load reduction policy includes any one or more of the following: adjusting the priority of the process, limiting the number of threads in the process, adjusting the resource allocation condition of a plurality of processes, and adjusting the CPU frequency and the power consumption mode. When the CPU utilization rate is larger than the preset threshold value, the CPU load is regulated according to the CPU load reduction strategy, so that the CPU utilization rate can be reduced to the normal level as soon as possible through reducing the CPU load to carry out effective self-adaptive regulation on the CPU utilization rate.
As an optional implementation manner, on the basis of any one of the foregoing embodiments, in response to determining that the CPU utilization is smaller than a preset threshold, the method further includes the following scheme:
and acquiring a pre-configured CPU load increase strategy. And regulating the CPU load according to the CPU load increasing strategy. The CPU load increase strategy includes: increasing the number of processes and/or increasing the amount of resource allocation in a process.
In this embodiment, after determining that the CPU utilization is smaller than the preset threshold, it is determined that the CPU utilization is insufficient, so that the CPU utilization is to be improved by increasing the CPU load. Specifically, the user may pre-configure at least one CPU load increase policy. By acquiring the at least one CPU load increase policy configured in advance, the CPU load can be increased in accordance with the at least one CPU load increase policy.
Alternatively, if the CPU load increase policy includes increasing the number of processes, the number of processes may be increased by increasing the amount of tasks handled by the CPU. If the CPU load increasing strategy comprises increasing the resource allocation amount in the process, the resource allocation amount in the process can be increased by increasing the resource allocation amount of at least one process in the process group in real time according to the CPU load condition, and the parallel operation of a plurality of processes can be ensured.
In the method for monitoring the CPU utilization rate, the CPU utilization rate is determined to be smaller than the preset threshold value, and a pre-configured CPU load increasing strategy is obtained; regulating the CPU load according to a CPU load increasing strategy; the CPU load increase strategy includes: increasing the number of processes and/or increasing the amount of resource allocation in a process. When the CPU utilization rate is smaller than the preset threshold value, the CPU load is regulated according to the CPU load increasing strategy, so that the CPU utilization rate can be effectively and adaptively regulated by increasing the CPU load, and the CPU utilization rate is increased to a normal level as soon as possible.
As an optional implementation manner, after obtaining the CPU utilization of the target Linux system on the basis of any one of the foregoing embodiments, the method further includes the following scheme:
and storing the CPU utilization rate in a preset period according to a preset storage strategy. And displaying the CPU utilization rate in a preset period in a line graph mode.
In this embodiment, in order to analyze and optimize the periodically acquired CPU utilization, the CPU utilization in a preset period is stored according to a preset storage policy.
The preset time period may be, for example, a last month, a last two weeks, or the like, which is not limited in this embodiment.
The preset storage strategy of the CPU in the utilization rate storage is the same as the preset storage strategy of the system environment log data. May include at least one of the following storage policies: and storing strategies according to a preset data structure, storing strategies after compressing according to a preset compression mode, storing strategies for limiting the data storage size, and the like.
The preset storage structure in the process of storing the CPU utilization rate can be in an array mode. The preset compression mode may be a gzip mode or a zip mode.
In this embodiment, when the CPU utilization rate in the preset period is displayed, a python drawing tool may draw a corresponding utilization rate/time line diagram with time as the horizontal axis and CPU utilization rate as the vertical axis, and display the corresponding utilization rate/time line diagram in the form of line diagram.
According to the CPU utilization monitoring method provided by the embodiment, after the CPU utilization of the target Linux system is obtained, the CPU utilization in a preset period is stored according to a preset storage strategy; and displaying the CPU utilization rate in a preset period in a line graph mode. The CPU utilization rate is stored according to the preset storage strategy, so that the data storage space can be effectively reduced, and the storage resources are saved. And the CPU utilization rate in a preset period is displayed in a line diagram mode, so that the fluctuation condition of the CPU utilization rate can be displayed more intuitively, and the efficiency and accuracy for positioning the abnormality of the CPU utilization rate are further improved.
As an optional implementation manner, before obtaining the CPU utilization rate of the target Linux system on the basis of any one of the above embodiments, the method further comprises the following scheme:
acquiring CPU utilization rate acquisition frequency and a preset threshold value which are preset by a user; the acquisition frequency is configured by adopting a command line parameter or configuration file mode.
Correspondingly, obtaining the CPU utilization rate of the target Linux system comprises the following steps:
and acquiring the CPU utilization rate of the target Linux system according to the CPU utilization rate acquisition frequency to obtain the CPU utilization rate.
Specifically, the user can configure the CPU utilization rate acquisition frequency based on the number of CPUs, the memory size, the CPU frequency and the like of the target Linux system. The user can specifically configure the CPU utilization rate acquisition frequency in a command line parameter or configuration file mode. And after the CPU utilization rate acquisition frequency is configured, the CPU utilization rate of the target Linux system can be acquired according to the CPU utilization rate acquisition frequency so as to periodically acquire the CPU utilization rate.
It can be understood that if the CPU utilization is at a lower level for a longer time, the CPU utilization acquisition frequency may also be updated to reduce the CPU utilization acquisition frequency. Or if CPU utilization is at a higher level for a longer period of time. The CPU utilization rate acquisition frequency can also be updated, so that the CPU utilization rate acquisition frequency is improved. The CPU utilization rate acquisition frequency can be adaptively adjusted based on the specific situation of the CPU utilization rate.
In this embodiment, the user may configure the preset threshold in addition to the CPU utilization rate acquisition frequency, and may specifically also configure the preset threshold by means of a command line parameter or a configuration file.
The CPU utilization monitoring method provided by the embodiment acquires the CPU utilization acquisition frequency and the preset threshold value which are preconfigured by a user before acquiring the CPU utilization of the target Linux system; the acquisition frequency is configured by adopting a command line parameter or configuration file mode; correspondingly, when the CPU utilization rate of the target Linux system is obtained, the CPU utilization rate of the target Linux system is collected according to the CPU utilization rate collection frequency, so that the CPU utilization rate is obtained. Because the CPU utilization rate acquisition frequency and the preset threshold value can be configured in advance by a user, the CPU utilization rate acquisition frequency and the preset threshold value can be customized based on the system requirement of the target Linux system, and more system requirements can be adapted.
Fig. 3 is a schematic flow chart of a method for monitoring CPU utilization in another embodiment of the present application, as shown in fig. 3, where the method for monitoring CPU utilization in this embodiment is described as an optional complete embodiment on the basis of any one of the foregoing embodiments, and an execution body of this embodiment is a CPU utilization monitoring device. The CPU utilization monitoring device may be located in an electronic device, and the CPU utilization monitoring method provided in this embodiment includes the following steps:
Step 301, acquiring CPU utilization rate acquisition frequency and a preset threshold value which are preset by a user; the acquisition frequency is configured by adopting a command line parameter or configuration file mode.
And step 302, collecting the CPU utilization rate of the target Linux system according to the CPU utilization rate collection frequency to obtain the CPU utilization rate.
Step 303, storing the CPU utilization rate in a preset period according to a preset storage strategy; and displaying the CPU utilization rate in a preset period in a line graph mode.
It should be noted that there is no strict limitation on the execution sequence between step 303 and steps 304-308.
Step 304, determining whether the CPU utilization is greater than a preset threshold, if so, executing step 305, otherwise, executing step 309.
And step 305, monitoring at least one process running in a preset time window in the kernel mode of the target Linux system to obtain system environment log data.
Wherein the system environment log data includes: at least one process corresponding to the operation related data and a process call chain; the operation-related data includes: the process consumes CPU time, kernel mode stack corresponding to the process, user mode stack and function executing time in the process.
The process call chain is used for representing call relations among processes.
And 306, transmitting the system environment log data from the kernel mode of the target Linux system to the user mode by adopting a double buffer cache technology, and storing the system environment log data in the user mode according to a preset storage strategy.
Step 307, displaying the system environment log data according to a preset form.
Step 308, obtaining a pre-configured CPU load reduction strategy; and regulating the CPU load according to the CPU load reduction strategy.
The CPU load reduction policy includes any one or more of the following:
adjusting the priority of the process, limiting the number of threads in the process, adjusting the resource allocation condition of a plurality of processes, and adjusting the CPU frequency and the power consumption mode.
It should be noted that, there is no strict limitation on the execution sequence between the step 307 and the step 308, the step 307 may be executed first and then the step 308 may be executed, the step 308 may be executed first and then the step 307 may be executed, or the step 307 and the step 308 may be executed simultaneously.
In step 309, in response to determining that the CPU utilization is less than the preset threshold, a preconfigured CPU load increase policy is obtained, and the CPU load is adjusted according to the CPU load increase policy.
Wherein the CPU load increase strategy comprises: increasing the number of processes and/or increasing the amount of resource allocation in a process.
In this embodiment, the implementation manners of steps 301 to 309 are similar to those of the corresponding schemes in the above embodiment, and will not be described in detail herein.
Fig. 4 is a schematic structural diagram of a CPU utilization monitoring device according to an embodiment of the present application, as shown in fig. 4, where the CPU utilization monitoring device provided in this embodiment is located in an electronic device, the CPU utilization monitoring device 40 provided in this embodiment includes: the system comprises an acquisition module 41, a monitoring module 42 and a display module 53.
The obtaining module 41 is configured to obtain a CPU utilization of the target Linux system. The monitoring module 42 is configured to monitor, in response to determining that the CPU utilization is greater than a preset threshold, at least one process running within a preset time window in a kernel mode of the target Linux system to obtain system environment log data, where the system environment log data includes: at least one process corresponding to the operation related data and a process call chain; the operation-related data includes: the process consumes CPU time, kernel mode stack corresponding to the process, user mode stack and function execution time in the process, and the process call chain is used for representing call relations among the processes. The display module 43 is configured to display the system environment log data according to a preset form.
The CPU utilization monitoring device provided in this embodiment may execute the scheme of the method embodiment shown in fig. 2, and specific implementation and beneficial effects are not described herein.
Optionally, the monitoring module 42 is specifically configured to:
and executing the KProcbes probe function pre-inserted into the process calling function when executing the process calling function in the kernel mode of the target Linux system within a preset time window. And monitoring the running condition of the process called by the process calling function by adopting the KProcbes probe function so as to obtain running related data and a process calling chain corresponding to at least one process.
Optionally, the obtaining module 41 is specifically configured to:
acquiring CPU indexes of a target Linux system by adopting a Proc file system; and calculating the CPU utilization rate according to the CPU index.
Optionally, the display module 43 is specifically configured to:
processing the system environment log data according to the format required by the flame map; and displaying the processed system environment log data in a flame pattern mode.
Optionally, the CPU utilization monitoring device provided in this embodiment further includes: the device comprises a monitoring module and a storage module.
The monitoring module is used for transmitting the system environment log data from the kernel mode of the target Linux system to the user mode by adopting a double buffer cache technology. And the storage module is used for storing the system environment log data in the user mode according to a preset storage strategy.
Optionally, the storage module is specifically configured to, when storing the system environment log data in the user state according to a preset storage policy:
processing each data in the system environment log data according to a preset data structure; compressing the system environment log data to obtain compressed system environment log data; and if the data storage space is full in the storage process, storing in a mode that the system environment log data after the new compression is used for covering the system environment log data after the old compression.
Optionally, the CPU utilization monitoring device provided in this embodiment further includes: and an adjusting module.
The acquisition module is further used for acquiring a pre-configured CPU load reduction strategy. And the adjusting module is used for adjusting the CPU load according to the CPU load reduction strategy.
Wherein the CPU load reduction policy includes any one or more of the following policies:
adjusting the priority of the process, limiting the number of threads in the process, adjusting the resource allocation condition of a plurality of processes, and adjusting the CPU frequency and the power consumption mode.
Optionally, the acquiring module is further configured to acquire a preconfigured CPU load increasing policy. And the adjusting module is also used for adjusting the CPU load according to the CPU load increasing strategy.
Wherein the CPU load increase strategy comprises: increasing the number of processes and/or increasing the amount of resource allocation in a process.
Optionally, the storage module is further configured to store the CPU utilization in a preset period according to a preset storage policy. The display module 43 is further configured to display the CPU utilization rate in a preset period in a line graph form.
Optionally, the acquisition module is further configured to acquire a CPU utilization acquisition frequency and a preset threshold value configured in advance by a user; the acquisition frequency is configured by adopting a command line parameter or configuration file mode.
Correspondingly, when the acquisition module acquires the CPU utilization rate of the target Linux system, the acquisition module is specifically used for:
and acquiring the CPU utilization rate of the target Linux system according to the CPU utilization rate acquisition frequency to obtain the CPU utilization rate.
Fig. 5 is a schematic structural diagram of an electronic device provided in an embodiment of the present application, as shown in fig. 5, where the electronic device 50 is configured to implement any one of the method embodiments, and the electronic device 50 of this embodiment may include: a memory 51, a processor 52 and an output device 53.
A memory 51 for storing computer-executable instructions. The Memory 51 may include a high-speed random access Memory (Random Access Memory, RAM), and may further include a Non-Volatile Memory (NVM), such as at least one magnetic disk Memory, and may also be a U-disk, a removable hard disk, a read-only Memory, a magnetic disk, or an optical disk.
A processor 52 for executing computer-executable instructions stored in memory to implement the methods of the embodiments described above. Reference may be made in particular to the relevant description of the embodiments of the method described above. The processor 52 may be a central processing unit (Central Proccessing Unit, CPU), but may also be other general purpose processors, digital signal processors (Digital Signal Proccessor, DSP), application specific integrated circuits (Application Specific Integrated Circuit, ASIC), etc. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like. The steps of a method disclosed in connection with the present invention may be embodied directly in a hardware processor for execution, or in a combination of hardware and software modules in a processor for execution.
Alternatively, the memory 51 may be separate or integrated with the processor 52.
And an output device 53 for displaying the data. The system can be a display screen, and can be used for displaying a line graph of CPU utilization rate and a flame graph of system environment log data.
When memory 51 is a separate device from processor 52, electronic device 50 may also include bus 54. The bus 54 is used to connect the memory 51 and the processor 52. The bus 54 may be an industry standard architecture (Industry Standard Architecture, ISA) bus, an external device interconnect (Peripheral Component Interconnect, PCI) bus, or an extended industry standard architecture (Extended Industry Standard Architecture, EISA) bus, among others. The buses may be divided into address buses, data buses, control buses, etc. For ease of illustration, the buses in the drawings of the present application are not limited to only one bus or one type of bus.
The electronic device provided in this embodiment may be used to execute the above-mentioned method for monitoring CPU utilization, and its implementation manner and technical effects are similar, and this embodiment is not described here again.
The present application also provides a computer-readable storage medium having stored therein computer-executable instructions that, when executed by a processor, are configured to implement the methods provided by the various embodiments described above.
The computer readable storage medium may be a computer storage medium or a communication medium. Communication media includes any medium that facilitates transfer of a computer program from one place to another. Computer storage media can be any available media that can be accessed by a general purpose or special purpose computer. For example, a computer-readable storage medium is coupled to the processor such that the processor can read information from, and write information to, the computer-readable storage medium. In the alternative, the computer-readable storage medium may be integral to the processor. The processor and the computer readable storage medium may reside in an application specific integrated circuit (Application Specific Integrated Circuits, ASIC). In addition, the ASIC may reside in a user device. The processor and the computer-readable storage medium may also reside as discrete components in a communication device.
In particular, the computer readable storage medium may be implemented by any type of volatile or non-volatile Memory device or combination thereof, such as Static Random-Access Memory (SRAM), electrically erasable programmable Read-Only Memory (Electrically-Erasable Procgrammable Read-Only Memory, eepropcm), erasable programmable Read-Only Memory (Erasable Procgrammable Read Only Memory, EPROCM), programmable Read-Only Memory (Procgrammable Read-Only Memory, PROCM), read-Only Memory (ROM), magnetic Memory, flash Memory, magnetic disk, or optical disk. A storage media may be any available media that can be accessed by a general purpose or special purpose computer.
The present application also provides a computer program product comprising a computer program stored in a computer readable storage medium. The computer program may be read from a computer-readable storage medium by at least one processor of the apparatus, and executed by the at least one processor, causes the apparatus to implement the methods provided by the various embodiments described above.
In the several embodiments provided in this application, it should be understood that the disclosed apparatus and method may be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative, e.g., the division of modules is merely a logical function division, and there may be additional divisions of actual implementation, e.g., multiple modules may be combined or integrated into another system, or some features may be omitted or not performed. Alternatively, the coupling or direct coupling or communication connection shown or discussed with each other may be an indirect coupling or communication connection via some interfaces, devices or modules, which may be in electrical, mechanical, or other forms.
Wherein the individual modules may be physically separated, e.g. mounted in different locations of one device, or mounted on different devices, or distributed over a plurality of network elements, or distributed over a plurality of processors. The modules may also be integrated together, e.g. mounted in the same device, or integrated in a set of codes. The modules may exist in hardware, or may also exist in software, or may also be implemented in software plus hardware. The purpose of the embodiment scheme can be achieved by selecting part or all of the modules according to actual needs.
When the individual modules are implemented as software functional modules, the integrated modules may be stored in a computer readable storage medium. The software functional modules described above are stored in a storage medium and include instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) or processor to perform some steps of the methods of the various embodiments of the present application.
It should be understood that, although the steps in the flowcharts in the above embodiments are sequentially shown as indicated by arrows, these steps are not necessarily sequentially performed in the order indicated by the arrows. The steps are not strictly limited in order and may be performed in other orders, unless explicitly stated herein. Moreover, at least some of the steps in the figures may include multiple sub-steps or stages that are not necessarily performed at the same time, but may be performed at different times, the order of their execution not necessarily occurring in sequence, but may be performed alternately or alternately with other steps or at least a portion of the other steps or stages.
Other embodiments of the present application will be apparent to those skilled in the art from consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the application following, in general, the principles of the application and including such departures from the present disclosure as come within known or customary practice within the art to which the application pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the application being indicated by the following claims.
It is to be understood that the present application is not limited to the precise arrangements and instrumentalities shown in the drawings, which have been described above, and that various modifications and changes may be effected without departing from the scope thereof. The scope of the application is limited only by the appended claims.

Claims (13)

1. A CPU utilization monitoring method, comprising:
obtaining the CPU utilization rate of a target Linux system;
in response to determining that the CPU utilization is greater than a preset threshold, monitoring at least one process running within a preset time window in a kernel mode of a target Linux system to obtain system environment log data, wherein the system environment log data comprises: at least one process corresponding to the operation related data and a process call chain; the operation-related data includes: the process consumes CPU time, a kernel mode stack corresponding to the process, a user mode stack and function execution time in the process, and the process call chain is used for representing call relations among the processes;
And displaying the system environment log data according to a preset form.
2. The method of claim 1, wherein the monitoring, in a kernel mode of the target Linux system, at least one process running in a preset time window to obtain running related data and a process call chain corresponding to the at least one process includes:
executing a KProcbes probe function which is inserted into a process calling function in advance when executing the process calling function in the kernel mode of a target Linux system within a preset time window;
and monitoring the running condition of the process called by the process calling function by adopting a KProcbes probe function so as to obtain running related data and a process calling chain corresponding to at least one process.
3. The method of claim 1, wherein the obtaining the CPU utilization of the target Linux system comprises:
acquiring CPU indexes of a target Linux system by adopting a Proc file system;
and calculating the CPU utilization rate according to the CPU index.
4. The method of claim 1, wherein the presenting the system environment log data in a preset form comprises:
processing the system environment log data according to a format required by a flame map;
And displaying the processed system environment log data in a flame pattern mode.
5. The method according to claim 1, wherein after monitoring at least one process running within a preset time window in a kernel mode of the target Linux system to obtain system environment log data, further comprising:
transmitting the system environment log data from the kernel mode of the target Linux system to the user mode by adopting a double buffer cache technology;
and storing the system environment log data in a user mode according to a preset storage strategy.
6. The method of claim 5, wherein storing the system environment log data in the user mode according to a preset storage policy comprises:
processing each data in the system environment log data according to a preset data structure;
compressing the system environment log data to obtain compressed system environment log data;
and if the data storage space is full in the storage process, storing in a mode that the system environment log data after the new compression is used for covering the system environment log data after the old compression.
7. The method according to claim 1, wherein after monitoring at least one process running within a preset time window in a kernel mode of the target Linux system to obtain system environment log data, further comprising:
Acquiring a pre-configured CPU load reduction strategy;
regulating the CPU load according to the CPU load reduction strategy;
the CPU load reduction policy includes any one or more of the following policies:
adjusting the priority of the process, limiting the number of threads in the process, adjusting the resource allocation condition of a plurality of processes, and adjusting the CPU frequency and the power consumption mode.
8. The method of claim 1, wherein in response to determining that CPU utilization is less than a preset threshold, the method further comprises:
acquiring a pre-configured CPU load increase strategy;
regulating the CPU load according to the CPU load increasing strategy;
the CPU load increase policy includes: increasing the number of processes and/or increasing the amount of resource allocation in a process.
9. The method according to any one of claims 1 to 8, further comprising, after the obtaining the CPU utilization of the target Linux system:
storing the CPU utilization rate in a preset period according to a preset storage strategy;
and displaying the CPU utilization rate in a preset period in a line graph mode.
10. The method according to any one of claims 1 to 8, further comprising, before the obtaining the CPU utilization of the target Linux system:
Acquiring CPU utilization rate acquisition frequency and a preset threshold value which are preset by a user; the acquisition frequency is configured by adopting a command line parameter or configuration file mode;
the obtaining the CPU utilization rate of the target Linux system comprises the following steps:
and acquiring the CPU utilization rate of the target Linux system according to the CPU utilization rate acquisition frequency to obtain the CPU utilization rate.
11. A CPU utilization monitoring apparatus, comprising:
the acquisition module is used for acquiring the CPU utilization rate of the target Linux system;
the monitoring module is used for monitoring at least one process running in a preset time window in a kernel mode of the target Linux system in response to determining that the CPU utilization rate is greater than a preset threshold value so as to obtain system environment log data, wherein the system environment log data comprises: at least one process corresponding to the operation related data and a process call chain; the operation-related data includes: the process consumes CPU time, a kernel mode stack corresponding to the process, a user mode stack and function execution time in the process, and the process call chain is used for representing call relations among the processes;
and the display module is used for displaying the system environment log data according to a preset form.
12. An electronic device, comprising: a processor, and a memory and an output device communicatively connected to the processor;
the memory stores computer-executable instructions; the output device is used for displaying data;
the processor executes computer-executable instructions stored in the memory to implement the method of any one of claims 1-10.
13. A computer readable storage medium having stored therein computer executable instructions which when executed by a processor are adapted to carry out the method of any one of claims 1 to 10.
CN202311580702.7A 2023-11-22 2023-11-22 CPU utilization monitoring method, device, equipment and storage medium Pending CN117555732A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311580702.7A CN117555732A (en) 2023-11-22 2023-11-22 CPU utilization monitoring method, device, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311580702.7A CN117555732A (en) 2023-11-22 2023-11-22 CPU utilization monitoring method, device, equipment and storage medium

Publications (1)

Publication Number Publication Date
CN117555732A true CN117555732A (en) 2024-02-13

Family

ID=89822992

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311580702.7A Pending CN117555732A (en) 2023-11-22 2023-11-22 CPU utilization monitoring method, device, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN117555732A (en)

Similar Documents

Publication Publication Date Title
CN108874624B (en) Server, method for monitoring Java process and storage medium
US10789184B2 (en) Vehicle control device
US20120072920A1 (en) Information processing apparatus and information processing apparatus control method
CN110362402B (en) Load balancing method, device, equipment and readable storage medium
US9292336B1 (en) Systems and methods providing optimization data
CN112486642B (en) Resource scheduling method, device, electronic equipment and computer readable storage medium
CN107463332B (en) File segmentation method and device
US11023335B2 (en) Computer and control method thereof for diagnosing abnormality
CN111538585A (en) Js-based server process scheduling method, system and device
CN117555732A (en) CPU utilization monitoring method, device, equipment and storage medium
CN112711606A (en) Database access method and device, computer equipment and storage medium
CN110347546B (en) Dynamic adjustment method, device, medium and electronic equipment for monitoring task
CN116185636A (en) Memory management method, device, equipment and storage medium
CN116680151A (en) Dynamic monitoring method, system, terminal and storage medium for hard disk performance
CN112817687A (en) Data synchronization method and device
CN116126937A (en) Job scheduling method, job scheduling device, electronic equipment and storage medium
JP2019036322A (en) Vehicle controller
CN111090627B (en) Log storage method and device based on pooling, computer equipment and storage medium
CN111459634B (en) Task scheduling method, device, terminal and storage medium
CN113505017A (en) Problem troubleshooting method, device, storage medium and equipment
US9037815B2 (en) Analyzing and reducing dump data
CN111221701A (en) Chip and circuit logic reconfiguration system thereof
CN116991582A (en) Reserved memory self-adaptive configuration method, device, equipment and storage medium
CN116483612B (en) Memory fault processing method, device, computer equipment and storage medium
CN112540846B (en) Method, device and medium for controlling performance stability of server

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination