System resource occupation detection method and device, equipment and readable storage medium
By acquiring and converting thread stack information, and utilizing number base conversion and sorting, threads with severe system resource consumption can be quickly and accurately located. This solves the problems of low detection efficiency and poor stability in existing technologies, and achieves efficient system resource consumption detection.
Patent Information
- Application Number
- CN202411185043.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-27
- Publication Date
- 2024-11-22
AI Technical Summary
In existing technologies, the resource usage of detection systems requires repeated manual verification, resulting in low detection efficiency and reduced system stability.
By obtaining the process's thread stack and thread usage data, and using number base conversion and descending sorting, the thread number and execution steps that are consuming a lot of system resources can be quickly determined, thereby accurately locating the problematic thread.
It improves thread location efficiency, ensures system stability, prevents the system from reaching alarm states, and reduces human error and oversight.
Smart Images

Figure CN119003179A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence technology, and in particular to a system resource occupancy detection method, apparatus, computer equipment, computer-readable storage medium, and computer program product. Background Art
[0002] Detecting system resource usage is an important indicator for measuring system performance. By detecting system resource usage, you can understand the current workload of the system. If the detected system resource usage is serious, it may indicate that the system is processing a large number of tasks, or some processes may be abnormal, which may affect the normal operation of the entire system.
[0003] When detecting an alarm for system resource usage, the problem must first be located. In related technologies, this process usually requires repeated verification by humans to determine the specific thread or specific task step that caused the alarm for system resource usage. This not only reduces the efficiency of detecting system resource usage, but also reduces the stability of the system. Summary of the invention
[0004] Based on this, it is necessary to provide a system resource occupancy detection method, apparatus, computer equipment, computer-readable storage medium and computer program product that can improve thread positioning efficiency in response to the above technical problems.
[0005] In a first aspect, the present application provides a method for detecting system resource occupancy, the method comprising:
[0006] Get the total occupancy data of each application process in system resources;
[0007] When it is determined that the total occupancy data exceeds a preset threshold, obtaining a thread stack of the process, the thread stack including service association information, and determining thread occupancy data of the system resources by multiple threads of the process;
[0008] Determine the thread numbers of the threads corresponding to the first M threads occupying the data in descending order;
[0009] Determine a first binary digit of the thread number and a second binary digit of the thread stack number in the thread stack;
[0010] Convert the thread numbers of the threads corresponding to the first M thread occupancy data from the first base digit to the second base digit to obtain the corresponding thread stack numbers;
[0011] A service association identifier is obtained, and based on the service association identifier and the thread stack number, service association information corresponding to the first M thread occupancy data is determined from the thread stack.
[0012] In one embodiment, the system resource occupancy detection method further includes:
[0013] determining a thread number for each of the threads;
[0014] Determine the thread stack number of each of the threads in the thread stack;
[0015] Establishing an association relationship between the thread number and the corresponding thread stack number;
[0016] The step of converting the thread numbers of the threads corresponding to the first M thread occupancy data from the first base digit to the second base digit to obtain the corresponding thread stack numbers comprises:
[0017] Obtaining the association relationship;
[0018] Based on the thread numbers of the threads corresponding to the first M thread occupancy data and the association relationship, the thread stack number corresponding to the thread numbers corresponding to the first M thread occupancy data is searched in the thread stack.
[0019] In one embodiment, the obtaining of total occupancy data of each application process in system resources includes:
[0020] Acquiring the total occupancy data according to a preset frequency;
[0021] When the total occupancy data exceeds a preset threshold for a consecutive preset number of times, a thread stack of the process is obtained, and thread occupancy data of the system resources by multiple threads of the process is determined.
[0022] In one embodiment, determining the service association information corresponding to the first M thread occupancy data from the thread stack according to the thread stack number includes:
[0023] In the service association information, at least the interaction data of the threads corresponding to the first M thread occupancy data, or the preceding steps, are determined.
[0024] In one embodiment, when determining that the total occupancy data exceeds a preset threshold, obtaining a thread stack of the process, the thread stack including business association information, and determining thread occupancy data of the system resources by multiple threads of the process include:
[0025] When it is determined that the total occupancy data exceeds a preset threshold, obtaining a process snapshot of the process;
[0026] Based on the process snapshot, a thread stack of the process is determined.
[0027] In one embodiment, after determining the service association information corresponding to the first M thread occupancy data from the thread stack according to the thread stack number, the method further includes:
[0028] The service association information corresponding to the first M thread occupancy data is sent.
[0029] In a second aspect, the present application further provides a system resource occupancy detection device, the system resource occupancy detection device comprising:
[0030] The first acquisition module is used to obtain the total occupancy data of each application process in the system resources;
[0031] A second acquisition module is used to acquire a thread stack of the process when it is determined that the total occupancy data exceeds a preset threshold, wherein the thread stack includes business association information and determines thread occupancy data of the system resources by multiple threads of the process;
[0032] A first determining module is used to sort the thread numbers of the threads corresponding to the first M thread occupancy data in descending order;
[0033] A second determining module, configured to determine a first binary digit of the thread number and a second binary digit of the thread stack number in the thread stack;
[0034] A conversion module, used for converting the thread numbers of the threads corresponding to the first M thread occupancy data from the first base digit to the second base digit to obtain the corresponding thread stack numbers;
[0035] The third determining module is used to obtain a service association identifier, and determine the service association information corresponding to the first M thread occupancy data from the thread stack based on the service association identifier and the thread stack number.
[0036] In one embodiment, the system resource occupancy detection device further includes:
[0037] A second determining module, used to determine the thread number of each of the threads;
[0038] A third determining module, used to determine the thread stack number of each of the threads in the thread stack;
[0039] An establishing module, used for establishing an association relationship between the thread number and the corresponding thread stack number;
[0040] The conversion module comprises:
[0041] A first acquisition unit, configured to acquire the association relationship;
[0042] The first determining unit is used to determine the thread stack number corresponding to the thread number of the thread corresponding to the first M thread occupancy data based on the thread numbers of the threads corresponding to the first M thread occupancy data and the association relationship.
[0043] In one embodiment, the system resource occupancy detection device further includes:
[0044] A third acquisition module, used to acquire the total occupancy data according to a preset frequency;
[0045] The second acquisition module is further configured to acquire the thread stack of the process and determine thread occupancy data of the system resources by multiple threads of the process when the total occupancy data exceeds a preset threshold for a consecutive preset number of times.
[0046] In one embodiment, the third determination module includes:
[0047] The second determining unit is used to determine at least the interaction data of the threads corresponding to the first M thread occupancy data, or the preceding steps in the business association information.
[0048] In one embodiment, the second acquisition module includes:
[0049] A second acquisition unit, configured to acquire a process snapshot of the process when it is determined that the total occupancy data exceeds a preset threshold;
[0050] The third determining unit is configured to determine a thread stack of the process based on the process snapshot.
[0051] In one embodiment, the system resource occupancy detection device further includes:
[0052] The sending module is used to send the business association information corresponding to the first M thread occupancy data.
[0053] In a third aspect, the present application further provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:
[0054] Get the total occupancy data of each application process in system resources;
[0055] When it is determined that the total occupancy data exceeds a preset threshold, obtaining a thread stack of the process, the thread stack including service association information, and determining thread occupancy data of the system resources by multiple threads of the process;
[0056] Determine the thread numbers of the threads corresponding to the first M threads occupying the data in descending order;
[0057] Determine a first binary digit of the thread number and a second binary digit of the thread stack number in the thread stack;
[0058] Convert the thread numbers of the threads corresponding to the first M thread occupancy data from the first base digit to the second base digit to obtain the corresponding thread stack numbers;
[0059] A service association identifier is obtained, and based on the service association identifier and the thread stack number, service association information corresponding to the first M thread occupancy data is determined from the thread stack.
[0060] In a fourth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor, the following steps are implemented:
[0061] Get the total occupancy data of each application process in system resources;
[0062] When it is determined that the total occupancy data exceeds a preset threshold, obtaining a thread stack of the process, the thread stack including service association information, and determining thread occupancy data of the system resources by multiple threads of the process;
[0063] Determine the thread numbers of the threads corresponding to the first M threads occupying the data in descending order;
[0064] Determine a first binary digit of the thread number and a second binary digit of the thread stack number in the thread stack;
[0065] Convert the thread numbers of the threads corresponding to the first M thread occupancy data from the first base digit to the second base digit to obtain the corresponding thread stack numbers;
[0066] A service association identifier is obtained, and based on the service association identifier and the thread stack number, service association information corresponding to the first M thread occupancy data is determined from the thread stack.
[0067] In a fifth aspect, the present application further provides a computer program product, including a computer program, which implements the following steps when executed by a processor:
[0068] Get the total occupancy data of each application process in system resources;
[0069] When it is determined that the total occupancy data exceeds a preset threshold, obtaining a thread stack of the process, the thread stack including service association information, and determining thread occupancy data of the system resources by multiple threads of the process;
[0070] Determine the thread numbers of the threads corresponding to the first M threads occupying the data in descending order;
[0071] Determine a first binary digit of the thread number and a second binary digit of the thread stack number in the thread stack;
[0072] Convert the thread numbers of the threads corresponding to the first M thread occupancy data from the first base digit to the second base digit to obtain the corresponding thread stack numbers;
[0073] Obtaining a business association identifier, and based on the business association identifier and a corresponding thread stack number;
[0074] A service association identifier is obtained, and based on the service association identifier and the thread stack number, service association information corresponding to the first M thread occupancy data is determined from the thread stack.
[0075] The above-mentioned system resource occupancy detection method, device, computer equipment, computer-readable storage medium and computer program product, first, when it is determined that the total occupancy data exceeds a preset threshold, the thread occupancy data of the system resources of multiple threads of the process are determined, and the thread numbers of the threads corresponding to the top M thread occupancy data are determined by descending sorting, so as to quickly determine the thread numbers that occupy the system resources more seriously. Secondly, the present disclosure converts the thread numbers of the threads corresponding to the top M thread occupancy data in descending order into the corresponding thread stack numbers by converting the number of base digits, so that the current execution steps and other information of the threads that occupy the system resources more seriously can be determined in the thread stack quickly and accurately, and then the threads that occupy the system resources more seriously can be accurately located, which is convenient for system maintenance personnel to handle. The present disclosure can quickly and accurately determine the threads that occupy the system resources more seriously, so that system maintenance personnel can quickly handle these threads to maintain the stability of the system and prevent the system from reaching an alarm state. BRIEF DESCRIPTION OF THE DRAWINGS
[0076] In order to more clearly illustrate the technical solutions in the embodiments of the present application or related technologies, the drawings required for use in the embodiments of the present application or related technical descriptions will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.
[0077] Figure 1 A schematic diagram of a flow chart of a method for detecting system resource occupancy provided in an embodiment;
[0078] Figure 2 A schematic diagram of a flow chart of a method for detecting system resource occupancy provided in another embodiment;
[0079] Figure 3A schematic diagram of a method for establishing an association relationship provided in an embodiment;
[0080] Figure 4 A schematic diagram of an association relationship application method provided in an embodiment;
[0081] Figure 5 A schematic diagram of obtaining total occupancy data provided in one embodiment;
[0082] Figure 6 A schematic diagram of obtaining a process snapshot provided in one embodiment;
[0083] Figure 7 A schematic diagram of sending business-related information provided in an embodiment;
[0084] Figure 8 is a structural block diagram of a system resource occupancy detection device in an embodiment;
[0085] Fig. 9 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0086] In order to make the purpose, technical solutions and advantages of the present application clearer, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application. It should be noted that in the embodiments of the present application, certain software, groups, models and other existing solutions in the industry may be mentioned, which should be considered as exemplary, and their purpose is only to illustrate the feasibility of the implementation of the technical solution of the present application, but it does not mean that the applicant has or will necessarily use the solution.
[0087] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant regulations. The acquisition, storage, use, and processing of data in the technical solution of this application are in compliance with relevant provisions of national laws and regulations.
[0088] It should be noted that in the embodiments of the present application, certain software, components, models and other existing solutions in the industry may be mentioned, and they should be regarded as exemplary. Their purpose is only to illustrate the feasibility of implementing the technical solution of the present application, but it does not mean that the applicant has or will necessarily use the solution.
[0089] The system resource occupancy detection method provided in the embodiment of the present application can be applied to a server. The server is connected to a terminal, and the terminal can be, but is not limited to, various personal computers, laptops, smart phones, tablet computers, Internet of Things devices, etc. The server can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides cloud computing services.
[0090] In one embodiment, Figure 1 and Figure 2 As shown, a system resource occupancy detection method is provided. In this embodiment, the method is applied to Figure 2 The monitoring and disposal management platform in the example is used for illustration. It can be understood that the method can also be applied to a system including a terminal and a server, and is implemented through the interaction between the terminal and the server. In this embodiment, the method includes the following steps:
[0091] Step 100: Obtain the total occupancy data of each application process in system resources.
[0092] Step 200: When it is determined that the total occupancy data exceeds a preset threshold, a thread stack of the process is obtained, the thread stack includes business association information, and thread occupancy data of system resources of multiple threads of the process is determined.
[0093] Step 300: Determine the thread numbers of the threads corresponding to the first M threads occupying data in descending order.
[0094] Step 400: Determine the first binary digit of the thread number and the second binary digit of the thread stack number in the thread stack.
[0095] Step 500: Convert the thread numbers of the threads corresponding to the first M thread occupancy data from the first base digit to the second base digit to obtain the corresponding thread stack numbers.
[0096] Step 600: Obtain a service association identifier, and based on the service association identifier and the thread stack number, determine service association information corresponding to the first M thread occupancy data from the thread stack.
[0097] In step 100, the system may include multiple applications. As an example, the system may include multiple Java applications, or the system may include multiple Python applications, etc. This embodiment does not specifically analyze the types of systems and applications. Multiple applications in the system may be in a running state, or in other states such as closed, restarted, and suspended.
[0098] Applications need to occupy system resources. As an example, system resources may include the computing capacity of the system's central processing unit (CPU), physical memory, computing capacity of physical drives, traffic of major networks, etc. This embodiment does not impose specific restrictions on system resources.
[0099] Each application may have a corresponding process. It is understandable that the process of an application may represent the current running degree or current running step of the application. Each application needs to occupy system resources, and applications in running state usually need to occupy more system resources. At this time, the current system operation status can be obtained by counting the total occupancy data of the processes of each application in the system resources. As an example, the total occupancy data of the processes of each application in the system resources may include the CPU occupancy rate or occupancy value, and may also include the occupancy rate of physical memory, disk utilization or network utilization, etc.
[0100] In step 200, illustratively, when the total occupancy data of system resources is the occupancy rate of the CPU, the preset threshold value may be 50%-70%. When the total occupancy data of system resources is the occupancy rate of the physical memory, the preset threshold value may be 60%-70%. The above data are for reference only. In actual embodiments, the preset threshold value of the total occupancy data of system resources is not limited to the above values, and the above values do not affect the protection scope of this embodiment.
[0101] When it is determined that the total occupancy data exceeds the preset threshold, it means that the system may be in a high-load state, or that an application in the system has an abnormal situation, or that the system is about to issue an alarm. At this time, the thread stack of the process can be obtained, and continuing may affect server performance and business response time. It can be understood that a thread can be an execution unit in a process, and a process can include multiple threads. The thread stack can include business-related information, and the business-related information can include the function or method currently called by each thread, the context information of the thread, the register status of the thread, the stack pointer of the thread, etc. As an example, at this time, Figure 2 As shown, the analysis action is triggered, and the terminal disposal agent can collect a thread stack of the process through the JDK command jstack and persist it in the local disk.
[0102] Moreover, when it is determined that the total occupancy data exceeds a preset threshold, the thread occupancy data of the system resources of multiple threads of the process can also be determined. It can be understood that each thread also needs to occupy system resources. As an example, when the total occupancy data of system resources is the occupancy rate of the CPU, it is necessary to obtain the CPU occupancy rate of each thread. For example, the CPU occupancy rate of each thread can be 1%, 2% or 0.1%, etc. This embodiment does not impose specific restrictions on the order of obtaining the thread stack of the process and determining the thread occupancy data of the system resources of multiple threads of the process. As an example, at this time, the CPU usage rate of each thread of the process can be obtained through the Linux command.
[0103] In step 300, the thread occupancy data of all threads may be sorted in descending order to obtain thread occupancy data arranged from large to small. As an example, the thread occupancy data after descending order may be 10%, 8%, 5%, 1%, and 0.5%.
[0104] In the thread occupancy data sorted in descending order, the first M threads can be considered as threads that occupy more system resources. As an example, the first M threads can be the first thread, or the first three threads, etc. This embodiment does not specifically limit the number of the first M threads.
[0105] In step 400, the first base digit of the thread number and the second base digit of the thread stack number in the thread stack may be determined. As an example, the first base digit of the thread number may be decimal, and the second base digit of the thread stack number in the thread stack may be hexadecimal. This embodiment does not specifically limit the first base digit and the second base digit. For example, the first base digit of the thread number may also be binary, and the second base digit of the thread stack number in the thread stack may also be octal, etc.
[0106] Of course, each thread may have a unique thread number. The thread stack number in each thread stack may also have a unique thread stack number.
[0107] In step S500, the thread numbers of the threads corresponding to the first M thread occupancy data may be converted from the first base digit to the second base digit, thereby obtaining the corresponding thread stack numbers. As an example, when the first base digit of the thread number may be decimal and the second base digit of the thread stack number in the thread stack may be hexadecimal, the corresponding thread stack number may be obtained by continuously dividing the thread number by 16 and taking the remainder.
[0108] In step 600, a business association identifier may be determined first. For example, the business association identifier may be a transaction code. Then, business association information corresponding to the first M thread occupancy data is determined from the thread stack. As an example, at this time, in the thread stack, the suffix of the transaction code of the first M thread occupancy data may be represented as the business association information.
[0109] In this embodiment, first, when it is determined that the total occupancy data exceeds a preset threshold, the thread occupancy data of the system resources of multiple threads of the process is determined, and the thread numbers of the threads corresponding to the top M thread occupancy data are determined by sorting in descending order, so as to quickly determine the thread numbers that occupy the system resources more seriously. Secondly, this embodiment converts the thread numbers of the threads corresponding to the top M thread occupancy data in descending order into corresponding thread stack numbers by converting the number of base digits, so that the current execution steps and other information of the threads that occupy the system resources more seriously can be quickly and accurately determined in the thread stack, and then the threads that occupy the system resources more seriously can be accurately located, so as to facilitate the processing by system maintenance personnel. This embodiment can quickly and accurately determine the threads that occupy the system resources more seriously, so as to facilitate the system maintenance personnel to quickly process these threads to maintain the stability of the system and prevent the system from reaching an alarm state.
[0110] Afterwards, the specific business of the thread that occupies the system resources more seriously can be located. As an example, in the business association information, at least the interaction data of the thread corresponding to the first M thread occupancy data, or the preceding step can be determined. For example, at this time, the linux command matching search can be used, and the terminal acquisition agent can feed back the business association information to the monitoring and disposal management platform. Furthermore, after determining the interaction data or the preceding step of the thread corresponding to the first M thread occupancy data, the business association information or business association account where the interaction data or the preceding step is located can be further located, and the occupancy data of the business association information where the interaction data or the preceding step is located can be determined. In the case where the occupancy data of the business association information where the interaction data or the preceding step is also high, the business association information where the interaction data or the preceding step is located can also be used by system maintenance personnel to analyze the reasons for the serious occupation of system resources.
[0111] In one embodiment, see Figure 3 and Figure 4 , the system resource occupancy detection method further includes:
[0112] Step 700: Determine the thread number of each thread.
[0113] Step 710: Determine the thread stack number of each thread in the thread stack.
[0114] Step 720: Establish an association relationship between the thread number and the corresponding thread stack number.
[0115] At this time, step 500 includes:
[0116] Step 510: Obtain association relationships.
[0117] Step 511: Based on the thread numbers and association relationships of the threads corresponding to the first M thread occupancy data, search the thread stack for the thread stack number corresponding to the thread number of the thread corresponding to the first M thread occupancy data.
[0118] In step 700 to step 720, each thread may have a unique thread number, and at the same time, each thread may have a unique thread stack number in the thread stack. It can be understood that the relative thread number and the thread stack number are different identifiers of the same thread in the system and business association information. There is an association relationship between the relative thread number and the thread stack number. Through this association relationship, the relative thread number and the thread stack number can be found. As an example, when the thread number is a decimal number 233, in this association relationship, the thread stack number is represented in hexadecimal as E9.
[0119] It can be understood that the association relationship can be preset, or can be accumulated and obtained during each application of the system resource occupancy detection method.
[0120] In step 510 and step 511, based on the association relationship, the thread stack number of the thread corresponding to the first M thread occupancy data can be searched in the thread stack. As an example, the specified thread number can be searched in the association relationship until all association relationships are traversed. This embodiment does not specifically limit the search method.
[0121] In this embodiment, by providing an association relationship between the relative thread number and the thread stack number, the thread stack number of the thread corresponding to the first M thread occupancy data can be quickly found, thereby improving the accuracy of finding the thread stack number. Moreover, the association relationship in this embodiment can also be used to detect whether the conversion between the relative thread number and the thread stack number is correct, thereby improving the accuracy of determining the thread stack number.
[0122] In one embodiment, see Figure 5 , step 100 comprises:
[0123] Step 110: Obtain total occupancy data according to a preset frequency.
[0124] At this time, step 200 includes:
[0125] Step 210: When the total occupancy data exceeds a preset threshold for a consecutive preset number of times, the thread stack of the process is obtained, and thread occupancy data of system resources of multiple threads of the process is determined.
[0126] In step 110, the preset frequency may be an interval of 10 minutes, or an interval of 1 hour, etc. This embodiment does not impose any specific restrictions on the preset frequency. Figure 2 As shown, further, step 110 can be distributed to each terminal analysis agent through a policy.
[0127] In step 210, the preset number of times may be 3, 5, or 8 times, etc. As an example, when it is detected for the first time that the total occupancy data exceeds the preset threshold, counting starts. When the continuous counting reaches the preset number of times, the thread stack of the process is obtained, and the thread occupancy data of the multiple threads of the process on the system resources is determined.
[0128] In this embodiment, the system resource occupancy is detected in real time and automatically according to the preset frequency, thereby improving the security of the system. Moreover, in this embodiment, the subsequent steps are performed only when the total occupancy data exceeds the preset threshold for a preset number of consecutive times, thereby avoiding unnecessary detection steps caused by a single system abnormality, reducing human operation errors and omissions, and reducing the risk of system errors and failures.
[0129] In one embodiment, see Figure 6 , step 200 comprises:
[0130] Step 220: When it is determined that the total occupancy data exceeds a preset threshold, a process snapshot of the process is obtained.
[0131] Step 230: Determine the thread stack of the process based on the process snapshot.
[0132] In step 220 and step 230, the thread snapshot may include the current interaction data of each thread, or the record of the previous step. Therefore, the thread stack of the process may be determined in the process snapshot.
[0133] As an example, at this time, you can use the jstack command to generate a thread snapshot of a specified Java process, and then determine the thread stack of the process in the thread snapshot. The thread stack can include the current interaction data of each thread, or the record of the previous step. Of course, the above information can be displayed using encrypted information to prevent information leakage.
[0134] In this embodiment, the thread stack of the process is obtained quickly and accurately by obtaining the process snapshot. In addition, the process snapshot can also be used as a backup, so that the system maintenance personnel can analyze the serious reasons for occupying system resources.
[0135] In one embodiment, see Figure 7 , after step 600, including:
[0136] Step 800: Sending service association information corresponding to the first M thread occupancy data.
[0137] In one possible example, the alarm information of the thread can be sent to the account maintained by the system, so that the account maintained by the operation can reassign the processing task. In another possible example, the interaction data of the thread can be determined in the business association information, and then the alarm information of the thread can be sent to the interaction account of the interaction data. In another possible example, the preceding step of the thread can also be determined in the business association information, and then the alarm information of the thread can be sent to the account of the preceding step. The alarm and disposal information can be stored locally or in the cloud for subsequent analysis.
[0138] In this embodiment, by sending the business association information corresponding to the first M thread occupancy data, it is convenient for the staff of the corresponding account to quickly process the thread. This embodiment does not specifically limit the processing method of the staff. For example, the staff can reduce the thread occupancy of the system resources by limiting the current and other methods.
[0139] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.
[0140] Based on the same inventive concept, the embodiment of the present application also provides a system resource occupancy detection device for implementing the system resource occupancy detection method involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in the one or more system resource occupancy detection device embodiments provided below can refer to the limitations of the system resource occupancy detection method above, and will not be repeated here.
[0141] In an exemplary embodiment, Figure 8 As shown, a system resource occupancy detection device is provided, comprising: a first acquisition module, a second acquisition module, a first determination module, a second determination module, a conversion module and a third determination module, wherein:
[0142] The first acquisition module is used to obtain the total occupancy data of each application process in the system resources.
[0143] The second acquisition module is used to acquire the thread stack of the process when it is determined that the total occupancy data exceeds a preset threshold, wherein the thread stack includes business association information and thread occupancy data of system resources of multiple threads of the process.
[0144] The first determining module is used to determine the thread numbers of the threads corresponding to the first M thread occupancy data sorted in descending order.
[0145] A second determination module, used to determine a first binary digit of the thread number and a second binary digit of the thread stack number in the thread stack;
[0146] The conversion module is used to convert the thread numbers of the threads corresponding to the first M thread occupancy data from the first base digit to the second base digit to obtain the corresponding thread stack numbers.
[0147] The third determination module is used to obtain a service association identifier, and determine service association information corresponding to the first M thread occupancy data from the thread stack based on the service association identifier and the thread stack number.
[0148] In one embodiment, the system resource occupation detection device further includes: a second determination module, a third determination module, and an establishment module, wherein:
[0149] The second determining module is used to determine the thread number of each thread.
[0150] The third determining module is used to determine the thread stack number of each thread in the thread stack.
[0151] The module is used to establish an association relationship between a thread number and a corresponding thread stack number.
[0152] Meanwhile, the conversion module includes a first acquisition unit and a first determination unit, wherein:
[0153] The first acquisition unit is used to acquire the association relationship.
[0154] The first determining unit is used to search the thread stack for the thread stack number corresponding to the thread number of the thread corresponding to the first M thread occupancy data based on the thread numbers and association relationships of the threads corresponding to the first M thread occupancy data.
[0155] In one embodiment, the system resource occupation detection device further includes a third acquisition module:
[0156] The third acquisition module is used to acquire total occupancy data according to a preset frequency.
[0157] At the same time, the second acquisition module is also used to acquire the thread stack of the process and determine the thread occupancy data of the system resources of multiple threads of the process when the total occupancy data exceeds the preset threshold for a consecutive preset number of times.
[0158] In one embodiment, the third determination module includes a second determination unit. The second determination unit is used to determine at least the interaction data of the threads corresponding to the first M thread occupancy data, or the preceding steps, in the service association information.
[0159] In one embodiment, the second acquisition module includes a second acquisition unit and a third determination unit, wherein:
[0160] The second acquisition unit is used to acquire a process snapshot of the process when it is determined that the total occupancy data exceeds a preset threshold.
[0161] The third determining unit is used to determine the thread stack of the process based on the process snapshot.
[0162] In one embodiment, the system resource occupancy detection device further includes a sending module, which is used to send service association information corresponding to the first M thread occupancy data.
[0163] Each module in the above-mentioned system resource occupancy detection device can be implemented in whole or in part by software, hardware or a combination thereof. Each of the above-mentioned modules can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute operations corresponding to each of the above modules.
[0164] In an exemplary embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as shown in FIG. Fig. 9 As shown. The computer device includes a processor, a memory, an input / output interface (Input / Output, referred to as I / O) and a communication interface. The processor, the memory and the input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store system resource occupancy detection data. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a system resource occupancy detection method is implemented.
[0165] Those skilled in the art will understand that Fig. 9The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0166] In an exemplary embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and when the processor executes the computer program, the following steps are implemented:
[0167] Step 100: Obtain the total occupancy data of each application process in system resources.
[0168] Step 200: When it is determined that the total occupancy data exceeds a preset threshold, a thread stack of the process is obtained, the thread stack includes business association information, and thread occupancy data of system resources of multiple threads of the process is determined.
[0169] Step 300: Determine the thread numbers of the threads corresponding to the first M threads occupying data in descending order.
[0170] Step 400: Determine the first binary digit of the thread number and the second binary digit of the thread stack number in the thread stack.
[0171] Step 500: Convert the thread numbers of the threads corresponding to the first M thread occupancy data from the first base digit to the second base digit to obtain the corresponding thread stack numbers.
[0172] Step 600: Obtain a service association identifier, and determine service association information corresponding to the first M thread occupancy data from the thread stack based on the service association identifier and the thread stack number.
[0173] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0174] Step 700: Determine the thread number of each thread.
[0175] Step 710: Determine the thread stack number of each thread in the thread stack.
[0176] Step 720: Establishing an association relationship between the thread number and the corresponding thread stack number;
[0177] Step 510: Obtain association relationships.
[0178] Step 511: Based on the thread numbers and association relationships of the threads corresponding to the first M thread occupancy data, search the thread stack for the thread stack number corresponding to the thread number of the thread corresponding to the first M thread occupancy data.
[0179] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0180] Step 110: Obtain total occupancy data according to a preset frequency.
[0181] Step 210: When the total occupancy data exceeds a preset threshold for a consecutive preset number of times, the thread stack of the process is obtained, and thread occupancy data of system resources of multiple threads of the process is determined.
[0182] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0183] Step 220: When it is determined that the total occupancy data exceeds a preset threshold, a process snapshot of the process is obtained.
[0184] Step 230: Determine the thread stack of the process based on the process snapshot.
[0185] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0186] Step 800: Sending service association information corresponding to the first M thread occupancy data.
[0187] In one embodiment, a computer readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented:
[0188] Step 100: Obtain the total occupancy data of each application process in system resources.
[0189] Step 200: When it is determined that the total occupancy data exceeds a preset threshold, a thread stack of the process is obtained, the thread stack includes business association information, and thread occupancy data of system resources of multiple threads of the process is determined.
[0190] Step 300: Determine the thread numbers of the threads corresponding to the first M threads occupying data in descending order.
[0191] Step 400: Determine the first binary digit of the thread number and the second binary digit of the thread stack number in the thread stack.
[0192] Step 500: Convert the thread numbers of the threads corresponding to the first M thread occupancy data from the first base digit to the second base digit to obtain the corresponding thread stack numbers.
[0193] Step 600: Determine the service association information corresponding to the first M thread occupancy data from the thread stack according to the thread stack number.
[0194] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0195] Step 700: Determine the thread number of each thread.
[0196] Step 710: Determine the thread stack number of each thread in the thread stack.
[0197] Step 720: Establishing an association relationship between the thread number and the corresponding thread stack number;
[0198] Step 810: Obtain association relationship.
[0199] Step 811: Based on the thread numbers and association relationships of the threads corresponding to the first M thread occupancy data, determine the thread stack numbers corresponding to the thread numbers of the threads corresponding to the first M thread occupancy data.
[0200] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0201] Step 110: Obtain total occupancy data according to a preset frequency.
[0202] Step 210: When the total occupancy data exceeds a preset threshold for a consecutive preset number of times, the thread stack of the process is obtained, and thread occupancy data of system resources of multiple threads of the process is determined.
[0203] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0204] Step 220: When it is determined that the total occupancy data exceeds a preset threshold, a process snapshot of the process is obtained.
[0205] Step 230: Determine the thread stack of the process based on the process snapshot.
[0206] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0207] Step 800: Sending service association information corresponding to the first M thread occupancy data.
[0208] In one embodiment, a computer program product is provided, comprising a computer program, which, when executed by a processor, implements the following steps:
[0209] Step 100: Obtain the total occupancy data of each application process in system resources.
[0210] Step 200: When it is determined that the total occupancy data exceeds a preset threshold, a thread stack of the process is obtained, the thread stack includes business association information, and thread occupancy data of system resources of multiple threads of the process is determined.
[0211] Step 300: Determine the thread numbers of the threads corresponding to the first M threads occupying data in descending order.
[0212] Step 400: Determine the first binary digit of the thread number and the second binary digit of the thread stack number in the thread stack.
[0213] Step 500: Convert the thread numbers of the threads corresponding to the first M thread occupancy data from the first base digit to the second base digit to obtain the corresponding thread stack numbers.
[0214] Step 600: Determine the service association information corresponding to the first M thread occupancy data from the thread stack according to the thread stack number.
[0215] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0216] Step 700: Determine the thread number of each thread.
[0217] Step 710: Determine the thread stack number of each thread in the thread stack.
[0218] Step 720: Establishing an association relationship between the thread number and the corresponding thread stack number;
[0219] Step 510: Obtain association relationships.
[0220] Step 511: Based on the thread numbers and association relationships of the threads corresponding to the first M thread occupancy data, determine the thread stack numbers corresponding to the thread numbers of the threads corresponding to the first M thread occupancy data.
[0221] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0222] Step 110: Obtain total occupancy data according to a preset frequency.
[0223] Step 210: When the total occupancy data exceeds a preset threshold for a consecutive preset number of times, the thread stack of the process is obtained, and thread occupancy data of system resources of multiple threads of the process is determined.
[0224] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0225] Step 220: When it is determined that the total occupancy data exceeds a preset threshold, a process snapshot of the process is obtained.
[0226] Step 230: Determine the thread stack of the process based on the process snapshot.
[0227] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0228] Step 800: Sending service association information corresponding to the first M thread occupancy data.
[0229] A person of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment method can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, an artificial intelligence (AI) processor, etc., but are not limited to this.
[0230] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.
[0231] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.
Claims
1. A method for detecting system resource occupancy, characterized in that: The system resource occupancy detection method comprises: Get the total occupancy data of each application process in system resources; When it is determined that the total occupancy data exceeds a preset threshold, obtaining a thread stack of the process, the thread stack including service association information, and determining thread occupancy data of the system resources by multiple threads of the process; Determine the thread numbers of the threads corresponding to the first M threads occupying the data in descending order; Determine a first binary digit of the thread number and a second binary digit of the thread stack number in the thread stack; Convert the thread numbers of the threads corresponding to the first M thread occupancy data from the first base digit to the second base digit to obtain the corresponding thread stack numbers; A service association identifier is obtained, and based on the service association identifier and the thread stack number, service association information corresponding to the first M thread occupancy data is determined from the thread stack.
2. The system resource occupancy detection method according to claim 1, characterized in that: The system resource occupancy detection method further includes: determining a thread number for each of the threads; Determine the thread stack number of each of the threads in the thread stack; Establishing an association relationship between the thread number and the corresponding thread stack number; The step of converting the thread numbers of the threads corresponding to the first M thread occupancy data from the first base digit to the second base digit to obtain the corresponding thread stack numbers comprises: Obtaining the association relationship; Based on the thread numbers of the threads corresponding to the first M thread occupancy data and the association relationship, the thread stack number corresponding to the thread numbers corresponding to the first M thread occupancy data is searched in the thread stack.
3. The system resource occupancy detection method according to claim 1, characterized in that: The obtaining of the total occupancy data of each application process in the system resources includes: Acquiring the total occupancy data according to a preset frequency; When the total occupancy data exceeds a preset threshold for a consecutive preset number of times, a thread stack of the process is obtained, and thread occupancy data of the system resources by multiple threads of the process is determined.
4. The system resource occupancy detection method according to claim 1, characterized in that: The determining, from the thread stack according to the thread stack number, the service association information corresponding to the first M thread occupancy data includes: In the service association information, at least the interaction data of the threads corresponding to the first M thread occupancy data, or the preceding steps, are determined.
5. The system resource occupancy detection method according to claim 1, characterized in that: When it is determined that the total occupancy data exceeds a preset threshold, obtaining a thread stack of the process, wherein the thread stack includes business association information, and determining thread occupancy data of the system resources by multiple threads of the process, including: When it is determined that the total occupancy data exceeds a preset threshold, obtaining a process snapshot of the process; Based on the process snapshot, a thread stack of the process is determined.
6. The system resource occupancy detection method according to claim 1, characterized in that: After determining the service association information corresponding to the first M thread occupancy data from the thread stack according to the thread stack number, the method further comprises: The service association information corresponding to the first M thread occupancy data is sent.
7. A system resource occupancy detection device, characterized in that: The system resource occupancy detection device comprises: The first acquisition module is used to obtain the total occupancy data of each application process in the system resources; A second acquisition module is used to acquire a thread stack of the process when it is determined that the total occupancy data exceeds a preset threshold, wherein the thread stack includes business association information and determines thread occupancy data of the system resources by multiple threads of the process; A first determining module is used to determine the thread numbers of the threads corresponding to the first M thread occupancy data sorted in descending order; A second determining module, configured to determine a first binary digit of the thread number and a second binary digit of the thread stack number in the thread stack; A conversion module, used for converting the thread numbers of the threads corresponding to the first M thread occupancy data from the first base digit to the second base digit to obtain the corresponding thread stack numbers; The third determination module is used to obtain a service association identifier, and determine the service association information corresponding to the first M thread occupancy data from the thread stack based on the service association identifier and the thread stack number.
8. The system resource occupancy detection device according to claim 7, characterized in that: The system resource occupancy detection device further comprises: A second determining module, used to determine the thread number of each of the threads; A third determining module, used to determine the thread stack number of each of the threads in the thread stack; An establishing module, used for establishing an association relationship between the thread number and the corresponding thread stack number; The conversion module comprises: A first acquisition unit, configured to acquire the association relationship; The first determining unit is configured to search the thread stack for the thread stack number corresponding to the thread number of the thread corresponding to the first M thread occupancy data based on the thread numbers of the threads corresponding to the first M thread occupancy data and the association relationship.
9. The system resource occupancy detection device according to claim 7, characterized in that: The system resource occupancy detection device further comprises: A third acquisition module, used to acquire the total occupancy data according to a preset frequency; The second acquisition module is further configured to acquire the thread stack of the process and determine thread occupancy data of the system resources by multiple threads of the process when the total occupancy data exceeds a preset threshold for a consecutive preset number of times.
10. The system resource occupancy detection device according to claim 7, characterized in that: The third determination module comprises: The second determining unit is used to determine at least the interaction data of the threads corresponding to the first M thread occupancy data, or the preceding steps in the business association information.
11. The system resource occupancy detection device according to claim 7, characterized in that: The second acquisition module includes: A second acquisition unit, configured to acquire a process snapshot of the process when it is determined that the total occupancy data exceeds a preset threshold; The third determining unit is configured to determine a thread stack of the process based on the process snapshot.
12. The system resource occupancy detection device according to claim 7, characterized in that: The system resource occupancy detection device further comprises: The sending module is used to send the business association information corresponding to the first M thread occupancy data.
13. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.
14. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
15. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
