CN115904858A - CPU use information acquisition method, device, equipment and storage medium - Google Patents

CPU use information acquisition method, device, equipment and storage medium Download PDF

Info

Publication number
CN115904858A
CN115904858A CN202111165841.4A CN202111165841A CN115904858A CN 115904858 A CN115904858 A CN 115904858A CN 202111165841 A CN202111165841 A CN 202111165841A CN 115904858 A CN115904858 A CN 115904858A
Authority
CN
China
Prior art keywords
alarm threshold
utilization rate
cpu utilization
cpu
target
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
CN202111165841.4A
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.)
Beijing Rockwell Technology Co Ltd
Original Assignee
Beijing Rockwell Technology 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 Beijing Rockwell Technology Co Ltd filed Critical Beijing Rockwell Technology Co Ltd
Priority to CN202111165841.4A priority Critical patent/CN115904858A/en
Publication of CN115904858A publication Critical patent/CN115904858A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • 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

  • Debugging And Monitoring (AREA)

Abstract

In the embodiment of the application, the CPU usage rate corresponding to any process in a system can be acquired, and under the condition that the CPU usage rate exceeds the corresponding alarm threshold value, the detailed data corresponding to the process during the period that the CPU usage rate exceeds the alarm threshold value is counted until the CPU usage rate is smaller than or equal to the corresponding alarm threshold value. By the method, the CPU use information of the process can be accurately acquired, and the method is more accurate and beneficial to analyzing the CPU use condition of the process and the system.

Description

