A system resource monitoring method, device and storage medium
The average value of cloud resources is calculated by iterative recursive formula, which solves the problems of memory and resource waste in existing technologies and achieves efficient average value calculation and system stability.
Patent Information
- Application Number
- CN202111631541.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-28
- Publication Date
- 2025-09-16
- Estimated Expiration
- 2041-12-28
AI Technical Summary
Existing technologies, when calculating the average value of cloud resources, result in excessive memory usage, data out-of-bounds, and resource waste, and are prone to system failures under high load conditions.
An iterative recursive formula is used to calculate the average value, using the previous average result to reduce dependence on historical data, avoid repeatedly loading data into memory, and group calculation of large amounts of data.
It reduces the usage of memory and CPU resources, avoids system overload, and improves computing performance and system security.
Smart Images

Figure CN114491409B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of cloud security monitoring, and in particular to a method, device and storage medium for monitoring system resources. Background Art
[0002] In the field of cloud security monitoring, service providers are often faced with providing clients with monitoring information about their leased cloud resources, such as hosts or servers. Specifically, they need to monitor average CPU usage, memory usage, and disk usage. Typically, the service provider's system servers need to continuously receive massive amounts of data and calculate the average of this data. In the prior art, the most common method for calculating averages is to sum the data, using the following mean definition. This can be achieved through direct brute force code or by invoking a database's average algorithm.
[0003] The mean is defined as: (n is a natural number greater than or equal to 1).
[0004] The disadvantages of using the above average definition method to calculate the average include: when calculating the average of a large amount of data, a large amount of data needs to be loaded into memory, resulting in excessive memory usage and affecting normal business; secondly, summing a large amount of data can easily cause data out of bounds, resulting in erroneous results; and finally, if the data for which the average is required is stored in a third-party component database, such as MySQL or HBase, the frequent need to read historical data for calculation leads to resource waste. Alternatively, if the third-party component's database average algorithm is directly used for calculation, abnormal component resource usage will also occur. Summary of the Invention
[0005] To overcome the above problems in the prior art, embodiments of the present invention provide a method, device, and storage medium for monitoring system resources.
[0006] To achieve the above objectives, a system resource monitoring method is provided, which is used to monitor resource usage of multiple hosts, including:
[0007] Receive the predetermined service parameter value X of the predetermined service parameter X collected and reported by each host at regular intervals n , the predetermined service parameter is related to the resource usage of the host, n is a natural number greater than 0, and n indicates that the reported value is the nth predetermined service parameter value;
[0008] For each host, calculate the current average value E of the predetermined service parameter n , save the calculated average value E n and the average value E nReport to the required node; when n=1, the average value E n =X1; when n is greater than 1, obtain the average value obtained in the previous calculation, and select the mean recursion formula (a) or (b) to calculate the current average value E of the predetermined service parameter based on the number of received predetermined service parameter values that did not participate in the previous average value calculation. n ;
[0009]
[0010]
[0011] Among them, E n-1 is the average value of the first n-1 predetermined service parameter values; E k is the average value of the first k predetermined service parameter values, It is the sum of the k+1th to nth predetermined service parameter values that did not participate in the previous average value calculation.
[0012] Wherein, the monitoring method calculates the current average value E of the predetermined business parameter n Previously also included:
[0013] Determine whether the number of received predetermined service parameter values that did not participate in the previous average value calculation is not greater than 2; if so, use the recursive formula (a) to calculate the current average value E n Otherwise, use the recursive formula (b) to calculate the current average value E n .
[0014] Wherein, the monitoring method, when the number of received predetermined service parameter values that have not participated in the previous average value calculation is 2, uses the recursive formula (a) twice to calculate the current average value E n .
[0015] Among them, the monitoring method, when the number of received predetermined business parameter values that did not participate in the previous average value calculation is greater than 2, divides the predetermined business parameter values that did not participate in the previous average value calculation into multiple groups according to a pre-set quantity threshold, and the number of predetermined business parameter values contained in each group is not greater than the quantity threshold; and uses the recursive formula (b) to calculate the average value for each group.
[0016] Among them, in the monitoring method, the quantity threshold is 20.
[0017] Wherein, in the monitoring method, the predetermined business parameters include one or more of the following parameters: CPU usage, memory usage and hard disk usage.
[0018] Wherein, the monitoring method, using the recursive formula (b) to calculate the average value for each group includes: substituting the average value calculated based on the previous group and the data included in the current group into the recursive formula (b) to calculate the overall average value including the data of the current group.
[0019] In another aspect, a data processing method is provided for receiving and processing data from multiple client hosts, comprising:
[0020] Receive the predetermined service parameter value X of the predetermined service parameter X collected and reported by each host at regular intervals n , n is a natural number greater than 0, n indicates that the reported value is the nth predetermined service parameter value;
[0021] For each host, calculate the current average value E of the predetermined service parameter n , save the calculated average value E n and the average value E n Report to the next node; when n=1, the average value E n =X1; when n is greater than 1, obtain the average value obtained in the previous calculation, and select the mean recursion formula (a) or (b) to calculate the current average value E of the predetermined service parameter based on the number of received predetermined service parameter values that did not participate in the previous average value calculation. n ;
[0022]
[0023]
[0024] Among them, E n-1 is the average value of the first n-1 predetermined service parameter values; E k is the average value of the first k predetermined service parameter values, It is the sum of the k+1th to nth predetermined service parameter values that did not participate in the previous average value calculation.
[0025] On the other hand, a system resource monitoring device is provided for monitoring resource usage of multiple hosts, including a memory and a processor, wherein the memory stores at least one program, and the at least one program is executed by the processor to implement the system resource monitoring method as described.
[0026] On the other hand, a computer-readable storage medium is provided, wherein at least one program is stored in the storage medium, and the at least one program is executed by a processor to implement the method as described above.
[0027] The above technical solution has the following technical effects:
[0028] The technical solution of the embodiment of the present invention, when implementing system monitoring or data processing, when it is necessary to calculate the average value of massive data, uses an iterative recursive method to calculate the average value, avoiding repeatedly reading a large amount of historical data into the memory, and directly using the average value calculated last time. It is only necessary to read a number of data that has not yet been calculated and the average value of the last time into the memory for calculation, so that the memory usage can be controlled within a predetermined range, such as a constant range, thereby avoiding memory exhaustion; in addition, by reducing the dependence on historical data, the use of CPU resources is reduced; since it is not necessary to add all the current and previously received data when calculating the average value, the risk of data crossing the boundary can be reduced; in addition, the technical solution of the embodiment of the present invention improves the computing performance compared with the average value calculation scheme of the prior art because it fully utilizes the last calculation result. Using the technical solution of the embodiment of the present invention to perform system monitoring or data processing can avoid the system server from malfunctioning or freezing due to exhaustion of computing resources due to system overload, thereby improving system security. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] Figure 1 A flowchart of a method for monitoring system resources according to an embodiment of the present invention;
[0030] Figure 2 and Figure 3 This is an example of a business scenario in which security monitoring is performed using the system resource monitoring method according to an embodiment of the present invention;
[0031] Figure 4 Schematic diagram of an example of data processing using the average value calculation method of the prior art and the iterative average value calculation method of the embodiment of the present invention in the absence of congestion;
[0032] Figure 5 Schematic diagram of an example of data processing using the average value calculation method of the prior art and the iterative average value calculation method of the embodiment of the present invention in a congested situation;
[0033] Figure 6 Schematic diagram of an algorithm flow for calculating the average value of a service parameter value in an embodiment of the present invention;
[0034] Figure 7 Schematic diagram of the structure of a system resource monitoring device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0035] To further illustrate various embodiments, the present invention is provided with accompanying drawings. These drawings form part of the present disclosure and are primarily used to illustrate the embodiments and, in conjunction with the relevant description in the specification, to explain the operating principles of the embodiments. By referring to these drawings, one of ordinary skill in the art will understand other possible embodiments and the advantages of the present invention. The components in the figures are not drawn to scale, and similar reference numerals are generally used to represent similar components.
[0036] The present invention will now be further described with reference to the accompanying drawings and specific embodiments.
[0037] Example 1:
[0038] Figure 1 The flowchart of the method for monitoring system resources according to one embodiment of the present invention is as follows. The method for monitoring system resources according to one embodiment of the present invention is used to monitor resource usage of multiple hosts, and the method includes:
[0039] Step S1: receiving the predetermined service parameter value X of the predetermined service parameter X collected and reported by each host at regular intervals. n , the predetermined service parameter is related to the resource usage of the host, n is a natural number greater than 0, and n indicates that the reported value is the nth predetermined service parameter value;
[0040] Step S2: Calculate the current average value E of the predetermined service parameter for each host. n , save the calculated average value E n and the average value E n Report to the next node; when n=1, the average value E n =X1; when n is greater than 1, obtain the average value obtained in the previous calculation, and select the mean recursion formula (a) or (b) to calculate the current average value E of the predetermined service parameter based on the number of received predetermined service parameter values that did not participate in the previous average value calculation. n ;
[0041]
[0042]
[0043] Among them, E n-1 is the average value of the first n-1 predetermined service parameter values; E k is the average value of the first k predetermined service parameter values, It is the sum of the k+1th to nth predetermined service parameter values that did not participate in the previous average value calculation.
[0044] The above formula (a) is obtained by the following iterative recursive formula (1) for calculating the average value, and the formula (b) is obtained by the following iterative recursive formula (2) for calculating the average value.
[0045]
[0046]
[0047] Furthermore, when calculating the current average value E of the predetermined service parameter n The method also includes: determining whether the number of the received predetermined service parameter values that did not participate in the previous average value calculation is not greater than 2; if so, using the recursive formula (a) to calculate the current average value E n Otherwise, use the recursive formula (b) to calculate the current average value E n When the number of received predetermined service parameter values that have not participated in the previous average value calculation is 2, the recursive formula (a) is used twice to calculate the current average value E. n When the number of received predetermined service parameter values that were not included in the previous average value calculation is greater than 2, the predetermined service parameter values that were not included in the previous average value calculation are divided into multiple groups according to a predetermined number threshold, with the number of predetermined service parameter values included in each group not exceeding the number threshold; and the average value is calculated for each group using the recursive formula (b). Preferably, the number threshold is 20.
[0048] Figure 2 and Figure 3 This is an example of a business scenario in which security monitoring is performed using the system resource monitoring method according to an embodiment of the present invention.
[0049] In an actual business scenario example, the cloud service provider provides the cloud service user with the performance parameters of the system resources rented or used by the cloud service user, such as the average CPU usage, memory usage and / or hard disk usage. The cloud service provider's system server uses the agent installed in the host rented or used by the cloud service user to collect and report the host's current CPU usage, memory usage and / or hard disk usage, and then calculates the average CPU usage, memory usage and / or hard disk usage of each corresponding host, and then pushes this average to the user, such as to each business system. Figure 2 For example, the system server receives the service parameter values reported by each agent through a message component. For example, the service system displays the average value to the user through a graphical user interface after receiving the average value.
[0050] like Figure 2 、 Figure 3As shown, in this business scenario, an agent is installed on a PC or server host. This agent continuously collects the real-time CPU usage, memory usage, and hard disk usage of the host operating system at regular intervals and reports this information to the system server. For example, the agent periodically reports this collected business parameter data to the system server's message component. After receiving the business parameter data reported by the agent, the system server analyzes the data and calculates the average CPU usage, memory usage, and hard disk usage for the current agent environment in real time. These average values are stored in a database or pushed to other business systems.
[0051] like Figure 3 In a specific application scenario, there are a large number of hosts to be monitored, and a large number of agents. The frequency of agent reporting is relatively high, and it is possible to report every 1 minute or several minutes. This results in a large amount of data being reported to the system server. Using the average value calculation method of the existing technology, under normal load conditions, the processing on the server can calculate the average value result. However, under high load conditions, the server may not process in time, and the CPU resources and memory resources required for code execution will soar, which will eventually lead to untimely push data, or even inability to obtain computing resources, resulting in the inability to continue pushing data. In abnormal conditions, if the system server stops running for a period of time, a lot of historical data will accumulate and not be processed. At this time, it is necessary to quickly calculate the overall average value of the current situation. Using the average value definition method of the existing technology to calculate the average value is usually not able to achieve fast calculation of the average value. However, using the monitoring method of the embodiment of the present invention, when calculating the resource average value, an average value calculation method based on the iteration method is used, as shown in formula (1) and formula (2), the average value calculated last time can be used, without the need to sum up all the corresponding data values received to calculate the average value each time; the load of the system server is reduced, relevant system resources are saved, and system performance is improved.
[0052] Figure 4 、 Figure 5 The diagram is a schematic diagram of resource data processing examples using the average value calculation method of the prior art and the iterative average value calculation method in the embodiment of the present invention.
[0053] Figure 4 The figure shows the situation where the reported data is not congested, that is, the average value can be calculated immediately after each data is reported, and there is no historical data accumulated due to unprocessed data. Figure 4, avg represents the average value calculated by the existing algorithm, and AVG represents the average value calculated using the iterative average value calculation method formula (a) or (1) in the embodiment of the present invention. Regarding the calculation formula of AVG, AVG on the right side of the formula is the average value obtained by the previous calculation. an represents the data reported in sequence, such as a1, a2, a3, a4, a5, and a6. When there is only data a1, avg = a1, AVG = a1. After receiving data a2, avg=(a1+a2) / 2, AVG=(a2-AVG) / 2+AVG; that is, the average value obtained by the first calculation is used to iteratively calculate the average value of the two data; after receiving data a3, avg=(a1+a2+a3) / 2, AVG=(a3-AVG) / 3+AVG, and AVG on the right side of the formula is the average value obtained by the previous calculation, that is, the second calculation; after receiving data a4, avg=(a1+a2+a3+a4) / 2, AVG=(a4-AVG) / 4+AVG, and AVG on the right side of the formula is the average value obtained by the previous calculation, that is, the third calculation. And so on. Figure 4 shown.
[0054] Figure 4 There is no data congestion. In actual application scenarios, due to the huge amount of data to be processed, it is usually impossible for the system server to immediately calculate the average CPU usage, memory usage, and hard disk usage reported by each agent. Therefore, there is often data congestion. That is, after the agent reports the data, the system server cannot process it immediately, but temporarily stores the data for subsequent processing. For each agent, based on the number of predetermined business parameter values that have been received and not participated in the previous average value calculation, the formula iterative average formula (1) or (2) can be selected for calculation. If this number is 1, it corresponds to the previous non-congested situation. If the number is 2, formula (1) can be used for calculation, and formula (1) needs to be used twice. If the number is greater than 2, formula (2), i.e. formula (b), can be used for calculation.
[0055] The inventors of this application analyzed the number of operations required, space usage, risk of out-of-bounds, and algorithm time of existing algorithms, formulas (1) and (2), and determined the applicable scenarios of the mean recursive formulas (1) and (2) based on the advantages of the mean value algorithm used in the embodiments of the present invention. Specifically, see Tables 1 and 2 below.
[0056]
[0057] Table 1
[0058] Table 2 is an estimate of the algorithm time: 1 multiplication and division calculation time = 10 addition and subtraction calculation time,
[0059] The numbers in the table represent the number of additions and subtractions required in this case. The greater the number, the more computing time is required.
[0060] Mean formula Mean recursion formula 1 Mean recursion formula 2 Single input data volume 1 1 12 32 Single input data volume 2 11 24 33 Single input data volume 3 12 36 34 Single input data volume 4 13 48 35 Single input data volume 5 14 50 36
[0061] Table 2
[0062] It is easy to see from the above table that the mean formula defined by the mean in the prior art requires fewer additions and subtractions, but it has the performance problems mentioned above. When the data volume is 1 and 2, the number of additions and subtractions required by recursive formula 1 is less, and recursive formula 1 is suitable. When the data volume is greater than 2, the mean recursive formula 2 is suitable. However, through operational experiments, it can be seen that for the mean recursive formula 2, the size of the data in each group or batch is also limited. The larger the data volume, the greater the risk of abnormal addition operations. Preferably, additions and subtractions within 20 numbers are considered normal. That is, preferably, when using the mean recursive formula (2) to calculate the average value, the number of data calculated each time, that is, the data length, does not exceed 20. If it exceeds 20, the data can be grouped into groups of 20 data or less than 20 data.
[0063] Figure 5 This is an example of resource data processing in the case of data congestion. In this example, a situation is given where the business parameter data for which the average value is to be calculated exceeds 20. The average value calculation process of the method using the prior art and the method using the mean recursive formula (2) of the embodiment of the present invention is compared. In the embodiment of the present invention, the data to be processed are divided into groups of 20, and the average value of the first 20 data is first calculated using the recursive formula (2). Then, this average value is used to continue using the recursive formula (2) to calculate the overall average value after adding the next group of 20 data. Similarly, the previous average value is used to calculate the overall average value after adding the next group of 20 data.
[0064] like Figure 5In this case of congested data, when calculating the average using conventional methods, each calculation of avg requires summing the existing data and then dividing it by the data length, i.e., the number of data. However, using the method of the present invention, the average value obtained in the previous calculation only needs to be calculated once. Taking the first group as an example, where n = 21, the average value of 21 data points needs to be calculated. The congested data points are a2, a3, to a21. The conventional method calculates avg by first calculating (a1 + a2) / 2, then (a1 + a2 + a3) / 3, then (a1 + a2 + a3 + a4) / 4, ... (a1 + a2 + a3 + a4 + ... a21) / 21, requiring 20 calculations. However, the method of the present invention only requires one calculation: AVG = (1 / 21)a1 + (a2 + ... + a21) / 21. As the amount of data increases, conventional methods calculate avg by summing all the data points and then calculating the average each time. For n data points, the summation of all data points needs to be calculated n times. The method of the embodiment of the present invention requires much fewer calculations and does not require repeated calculation of previously calculated data. Instead, it only requires multiple calculations using AVG = (k / n)AVG + (a[k+1] + ... + a[n]) / n. The AVG on the right side of the formula is the average value of the k previously calculated data, a[k+1] is the k+1th data, and a[n] is the nth data. Specifically, see Figure 5 shown.
[0065] From the above analysis, it can be seen that when calculating the average value using the existing method, all the data to be summed each time must be loaded into the memory before the calculation can be performed, which consumes loading resources. When there is too much data, there may be insufficient memory required to load all the data, which makes it impossible to perform the calculation. However, using the average value recursive formula of the embodiment of the present invention, it is not necessary to load all the data into the memory at once; and if there is an average value obtained from the last calculation, the result can be calculated directly. The memory only needs to store the last average value result and the current data. If there is no last average value result, but there is a large amount of data, the average value results can also be calculated in batches. The memory only needs to store each allocated data and the last average value. If there is a last average value result and it is also congested with a lot of historical data, the above-mentioned batch calculation method can also be used.
[0066] Regarding CPU usage, existing methods require calculating the sum of all data points each time, resulting in wasted repeated calculations. As data continues to be reported, the number of data points required for calculation increases by one, requiring more CPU resources each time. However, using the average value recursion formula of the present invention, the amount of calculation required each time is fixed, and the previous average value result can be reused. Therefore, using the average value recursion formula of the present invention saves CPU usage.
[0067] Figure 6This is a flow chart of an algorithm for calculating the average value of a service parameter value in one embodiment of the present invention. In this example, the algorithm variable definitions are shown in Table 3:
[0068] variable name default value illustrate n 0 The number of iterations is incremented by 1 each time the data is calculated. prev 0 Store the last calculated average value BATCH_SIZE 20 Threshold value, when it exceeds this value, the average formula is used for batch calculation
[0069] Table 3
[0070] Algorithm input: input data
[0071] Algorithm output: the average value of the current system after adding new data
[0072] Algorithm description: Input n numbers and calculate the overall average value of the current system.
[0073] Step 1, initialize prev=0, n=0;
[0074] Step 2: Determine the size of the input data, i.e. the length of the data;
[0075] When the input data volume = 0, the previous average value prev is returned, which defaults to 0, and jumps to step 4;
[0076] When the input data volume = 1, use the mean recursion formula 1 to calculate the average value and jump to step 3;
[0077] When the input data volume = 2, it is divided into 2 times, the average value is calculated using the mean recursion formula 1, and then jump to step 3;
[0078] When the input data volume is greater than 2, first determine whether grouping is required, that is, whether the input data volume is greater than the data volume threshold BATCH_SIZE. If not, no grouping is required, and the mean recursion formula (2) is directly used to calculate the average value. If so, grouping is required, and grouping is performed first, and then the mean recursion formula (2) is used to calculate the average value of each group, and then jump to step 3. When the mean recursion formula (2) is used to calculate the average value of each group, the next group calculated uses the average value calculated by the previous group and the data of its own group to calculate the overall average value.
[0079] Step 3, update prev = calculation result, n increments;
[0080] Step 4, end.
[0081] Example 3:
[0082] The embodiment of the present invention further provides a data processing method for receiving and processing data from multiple client hosts, comprising: receiving a predetermined service parameter value X of a predetermined service parameter X regularly collected and reported by each host; n, n is a natural number greater than 0, n indicates that the reported value is the nth predetermined service parameter value; for each host, calculate the current average value E of the predetermined service parameter n , save the calculated average value E n and the average value E n Report to the next node; when n=1, the average value E n =X1; when n is greater than 1, obtain the average value obtained in the previous calculation, and select the mean recursion formula (a) or (b) to calculate the current average value E of the predetermined service parameter based on the number of received predetermined service parameter values that did not participate in the previous average value calculation. n ;
[0083]
[0084]
[0085] Among them, E n-1 is the average value of the first n-1 predetermined service parameter values; E k is the average value of the first k predetermined service parameter values, It is the sum of the k+1th to nth predetermined service parameter values that did not participate in the previous average value calculation.
[0086] Furthermore, when calculating the current average value E of the predetermined service parameter n The method also includes: determining whether the number of the received predetermined service parameter values that did not participate in the previous average value calculation is not greater than 2; if so, using the recursive formula (a) to calculate the current average value E n Otherwise, use the recursive formula (b) to calculate the current average value E n Specifically, when the number of received predetermined service parameter values that did not participate in the previous average value calculation is 2, the recursive formula (a) is used twice to calculate the current average value E. n . Preferably, when the number of received predetermined business parameter values that did not participate in the previous average value calculation is greater than 2, the predetermined business parameter values that did not participate in the previous average value calculation are divided into multiple groups according to a preset quantity threshold, and the number of predetermined business parameter values contained in each group is not greater than the quantity threshold; the average value is calculated for each group using the recursive formula (b). Preferably, the quantity threshold is 20. Wherein, calculating the average value for each group using the recursive formula (b) includes: substituting the average value calculated based on the previous group and the data contained in the current group into the recursive formula (b) to calculate the overall average value containing the data of the current group.
[0087] The data processing method of the present embodiment utilizes a mean recursion formula to calculate the average of corresponding business parameters, reusing the previous average value, thus avoiding the repeated summation required by conventional mean calculation methods. It is not necessary to load all data into memory at once; if the previous average value is available, the result can be directly calculated. The memory only needs to store the previous average value and the current data. If the previous average value is not available, but a large amount of data is available, the average results can be calculated in batches. The memory only needs to store the data for each allocation and the last average value. If the previous average value is available and there is a large amount of historical data, the batch calculation method can also be used. Furthermore, the data processing method of the present embodiment maintains a fixed amount of calculations each time, reusing the previous average value. Therefore, the use of the mean recursion formula of the present embodiment saves CPU usage. When dynamically calculating the average of an ever-increasing amount of data, the data processing method of the present embodiment can prevent system server failures or crashes due to exhaustion of computing resources caused by system overload, thereby improving system security.
[0088] Example 4:
[0089] The present invention also provides a system resource monitoring device for monitoring resource usage of multiple hosts, such as Figure 7 As shown, the device includes a processor 701, a memory 702, a bus 703, and a computer program stored in the memory 702 and executable on the processor 701. The processor 701 includes one or more processing cores. The memory 702 is connected to the processor 701 via the bus 703. The memory 602 is used to store program instructions. When the processor executes the computer program, the steps of the above-mentioned system resource monitoring method embodiment of the present invention are implemented.
[0090] Furthermore, as an executable solution, the system resource monitoring device may be a computer unit, which may be a computing device such as a desktop computer, laptop, PDA, or cloud server. The computer unit may include, but is not limited to, a processor and memory. Those skilled in the art will appreciate that the aforementioned computer unit structure is merely an example of a computer unit and does not constitute a limitation of the computer unit. The computer unit may include more or fewer components than those described above, or a combination of certain components, or different components. For example, the computer unit may also include input / output devices, network access devices, buses, etc., which are not limited in the embodiments of the present invention.
[0091] Furthermore, as an executable solution, the processor may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or any conventional processor, etc. The processor is the control center of the computer unit and connects various parts of the entire computer unit using various interfaces and lines.
[0092] The memory can be used to store the computer programs and / or modules, and the processor implements the various functions of the computer unit by running or executing the computer programs and / or modules stored in the memory, and calling the data stored in the memory. The memory can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system and at least one application required for a function; the data storage area can store data created based on the use of the mobile phone, etc. In addition, the memory can include a high-speed random access memory, and can also include a non-volatile memory, such as a hard disk, a memory, a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), at least one disk storage device, a flash memory device, or other volatile solid-state storage device.
[0093] Embodiment 5:
[0094] The present invention also provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the above method in the embodiment of the present invention are implemented.
[0095] If the module / unit integrated in the computer unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present invention implements all or part of the process in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium. When the computer program is executed by a processor, it can implement the steps of each of the above-mentioned method embodiments. Among them, the computer program includes computer program code, which can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM) and software distribution medium. It should be noted that the content contained in the computer-readable medium can be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction.
[0096] Although the present invention has been particularly shown and described in conjunction with preferred embodiments, it will be understood by those skilled in the art that various changes in form and details may be made to the present invention without departing from the spirit and scope of the invention as defined in the appended claims, and all such changes are within the scope of protection of the present invention.
Claims
1. A system resource monitoring method for monitoring resource usage of multiple hosts, characterized in that: include: Receive the predetermined service parameter value X of the predetermined service parameter X collected and reported by each host at regular intervals n , the predetermined service parameter is related to the resource usage of the host, n is a natural number greater than 0, and n indicates that the reported value is the nth predetermined service parameter value; For each host, calculate the current average value E of the predetermined service parameter n , save the calculated average value E n and the average value E n Report to the required node; when n=1, the average value E n =X1; when n is greater than 1, obtain the average value obtained in the previous calculation, and select the mean recursion formula (a) or (b) to calculate the current average value E of the predetermined service parameter based on the number of received predetermined service parameter values that did not participate in the previous average value calculation. n ; Among them, E n-1 is the average value of the first n-1 predetermined service parameter values; E k is the average value of the first k predetermined service parameter values, The sum of the k+1th to nth predetermined service parameter values that did not participate in the previous average value calculation; Wherein, when calculating the current average value E of the predetermined service parameter n Previously also included: Determine whether the number of received predetermined service parameter values that did not participate in the previous average value calculation is not greater than 2; if so, use the recursive formula (a) to calculate the current average value E n Otherwise, use the recursive formula (b) to calculate the current average value E n .
2. The monitoring method according to claim 1, characterized in that: When the number of received predetermined service parameter values that did not participate in the previous average value calculation is 2, the recursive formula (a) is used twice to calculate the current average value E n .
3. The monitoring method according to claim 1, characterized in that: When the number of received predetermined service parameter values that did not participate in the previous average value calculation is greater than 2, dividing the predetermined service parameter values that did not participate in the previous average value calculation into a plurality of groups according to a preset number threshold, and the number of predetermined service parameter values included in each group is not greater than the number threshold; The mean value was calculated for each group using the recursive formula (b).
4. The monitoring method according to claim 3, characterized in that: The quantity threshold is 20.
5. The method according to claim 1, wherein The predetermined service parameters include one or more of the following parameters: CPU usage, memory usage, and hard disk usage.
6. The method according to claim 3, characterized in that Calculating the average value for each group using the recursive formula (b) includes: Substitute the average value calculated based on the previous group and the data included in this group into the recursive formula (b) to calculate the overall average value including the data of this group.
7. A data processing method for receiving and processing data from multiple client hosts, characterized in that: include: Receive the predetermined service parameter value X of the predetermined service parameter X collected and reported by each host at regular intervals n , n is a natural number greater than 0, n indicates that the reported value is the nth predetermined service parameter value; For each host, calculate the current average value E of the predetermined service parameter n , save the calculated average value E n and the average value E n Report to the next node; when n=1, the average value E n =X1; when n is greater than 1, obtain the average value obtained in the previous calculation, and select the mean recursion formula (a) or (b) to calculate the current average value E of the predetermined service parameter based on the number of received predetermined service parameter values that did not participate in the previous average value calculation. n ; Among them, E n-1 is the average value of the first n-1 predetermined service parameter values; E k is the average value of the first k predetermined service parameter values, The sum of the k+1th to nth predetermined service parameter values that did not participate in the previous average value calculation; Wherein, when calculating the current average value E of the predetermined service parameter n Previously also included: Determine whether the number of received predetermined service parameter values that did not participate in the previous average value calculation is not greater than 2; if so, use the recursive formula (a) to calculate the current average value E n Otherwise, use the recursive formula (b) to calculate the current average value E n .
8. A system resource monitoring device for monitoring resource usage of multiple hosts, characterized in that: The system comprises a memory and a processor, wherein the memory stores at least one program, and the at least one program is executed by the processor to implement the system resource monitoring method according to any one of claims 1 to 5.
9. A computer-readable storage medium, characterized in that The storage medium stores at least one program, and the at least one program is executed by a processor to implement the method according to any one of claims 1 to 5.
Citation Information
Patent Citations
Resource monitoring method and device and electronic equipment
CN109840182A
Early warning method for server hardware, equipment and storage medium
CN110674003A