CPU use information acquisition method, device, equipment and storage medium
Technical Field
The present application relates to the field of computer technologies, and in particular, to a method, an apparatus, a device, and a storage medium for acquiring CPU usage information.
Background
In a Linux or Unix system, a top command is usually adopted to obtain the overall utilization rate of a CPU and the CPU utilization rate corresponding to each process according to a fixed time period. Since the top command has a high load when executing, which may cause extra stress to the CPU, in order to alleviate this phenomenon when the system is busy, a way of lowering the priority of the top command is usually adopted. Therefore, when the system is busy, the actual time for executing the top command is later than the preset time, and the top command still calculates the utilization rate of the CPU according to the preset time period, so that the calculation result is inaccurate.
Disclosure of Invention
Various aspects of the present application provide a method, an apparatus, a device, and a storage medium for acquiring CPU usage information, so as to acquire corresponding CPU usage information for different types of processes according to different statistical periods, and calculate a usage rate of a CPU according to an actual execution time of the CPU usage information acquired by each process, thereby ensuring accuracy of a calculation result.
The embodiment of the application provides a method for acquiring CPU use information, which comprises the following steps: aiming at any process currently existing in the system, acquiring a target statistic period and a target alarm threshold corresponding to the process; acquiring the CPU utilization rate of the process according to the target statistic period; and when the CPU utilization rate of the process is identified to exceed the target alarm threshold, starting to count the detail data of the process until the CPU utilization rate of the process is equal to or less than the target alarm threshold.
In an optional embodiment, the obtaining the target statistics period and the target alarm threshold corresponding to the process includes: acquiring an identifier corresponding to any process from a process identifier list dynamically generated by a system; judging whether the process identifier is located in a specific process configuration table, wherein the specific process configuration table stores the specific process identifier, an exclusive statistical period corresponding to the specific process and an exclusive alarm threshold; if so, acquiring a first exclusive statistical period and a first exclusive alarm threshold corresponding to the process identifier from the specific process configuration table, and taking the first exclusive statistical period as the target statistical period and the first exclusive alarm threshold as the target alarm threshold; if not, taking the default counting period as the target counting period and taking the process default alarm threshold as the target alarm threshold.
In an optional embodiment, the method further comprises: acquiring the CPU utilization rate of the system according to a default statistical period; and when the CPU utilization rate of the system is identified to exceed a first system alarm threshold value, starting to count the detail data of the system until the CPU utilization rate of the system is equal to or less than the first system alarm threshold value.
In an optional embodiment, the method further comprises: acquiring the CPU utilization rate of the system according to a default statistical period; and when the CPU utilization rate of the system is identified to exceed a first system alarm threshold value, starting to count the detail data of the system until the CPU utilization rate of the system is equal to or less than a second system alarm threshold value, wherein the second system alarm threshold value is less than the first system alarm threshold value.
In an optional embodiment, counting detail data of the process or the system until the CPU usage rate of the process or the system is equal to or less than a corresponding alarm threshold includes: recording the time when the CPU utilization rate of the process or the system exceeds a corresponding alarm threshold value as starting time; recording the time when the CPU utilization rate of the process or the system is equal to or less than the corresponding alarm threshold value as the end time; and determining the duration of the CPU utilization rate of the process or the system exceeding a corresponding alarm threshold according to the starting time and the ending time, and recording the CPU utilization rate of the process or the system in the duration.
In an optional embodiment, further comprising: recording the detail data of the process as first exception information into a first exception information table, and recording the detail data of the system as second exception information into a second exception information table.
In an optional embodiment, the method further comprises: and outputting the first abnormal information table and the second abnormal information table to analyze the use condition of the CPU according to the first and second abnormal information.
In an optional embodiment, in a case that the CPU usage of the process does not exceed the target alarm threshold, the method further includes: and acquiring the CPU use information of the process, and dynamically updating a preset CPU use information table according to the CPU use information.
An embodiment of the present application further provides an information acquiring apparatus, including: a first obtaining module: the method comprises the steps of acquiring a target statistic period and a target alarm threshold corresponding to any process currently existing in the system; a second obtaining module: the CPU utilization rate of the process is obtained according to the target statistic period; a statistic module: and the device is used for starting to count the detail data of the process when the CPU utilization rate of the process is identified to exceed the target alarm threshold value until the CPU utilization rate of the process is equal to or less than the target alarm threshold value.
An embodiment of the present application further provides an information acquiring apparatus, including: a processor and a memory storing a computer program; the processor to execute the computer program to: aiming at any process currently existing in the system, acquiring a target statistic period and a target alarm threshold corresponding to the process; acquiring the CPU utilization rate of the process according to the target statistical period; and when the CPU utilization rate of the process is identified to exceed the target alarm threshold, starting to count the detail data of the process until the CPU utilization rate of the process is equal to or less than the target alarm threshold.
Embodiments of the present application also provide a computer-readable storage medium storing a computer program, which when executed, implements the steps in the method.
In the embodiment of the present application, for any process in the system, the CPU utilization rate corresponding to the process may be obtained, and when it is identified that the CPU utilization rate exceeds the corresponding alarm threshold, the detailed data corresponding to the process during the period when the CPU utilization rate exceeds the alarm threshold is counted until the CPU utilization rate is less than or equal to the corresponding alarm threshold. By the method, the CPU use information of the process can be accurately acquired, and the CPU use information is more accurate, so that the CPU use condition of the process and the system can be analyzed.
Drawings
The accompanying drawings, which are included to provide a further understanding of the application and are incorporated in and constitute a part of this application, illustrate embodiment(s) of the application and together with the description serve to explain the application and not to limit the application. In the drawings:
fig. 1 is a flowchart of a method for acquiring CPU utilization information according to an embodiment of the present disclosure;
fig. 2 is a schematic structural diagram of a CPU utilization information acquiring apparatus according to an embodiment of the present application;
fig. 3 is a schematic structural diagram of a CPU utilization information acquiring apparatus according to an embodiment of the present application.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the technical solutions of the present application will be described in detail and completely with reference to the following specific embodiments of the present application and the accompanying drawings. It should be apparent that the described embodiments are only some of the embodiments of the present application, and not all of the embodiments. All other embodiments obtained by a person of ordinary skill in the art based on the embodiments in the present application without making any creative effort belong to the protection scope of the present application.
Under the background of the current information age, the CPU computing resource in a computer system becomes a vital production material, and whether the CPU computing resource can be efficiently utilized or not directly relates to the cost expenditure of enterprises, and further reflects the development level of social productivity. In the existing operating system, the monitoring of the performance of the CPU is the core for ensuring the stable, normal and efficient operation of the equipment such as a computer, a server and the like, wherein the task occupancy rate of the CPU is the key for effectively controlling and reasonably using the processing capacity of the CPU.
For example, in the Windows operating system, a task manager is provided as a tool by which a user can view detailed information of programs and processes currently running on the computer and can perform some operations. Linux or Unix is widely used in various industries as a mainstream modern operating system, and similar tools are also used in the Linux or Unix operating system, for example, a top command can be used to view the resource consumption of a process running in the current system. However, the top command has a high load when in use, which may cause additional stress to the CPU, and if the priority of the top command is reduced, other tasks are preferentially executed when the system is busy, and the execution result of the top command may be inaccurate. Therefore, how to accurately acquire the CPU use information without occupying excessive CPU resources when the system is busy is an important means for monitoring the CPU performance.
Based on this, the embodiment of the present application provides a method for acquiring CPU usage information, which may acquire corresponding CPU usage information by using different statistical periods for different types of processes as needed, and does not need to perform a CPU usage information acquisition operation on all processes at the same time, and may not bring excessive pressure to a CPU when a system is busy. Fig. 1 is a flowchart of a CPU usage information obtaining method provided in an embodiment of the present application, and as shown in fig. 1, the method includes:
s1, aiming at any process currently existing in a system, acquiring a target counting period and a target alarm threshold corresponding to the process;
s2, acquiring the CPU utilization rate of the process according to a target statistical period;
and S3, when the CPU utilization rate of the process is identified to exceed the target alarm threshold, counting the detailed data of the process until the CPU utilization rate of the process is equal to or less than the target alarm threshold.
In the embodiment of the present application, according to a specific service requirement, a dedicated statistical period corresponding to a specific process may be set for the specific process, so as to obtain CPU usage information corresponding to each specific process according to the dedicated statistical period corresponding to each specific process. In the embodiment of the application, a specific process configuration table is maintained in advance in the system, wherein at least a unique identifier of a specific process, an exclusive statistical period corresponding to the specific process and an exclusive alarm threshold are stored; the unique identifier of a specific process may be an ID of the process or a name of the process, and the exclusive statistical period and the exclusive alarm threshold corresponding to different specific processes may be the same or different, which is not limited herein. In the embodiment of the present application, the dedicated alarm threshold refers to a CPU utilization alarm threshold corresponding to each specific process, and according to the dedicated alarm threshold corresponding to each specific process, whether the CPU utilization of each specific process has an overload condition may be determined.
The system can identify the process currently running in the running process, and dynamically generate a process list according to the process currently running in the system; the process list includes identifiers corresponding to processes currently existing in the system, for example, a pid list is stored in the/proc directory and used for recording the identifiers corresponding to the processes currently existing in the system. Based on this, in the start configuration file of the system, a preset execution period may be configured for one designated process, and in the case of system start, the designated process may be executed according to the preset execution period, and the pid list under the proc directory is traversed to obtain the identifier corresponding to each process.
Further, under the condition that the identifier corresponding to each process is obtained, it may be determined from the process dimension whether the identifier of the process corresponding to the process is located in the specific process configuration table, for any process currently existing in the system. If the process identifier is located in the specific process configuration table, which indicates that the process is a specific process with a specific service requirement, a first exclusive statistical period and a first exclusive alarm threshold corresponding to the process identifier are obtained from the specific process configuration table, so as to obtain the CPU utilization of the process according to the first exclusive statistical period. Further, when the CPU utilization of the process exceeds the first dedicated alarm threshold corresponding thereto, the first detail data corresponding to the process when the CPU utilization exceeds the first dedicated alarm threshold may be counted for analyzing the CPU utilization of the specific process according to the first detail data.
And if the process is not located in the specific process configuration table, which indicates that the process is a non-specific process without specific service requirements, acquiring the CPU utilization rate of the process according to a default statistical period. Further, under the condition that the CPU utilization rate of the process exceeds a process default alarm threshold, counting second detail data corresponding to the process under the condition that the CPU utilization rate of the process exceeds the process default alarm threshold, so as to analyze the CPU utilization condition of the process according to the second detail data; the process default alarm threshold refers to a CPU utilization alarm threshold corresponding to each process without a specific service requirement.
In the embodiment of the application, the CPU usage information of the system can be acquired from the system dimension. Optionally, the CPU utilization rate of the system may be obtained according to a default statistical period, and in the case that the CPU utilization rate of the system exceeds the first system alarm threshold, third detail data corresponding to the system in the case that the CPU utilization rate of the system exceeds the first system alarm threshold may be counted; the first system alarm threshold is an alarm threshold corresponding to the overall CPU utilization rate of the system.
In the embodiment of the application, a CPU use information table and an abnormal information table are also maintained in the system; the CPU usage information table is used for storing CPU usage information corresponding to each process, and the exception information table is used for storing corresponding exception information from process dimensions and system dimensions. In the embodiment of the present application, the exception information refers to CPU usage information corresponding to each process when the CPU usage rate of each process exceeds a corresponding alarm threshold, and CPU usage information corresponding to the system when the CPU usage rate of each process exceeds a corresponding alarm threshold. In this embodiment, the exception information corresponding to each process and the exception information corresponding to the system may be stored in the first exception information table and the second exception information table, respectively.
Based on the above, under the condition that the CPU utilization rate of the specific process is obtained according to the first exclusive statistical cycle and/or the CPU utilization rate of the non-specific process is obtained according to the default statistical cycle, the information such as the identifier of the specific process and/or the non-specific process, the corresponding CPU utilization rate, the time for obtaining the CPU utilization rate and the like can be respectively recorded into the CPU utilization information table; under the condition that the CPU utilization rate of the specific process and/or the CPU utilization rate of the non-specific process exceed the corresponding alarm threshold value, recording first detail data corresponding to the specific process and/or second detail data corresponding to the non-specific process into a first abnormal information table; and recording the third detail data into the second abnormal information table under the condition that the CPU utilization rate of the system exceeds the corresponding alarm threshold value.
Further, the contents of the first abnormal information table and the second abnormal information table can be output, and the receiving end can analyze the CPU use condition of each process and system according to the abnormal information in the first abnormal information table and the second abnormal information table. In the embodiment of the present application, implementation forms of the receiving end are not limited, and optionally, the receiving end may be an independent computer device or server, a cloud server, or other terminal devices; for example, smart devices such as vehicle-mounted devices, mobile phones, or tablet computers. Based on this, the receiving end can perform corresponding processing under the condition that the CPU use conditions of each process and system are analyzed according to the received abnormal information. For example, for a specific process, under the condition that it is determined that there is a CPU usage exception, corresponding processing may be performed according to specific service requirements. Further optionally, in terms of a system, in the case of obtaining the first, second, and third detail data, each process in the system may also be specifically controlled according to the contents of the first exception information table and the second exception information table; for example, in the case where it is determined that there is a CPU use abnormality in some processes, it may be controlled to stop the execution of these processes, or the like.
In an optional embodiment of the present application, when the CPU utilization of each process is obtained for a first dedicated statistical period or a default statistical period, an actual period corresponding to the CPU utilization of each process obtained according to the current period may be determined according to the time obtained this time and a time interval of the last time obtained time in the CPU utilization information table, and the CPU utilization of each process in the actual period may be determined according to the CPU utilization obtained this time and the CPU utilization obtained last time. Alternatively, the CPU utilization may be a CPU maximum utilization, a CPU minimum utilization, or a CPU average utilization, which is not limited herein.
In the embodiment of the application, when the CPU utilization rate of each process is obtained, the CPU utilization information of the current process can be obtained according to the pid query/proc/pid/stat directory of the current process; all CPU use information of the current process is recorded in a/proc/pid/stat directory, and all information in the directory is recorded from the beginning of system startup to the current time. By means of the information, the duration, the starting time and the ending time of each process when the CPU utilization rate of each process exceeds the corresponding alarm threshold value can be calculated. Correspondingly, when the CPU utilization rate of the system is obtained, the CPU utilization information of the system can be obtained by inquiring/proc/stat directory; all CPU use information of the system is recorded under a/proc/stat directory, and all information in the directory is recorded from the start of the system to the current time. From this information, the duration, start time, and end time of the system when its CPU usage exceeds the corresponding alarm threshold may be calculated.
Based on this, in the embodiment of the present application, the first detail data and the second detail data at least include a duration, a start time, and an end time for which the CPU usage rate of each process exceeds the corresponding alarm threshold, and a CPU usage rate within the duration; optionally, the CPU utilization rate in this time may include a CPU maximum utilization rate, a CPU minimum utilization rate, or a CPU average utilization rate of each process, which is not limited herein. The third detail data at least comprises duration, starting time and ending time when the CPU utilization rate of the system exceeds a corresponding alarm threshold value, and the CPU utilization rate in the duration; optionally, the CPU usage rate in the duration may include a CPU maximum usage rate, a CPU minimum usage rate, or a CPU average usage rate of the system, which is not limited herein.
In the embodiment of the present application, when determining that the CPU utilization of each process and system exceeds the duration of the respective corresponding alarm threshold, the duration from the time the CPU utilization exceeds the corresponding alarm threshold to the time less than or equal to the corresponding alarm threshold may be determined, or the duration may be determined according to another alarm threshold. Optionally, taking the duration that the CPU utilization rate of the system exceeds the corresponding alarm threshold as an example, a second system alarm threshold may also be set for the CPU utilization rate of the system, and whether the CPU utilization condition of the system is recovered to normal is determined according to the second system alarm threshold; wherein the second system alarm threshold is less than the first system alarm threshold.
For example, the first system alarm threshold is 70%, the second system alarm threshold is 60%, and if it is determined that the CPU utilization of the current system exceeds 70%, it is determined that the CPU load of the system is too high, which is an abnormal use condition. At the moment, recording the current time as the starting time, acquiring the CPU use information of the system, and recording the acquired CPU use information into a second abnormal information table until the CPU use rate of the system is lower than 60%, and determining that the CPU of the system is recovered to be normally used. At this time, the CPU usage information of the system is stopped to be obtained, the current time is recorded as the end time, and the time range from the start time to the end time is determined as the duration of the CPU usage rate of the system exceeding the corresponding alarm threshold. By the method, the condition that the recording result is inaccurate due to fluctuation of the CPU utilization rate of the system around the first system alarm threshold value can be effectively avoided.
In an optional embodiment of the present application, a corresponding priority may also be set for the CPU utilization information obtaining task of each process. For example, for a particular process with a particular business requirement and a non-particular process without a particular business requirement, the system may be more concerned about the CPU usage of the particular process at runtime. Based on this, the priority of executing the CPU usage information acquisition task for the specific process can be set to a higher priority, so that the CPU usage information of the specific process can be acquired in time in any situation. Further, for non-specific processes without specific service requirements, the priority for executing the CPU usage information acquisition task on these processes may be set to a lower priority, so as to preferentially acquire the CPU usage information of a specific process when the system is busy, and execute the CPU usage information acquisition task on the non-specific processes when the system is idle. Therefore, the CPU use information of the specific process can be obtained in time even if the system is busy, and no more pressure is caused to the CPU.
In the embodiment of the present application, a manner of setting corresponding priorities for the CPU usage information acquisition tasks of the processes is not limited, and alternatively, the priority for executing the CPU usage information acquisition tasks on specific processes may be set as a fixed priority, and the priority for executing the CPU usage information acquisition tasks on non-specific processes may be set as a dynamically adjustable priority, so that the priorities for executing the CPU usage information acquisition tasks on the processes are adjusted when individual non-specific processes have specific service requirements.
Based on the above, when the CPU utilization of each process is acquired for the first exclusive statistical period or the default statistical period, the actual time of acquiring the CPU utilization of the process in this execution may be determined according to the priority of the CPU utilization information acquisition task executed on each process, and the CPU utilization of the process in this time interval may be determined according to the time interval between the actual time of acquiring the CPU utilization of the process in this execution and the actual time of acquiring the CPU utilization of the process last time. Optionally, the CPU usage rate in the time interval may include a CPU maximum usage rate, a CPU minimum usage rate, or a CPU average usage rate of each process, which is not limited herein.
In the embodiment of the application, whether the current process is a specific process or not can be judged according to the identification corresponding to each process, and under the condition that the current process is determined to be the specific process, the CPU utilization rate corresponding to the current process is obtained according to the corresponding specific statistical period; and obtaining the corresponding CPU utilization rate according to a default statistical period under the condition that the current process is determined to be a non-specific process. And under the condition that the CPU utilization rate of the current process exceeds the corresponding alarm threshold value, the CPU utilization information corresponding to the current process under the condition that the CPU utilization rate of the current process exceeds the alarm threshold value can be acquired. In addition, the embodiment of the application can also acquire the CPU utilization rate of the system according to a default statistical period, and acquire the CPU utilization information of the system under the condition that the CPU utilization rate of the system exceeds a corresponding alarm threshold value. The CPU use information acquired during the period that the CPU use rate of the process or the system exceeds the corresponding alarm threshold value is more accurate, so that the CPU use condition of each process or system can be more accurately analyzed.
For the details of the implementation process of the method, reference may be made to the embodiment of the system method, which is not described herein again. It should be noted that the execution subjects of the steps of the methods provided in the above embodiments may be the same device, or different devices may be used as the execution subjects of the methods. For example, the execution subjects of steps S1 to S3 may be device a; for another example, the execution subject of step S1 may be device a, and the execution subjects of steps S2 to S3 may be device B; and so on.
In addition, in some of the flows described in the above embodiments and the drawings, a plurality of operations that appear in a specific order are included, but it should be clearly understood that these operations may be executed out of the order they appear herein or in parallel, and the order of the operations, such as S1, S2, etc., is merely used to distinguish between the various operations, and the order itself does not represent any order of execution. Additionally, the flows may include more or fewer operations, and the operations may be performed sequentially or in parallel. It should be noted that, the descriptions of "first", "second", etc. in this document are used for distinguishing different messages, devices, modules, etc., and do not represent a sequential order, nor limit the types of "first" and "second" to be different.
An embodiment of the present application further provides an information obtaining apparatus, fig. 2 is a schematic structural diagram of the information obtaining apparatus used by the processor in the embodiment of the present application, and as shown in fig. 2, the information obtaining apparatus includes: a processor 21 and a memory 22 in which computer programs are stored. The processor 21 and the memory 22 may be one or more.
The memory 22 is mainly used for storing computer programs, and these computer programs can be executed by the processor, so that the processor controls the processor 21 to implement the corresponding functions and complete the corresponding actions or tasks by using the information acquisition device. In addition to storing computer programs, the memories may be configured to store various other data to support operations on the processor 21 using the information acquisition device, examples of which include instructions for any application or method operating on the processor 21 using the information acquisition device.
The memory 22, which may be implemented by any type or combination of volatile and non-volatile memory devices, may include, for example, static Random Access Memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic or optical disks.
In the embodiment of the present application, the implementation form of the processor 21 is not limited, and may be, for example, but not limited to, a CPU, a GPU, an MCU, or the like. The processor 21 may be regarded as a control unit of the information obtaining apparatus and may be adapted to execute a computer program stored in the memory 22 to control the information obtaining apparatus to implement the corresponding functions, to perform the corresponding actions or tasks. It should be noted that, according to the different implementation forms and scenes of the information acquisition devices, the functions, actions or tasks to be implemented may be different; accordingly, the computer programs stored in the memory 22 may vary, and execution of different computer programs by the processor 21 may control the information acquisition device to perform different functions, perform different actions or tasks.
In some optional embodiments, as shown in fig. 2, the information acquiring apparatus may further include: communication components 23, a display 24, and power components 25. Only some components are schematically shown in fig. 2, which does not mean that the information acquiring apparatus includes only the components shown in fig. 2, and the information acquiring apparatus may further include other components according to different application requirements, depending on the product form of the information acquiring apparatus.
In the embodiment of the present application, the usage scenario and the implementation form of the information acquisition device are not limited, and the implementation form of the information acquisition device may be different in different usage scenarios. For example, in a scene of the internet of things, taking a vehicle use scene as an example, the information acquisition device may be one of vehicle-mounted devices; for another example, in the internet or other scenarios, the information obtaining device may be a separate computer device or a cloud server, and the like, which is not limited herein.
In the embodiment of the present application, when the processor 21 executes the computer program in the memory 22, it is configured to: aiming at any process currently existing in the system, acquiring a target statistic period and a target alarm threshold corresponding to the process; acquiring the CPU utilization rate of a process according to a target statistic period; and when the CPU utilization rate of the process is identified to exceed the target alarm threshold, starting to count the detail data of the process until the CPU utilization rate of the process is equal to or less than the target alarm threshold.
In an optional embodiment, when obtaining the target statistic period and the target alarm threshold corresponding to the process, the processor 21 is configured to: acquiring an identifier corresponding to any process from a process identifier list dynamically generated by the system; judging whether the process identifier is located in a specific process configuration table, wherein the specific process configuration table stores the specific process identifier, an exclusive statistical period corresponding to the specific process and an exclusive alarm threshold; if so, acquiring a first exclusive statistical period and a first exclusive alarm threshold corresponding to the process identifier from the specific process configuration table, and taking the first exclusive statistical period as a target statistical period and the first exclusive alarm threshold as a target alarm threshold; if not, taking the default counting period as a target counting period and taking the process default alarm threshold value as a target alarm threshold value.
In an alternative embodiment, the processor 21 is further configured to: acquiring the CPU utilization rate of the system according to a default statistical period; and when the CPU utilization rate of the system is identified to exceed the first system alarm threshold value, starting to count the detail data of the system until the CPU utilization rate of the system is equal to or less than the first system alarm threshold value.
In an alternative embodiment, the system further comprises a second system alarm threshold different from the first system alarm threshold, the processor 21 is further configured to: acquiring the CPU utilization rate of the system according to a default statistical period; when the CPU utilization rate of the system is identified to exceed a first system alarm threshold value, counting the detail data of the system is started until the CPU utilization rate of the system is equal to or smaller than a second system alarm threshold value, wherein the second system alarm threshold value is smaller than the first system alarm threshold value.
In an alternative embodiment, the processor 21 is configured to, when counting detail data of a process or system until the CPU usage rate of the process or system is equal to or less than a corresponding alarm threshold value: recording the time when the CPU utilization rate of the process or the system exceeds the corresponding alarm threshold value as the starting time; recording the time when the CPU utilization rate of the process or the system is equal to or less than the corresponding alarm threshold value as the end time; and determining the duration that the CPU utilization rate of the process or the system exceeds the corresponding alarm threshold value according to the starting time and the ending time, and recording the CPU utilization rate of the process or the system in the duration.
In an optional embodiment, the processor 21 is further configured to: recording the detail data of the process as first exception information into a first exception information table, and recording the detail data of the system as second exception information into a second exception information table.
In an alternative embodiment, the processor 21 is further configured to: and outputting the first abnormal information table and the second abnormal information table to analyze the use condition of the CPU according to the first and second abnormal information.
In an alternative embodiment, in the event that the CPU usage of the process does not exceed the target alarm threshold, the processor 21 is further configured to: and acquiring CPU use information of the process, and dynamically updating a preset CPU use information table according to the CPU use information.
Accordingly, the present application further provides a computer-readable storage medium storing a computer program, where the computer program can implement the steps that can be executed by the information acquisition device in the foregoing method embodiments when executed.
The embodiment of the application also provides an information acquisition device. For example, the processing device may be implemented as a virtual device, such as an application program, in a Communication Control Unit (CCU). As shown in fig. 3, the information acquisition apparatus includes:
the first obtaining module 301: the system is used for acquiring a target statistic period and a target alarm threshold corresponding to a process aiming at any process currently existing in the system;
the second obtaining module 302: the CPU utilization rate of the process is acquired according to the target statistical period;
the statistic module 302: and the method is used for starting to count the detail data of the process when the CPU utilization rate of the process is identified to exceed the target alarm threshold value until the CPU utilization rate of the process is equal to or less than the target alarm threshold value.
In an optional embodiment, when acquiring the target statistics period and the target alarm threshold corresponding to the process, the first acquiring module 301 is configured to: acquiring an identifier corresponding to any process from a process identifier list dynamically generated by the system; judging whether the process identifier is in a specific process configuration table, wherein the specific process configuration table stores the specific process identifier, an exclusive statistical period corresponding to the specific process and an exclusive alarm threshold; if so, the statistical module 302 obtains a first exclusive statistical period and a first exclusive alarm threshold corresponding to the process identifier from the specific process configuration table, and takes the first exclusive statistical period as a target statistical period and the first exclusive alarm threshold as a target alarm threshold; if not, the statistical module 302 takes the default statistical period as the target statistical period and takes the process default alarm threshold as the target alarm threshold.
In an alternative embodiment, the statistics module 302 is further configured to: acquiring the CPU utilization rate of the system according to a default statistical period; and when the CPU utilization rate of the system is identified to exceed the first system alarm threshold value, starting to count the detail data of the system until the CPU utilization rate of the system is equal to or less than the first system alarm threshold value.
In an alternative embodiment, the system further comprises a second system alarm threshold different from the first system alarm threshold, and the statistics module 302 is further configured to: acquiring the CPU utilization rate of the system according to a default statistical period; when the CPU utilization rate of the system is identified to exceed a first system alarm threshold value, counting the detail data of the system is started until the CPU utilization rate of the system is equal to or smaller than a second system alarm threshold value, wherein the second system alarm threshold value is smaller than the first system alarm threshold value.
In an optional embodiment, the statistics module 302, when counting detail data of a process or a system until the CPU usage rate of the process or the system is equal to or less than a corresponding alarm threshold, is configured to: recording the time when the CPU utilization rate of the process or the system exceeds the corresponding alarm threshold value as the starting time; recording the time when the CPU utilization rate of the process or the system is equal to or less than the corresponding alarm threshold value as the end time; and determining the duration that the CPU utilization rate of the process or the system exceeds the corresponding alarm threshold value according to the starting time and the ending time, and recording the CPU utilization rate of the process or the system in the duration.
In an alternative embodiment, the statistics module 302 is further configured to: recording the detail data of the process as first exception information into a first exception information table, and recording the detail data of the system as second exception information into a second exception information table.
In an alternative embodiment, the statistics module 302 is further configured to: and outputting the first abnormal information table and the second abnormal information table to analyze the use condition of the CPU according to the first and second abnormal information.
In an alternative embodiment, in the case that the CPU usage of the process does not exceed the target alarm threshold, the statistics module 302 is further configured to: and acquiring CPU use information of the process, and dynamically updating a preset CPU use information table according to the CPU use information.
The communication component in the above embodiments is configured to facilitate communication between the device in which the communication component is located and other devices in a wired or wireless manner. The device where the communication component is located can access a wireless network based on a communication standard, such as a WiFi, a 2G, 3G, 4G/LTE, 5G and other mobile communication networks, or a combination thereof. In an exemplary embodiment, the communication component receives a broadcast signal or broadcast related information from an external broadcast management system via a broadcast channel. In one exemplary embodiment, the communication component further comprises a Near Field Communication (NFC) module to facilitate short-range communication. For example, the NFC module may be implemented based on Radio Frequency Identification (RFID) technology, infrared data association (IrDA) technology, ultra Wideband (UWB) technology, bluetooth (BT) technology, and other technologies.
The display in the above embodiments includes a screen, which may include a Liquid Crystal Display (LCD) and a Touch Panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive an input signal from a user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundary of a touch or slide action, but also detect the duration and pressure associated with the touch or slide operation.
The power supply assembly of the above embodiments provides power to various components of the device in which the power supply assembly is located. The power components may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power for the device in which the power component is located.
The audio component in the above embodiments may be configured to output and/or input an audio signal. For example, the audio component includes a Microphone (MIC) configured to receive an external audio signal when the device in which the audio component is located is in an operational mode, such as a call mode, a recording mode, and a voice recognition mode. The received audio signal may further be stored in a memory or transmitted via a communication component. In some embodiments, the audio assembly further comprises a speaker for outputting audio signals.
As will be appreciated by one skilled in the art, embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the application. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
In a typical configuration, a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
The memory may include forms of volatile memory in a computer readable medium, random Access Memory (RAM) and/or non-volatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM). Memory is an example of a computer-readable medium.
Computer-readable media, including both permanent and non-permanent, removable and non-removable media, may implement the information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static Random Access Memory (SRAM), dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), read Only Memory (ROM), electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), digital Versatile Disks (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission medium, which can be used to store information that can be accessed by a computing device. As defined herein, a computer readable medium does not include a transitory computer readable medium such as a modulated data signal and a carrier wave.
It should also be noted that the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrases "comprising a," "8230," "8230," or "comprising" does not exclude the presence of other like elements in a process, method, article, or apparatus comprising the element.
The above description is only an example of the present application and is not intended to limit the present application. Various modifications and changes may occur to those skilled in the art. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.

Claims (10)

1. A CPU usage information acquisition method is characterized by comprising the following steps: aiming at any process currently existing in the system, acquiring a target statistic period and a target alarm threshold corresponding to the process;
acquiring the CPU utilization rate of the process according to the target statistical period;
and when the CPU utilization rate of the process is identified to exceed the target alarm threshold, starting to count the detail data of the process until the CPU utilization rate of the process is equal to or less than the target alarm threshold.
2. The method of claim 1, wherein obtaining the target statistics period and the target alarm threshold corresponding to the process comprises:
acquiring an identifier corresponding to any process from a process identifier list dynamically generated by the system;
judging whether the process identifier is located in a specific process configuration table, wherein the specific process configuration table stores the specific process identifier, an exclusive statistical period corresponding to the specific process and an exclusive alarm threshold;
if so, acquiring a first exclusive statistical period and a first exclusive alarm threshold corresponding to the process identifier from the specific process configuration table, and taking the first exclusive statistical period as the target statistical period and the first exclusive alarm threshold as the target alarm threshold;
if not, taking the default statistical period as the target statistical period and taking the process default alarm threshold as the target alarm threshold.
3. The method of claim 1, further comprising:
acquiring the CPU utilization rate of the system according to a default statistical period;
when the CPU utilization rate of the system is identified to exceed a first system alarm threshold value, counting the detail data of the system is started until the CPU utilization rate of the system is equal to or less than the first system alarm threshold value.
4. The method of claim 1, further comprising:
acquiring the CPU utilization rate of the system according to a default statistical period;
when the CPU utilization rate of the system is identified to exceed a first system alarm threshold value, starting to count the detail data of the system until the CPU utilization rate of the system is equal to or smaller than a second system alarm threshold value, wherein the second system alarm threshold value is smaller than the first system alarm threshold value.
5. The method according to any one of claims 2-4, wherein counting detail data of the process or the system until CPU usage of the process or the system is equal to or less than a corresponding alarm threshold comprises:
recording the time when the CPU utilization rate of the process or the system exceeds a corresponding alarm threshold value as starting time; recording the time when the CPU utilization rate of the process or the system is equal to or less than the corresponding alarm threshold value as the end time;
and determining the duration of the CPU utilization rate of the process or the system exceeding a corresponding alarm threshold according to the starting time and the ending time, and recording the CPU utilization rate of the process or the system in the duration.
6. The method of claim 5, further comprising:
recording the detail data of the process as first exception information into a first exception information table, and recording the detail data of the system as second exception information into a second exception information table.
7. The method of claim 6, further comprising:
and outputting the first abnormal information table and the second abnormal information table to analyze the use condition of the CPU according to the first and second abnormal information.
8. An information acquisition apparatus characterized by comprising:
a first obtaining module: the method comprises the steps of acquiring a target statistic period and a target alarm threshold corresponding to any process currently existing in the system;
a second obtaining module: the CPU utilization rate of the process is obtained according to the target statistical period;
a statistic module: and the device is used for starting to count the detail data of the process when the CPU utilization rate of the process is identified to exceed the target alarm threshold value until the CPU utilization rate of the process is equal to or less than the target alarm threshold value.
9. An information acquisition apparatus characterized by comprising: a processor and a memory storing a computer program;
the processor to execute the computer program to:
aiming at any process currently existing in the system, acquiring a target counting period and a target alarm threshold corresponding to the process;
acquiring the CPU utilization rate of the process according to the target statistical period;
and when the CPU utilization rate of the process is identified to exceed the target alarm threshold, starting to count the detail data of the process until the CPU utilization rate of the process is equal to or less than the target alarm threshold.
10. A computer-readable storage medium storing a computer program, wherein the computer program, when executed, performs the steps of the method of any one of claims 1-7.
CN202111165841.4A 2021-09-30 2021-09-30 CPU use information acquisition method, device, equipment and storage medium Pending CN115904858A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111165841.4A CN115904858A (en) 2021-09-30 2021-09-30 CPU use information acquisition method, device, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111165841.4A CN115904858A (en) 2021-09-30 2021-09-30 CPU use information acquisition method, device, equipment and storage medium

Publications (1)

Publication Number Publication Date
CN115904858A true CN115904858A (en) 2023-04-04

Family

ID=86492109

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111165841.4A Pending CN115904858A (en) 2021-09-30 2021-09-30 CPU use information acquisition method, device, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN115904858A (en)

Similar Documents

Publication Publication Date Title
US9336054B2 (en) Method and apparatus for configuring resource
CN110308782B (en) Power consumption prediction and control method and device and computer readable storage medium
CN112346829A (en) Method and equipment for task scheduling
CN110109899B (en) Internet of things data filling method, device and system
CN113301075B (en) Flow control method, distributed system, device and storage medium
CN112565317B (en) Hybrid cloud system, data processing method and device thereof, and storage medium
CN111581174A (en) Resource management method and device based on distributed cluster system
CN107623702B (en) Data caching method, device and system
CN115080341A (en) Computing cluster and data acquisition method, equipment and storage medium thereof
CN113728294B (en) Power consumption control and scheme generation method, device, system and storage medium
CN112486658A (en) Task scheduling method and device for task scheduling
CN115904858A (en) CPU use information acquisition method, device, equipment and storage medium
CN109063645B (en) Filtering method, filtering device and storage medium
CN115048186A (en) Method and device for processing expansion and contraction of service container, storage medium and electronic equipment
CN115905137A (en) File descriptor leakage monitoring method, device, equipment and storage medium
CN112395103B (en) Method and device for sending delay message and storage medium
CN113885969A (en) Embedded device, embedded software loading method and storage medium
CN115033369A (en) Thread scheduling method, device and equipment based on task processing
CN110737320B (en) Power consumption detection method and device, electronic equipment and storage medium
CN111459653B (en) Cluster scheduling method, device and system and electronic equipment
CN109992376B (en) Application freezing method, device, terminal and computer readable storage medium
CN113301076A (en) Flow control method, distributed system, device and storage medium
CN112149964A (en) Resource allocation method and device
CN111314303B (en) Live broadcast system, and data processing method and device of live broadcast system
CN109947765B (en) Data source detection method and device

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