A method, device and medium for obtaining cloud platform CPU usage
By obtaining the use time of the cloud platform node list and its core, and combining the impact coefficient to calculate the CPU usage rate of the cloud platform, the problem of inaccurate calculation results in the existing technology is solved, and more accurate resource management and evaluation is achieved.
Patent Information
- Application Number
- CN202211046687.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-08-30
- Publication Date
- 2025-08-19
- Estimated Expiration
- 2042-08-30
AI Technical Summary
In the prior art, the calculation method of the CPU usage rate of cloud platform cannot truly reflect the differences in the capabilities of multiple architecture servers and different cores through the average value, resulting in inaccurate calculation results.
Obtain the node list of the cloud platform and its core, and calculate the CPU usage rate of the cloud platform through the usage time within the preset time and the impact coefficient, and refine the CPU core usage of the node.
It provides a more accurate cloud platform CPU usage rate, which can truly reflect the platform's load and resource allocation, and helps the operation and maintenance and operational ends to effectively manage resources.
Smart Images

Figure CN115309609B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of cloud platform technology, and in particular to a method, device, and medium for obtaining the CPU usage of a cloud platform. Background Art
[0002] As OpenStack matures and its services continue to expand, the number of servers has grown from a few or a dozen to hundreds or even thousands. In cloud platform operations and maintenance, central processing unit (CPU) utilization is a crucial metric. This metric can be used to identify bottlenecks in the platform's controller computing resources and assess overall computing resources, enabling virtual machine migration and system expansion.
[0003] Currently, cloud platform CPU utilization is calculated by taking the average CPU utilization of all nodes and using this average as the cloud platform's CPU utilization. However, cloud platforms typically include servers with various architectures, and the core capabilities of the CPUs of different servers vary significantly. Even within the same server, core capabilities can vary significantly. For example, one server's CPU may have one core, while another may have six. Using the average as the utilization of both servers does not accurately reflect the cloud platform's CPU utilization.
[0004] It can be seen from this that how to more realistically reflect the CPU usage of the cloud platform is a technical problem that people in this field urgently need to solve. Summary of the Invention
[0005] The purpose of this application is to provide a method, device and medium for obtaining the CPU usage of a cloud platform, so as to more realistically reflect the CPU usage of the cloud platform.
[0006] To solve the above technical problems, this application provides a method for obtaining the CPU usage of a cloud platform, including:
[0007] Obtain a list of nodes on the cloud platform and the kernel of each node;
[0008] Obtaining the usage time of the core of each node within a preset time period;
[0009] The cloud platform CPU usage rate is determined according to the usage duration and the preset duration.
[0010] Preferably, the cloud platform CPU usage includes the CPU usage of the operation and maintenance end or the CPU usage of the operation end.
[0011] Preferably, when the cloud platform CPU usage is the operation and maintenance end CPU usage, determining the operation and maintenance end CPU usage according to the usage duration and the preset duration includes:
[0012] Obtaining a control node and a computing node from the nodes;
[0013] Setting a first influence coefficient for the control node and setting a second influence coefficient for the computing node;
[0014] The CPU usage rate of the operation and maintenance end is determined according to the usage time, the preset time, the first impact coefficient, and the second impact coefficient.
[0015] Preferably, determining the CPU usage rate of the operation and maintenance end according to the usage duration, the preset duration, the first impact coefficient, and the second impact coefficient includes:
[0016] Respectively obtaining a first product result of the usage time corresponding to each core of each control node and the first influence coefficient, and a second product result of the usage time corresponding to each core of each computing node and the second influence coefficient;
[0017] Obtaining a sum of the first multiplication results and a sum of the second multiplication results;
[0018] Adding a sum of the first multiplication results and a sum of the second multiplication results to obtain a first total usage time of all the cores;
[0019] Obtaining a third product result of the preset duration and the first influence coefficient for each core of each control node, and obtaining a fourth product result of the preset duration and the second influence coefficient for each core of each computing node;
[0020] Obtaining a sum of the third multiplication results and a sum of the fourth multiplication results;
[0021] adding a sum of the third multiplication results and a sum of the fourth multiplication results to obtain a first total allocated duration used by all the cores;
[0022] Obtaining a first ratio of the first total usage time to the first total allocation time;
[0023] The first ratio is used as the CPU usage of the operation and maintenance end.
[0024] Preferably, the first influence coefficient includes a plurality of sub-influence coefficients, wherein the sub-influence coefficients are set according to the control nodes of different roles.
[0025] Preferably, when the cloud platform CPU usage rate is the operation end CPU usage rate, determining the operation end CPU usage rate according to the usage duration and the preset duration includes:
[0026] Obtaining the usage time corresponding to each core of each computing node respectively;
[0027] Adding the usage durations corresponding to the cores of the computing nodes to obtain a second total usage duration of all the cores of all the computing nodes;
[0028] Get the total number of cores of all the computing nodes;
[0029] Obtaining a product of a total number of cores of all the computing nodes and the preset duration to obtain a second total allocated duration used by all the cores of all the computing nodes;
[0030] Obtaining a second ratio of the second total usage time to the second total allocation time;
[0031] The second ratio is used as the CPU usage of the operation end.
[0032] Preferably, obtaining a list of nodes of the cloud platform and the kernel of each node includes:
[0033] Collecting monitoring data through a client; wherein the monitoring data includes at least a list of nodes of the cloud platform, a kernel of each of the nodes, and the usage time of the kernel of each of the nodes within the preset time period;
[0034] Storing the monitoring data in a time series database;
[0035] Upon receiving an instruction to obtain a list of nodes of the cloud platform and a kernel of each node, obtaining the list of nodes of the cloud platform and a kernel of each node from the time series database;
[0036] Correspondingly, obtaining the usage time of the core of each node within a preset time period includes:
[0037] When an instruction to obtain the usage time of the core of each node within the preset time is received, the usage time of the core of each node within the preset time is obtained from the time series database.
[0038] In order to solve the above technical problems, the present application also provides a device for obtaining the CPU usage of a cloud platform, including:
[0039] A first acquisition module is used to obtain a list of nodes of the cloud platform and the kernel of each node;
[0040] A second acquisition module is used to obtain the usage time of the core of each node within a preset time period;
[0041] A determination module is used to determine the CPU usage of the cloud platform according to the usage time and the preset time.
[0042] In order to solve the above technical problems, the present application also provides a device for obtaining the CPU usage of a cloud platform, including:
[0043] memory for storing computer programs;
[0044] The processor is used to implement the steps of the above-mentioned method for obtaining the CPU usage of the cloud platform when executing the computer program.
[0045] In order to solve the above technical problems, the present application also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the above-mentioned method for obtaining the CPU usage of the cloud platform are implemented.
[0046] The method for obtaining the cloud platform CPU usage provided by this application includes obtaining a list of cloud platform nodes and the cores of each node; obtaining the usage time of each node's core within a preset time period; and determining the cloud platform CPU usage based on the usage time and the preset time period. Compared to the previous method of taking the average of the CPU usage of all nodes as the cloud platform CPU usage, the method provided by this application refines the node's CPU usage to the usage of the node's CPU cores, and determines the cloud platform CPU usage based on the node's CPU core usage, making the obtained cloud platform CPU usage more accurate.
[0047] In addition, the present application also provides a device for obtaining the CPU usage rate of a cloud platform and a computer-readable storage medium, which have the same or corresponding technical features as the above-mentioned method for obtaining the CPU usage rate of a cloud platform, and the effect is the same as above. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] In order to more clearly illustrate the embodiments of the present application, the following is a brief introduction to the drawings required for use in the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0049] Figure 1 A flowchart of a method for obtaining the CPU usage of a cloud platform provided in an embodiment of the present application;
[0050] Figure 2A structural diagram of an apparatus for obtaining the CPU usage of a cloud platform provided in one embodiment of the present application;
[0051] Figure 3 A structural diagram of an apparatus for obtaining the CPU usage of a cloud platform provided in another embodiment of the present application;
[0052] Figure 4 A schematic diagram of an application scenario of a method for calculating the CPU usage of a cloud platform provided in an embodiment of the present application. DETAILED DESCRIPTION
[0053] The following will be combined with the accompanying drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are only part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.
[0054] The core of this application is to provide a method, device and medium for obtaining the CPU usage of a cloud platform, which is used to more realistically reflect the CPU usage of the cloud platform.
[0055] As OpenStack matures and its services continue to expand, the number of servers has grown from a few or a dozen to hundreds or even thousands. In cloud platform operations and maintenance, overall CPU utilization is a crucial metric. This metric can be used to identify bottlenecks in the platform's controller computing resources and, as a guide, assess overall computing resources, enabling virtual machine migration and system expansion.
[0056] The node CPU usage is divided into user, system, nice, idle, iowait, irq, and softirq usage. However, the CPU usage here refers to the total CPU usage, which is the sum of user CPU usage, system CPU usage, and other CPU usage. The total usage is also calculated for the nodes of the cloud platform. Currently, the overall CPU usage of the cloud platform is calculated by calculating the CPU usage of all nodes and taking the average. For example, if there are n nodes in the cloud platform and the CPU usage is usage[1], usage[2], ..., usage[n], then the overall CPU usage of the cloud platform is ∑usage[i] / n, where i = 1, 2, 3, ..., n. However, this method has little reference value in actual production environments. On the one hand, the usage of cloud platform control nodes and computing nodes has different meanings. If the same CPU usage is 90%, if it is a control node, it means that the cloud platform is consuming too many resources and needs to locate the problem or add resources. If it is a computing node, it means that the system has no resources for users to apply. On the other hand, CPU performance varies significantly across servers with various architectures, and even the core capabilities of the same server can vary significantly. Therefore, calculating average utilization is of limited value to users. Therefore, this application uses different calculation methods for different users, prioritizes key areas, and refines CPU utilization down to the core level, ensuring that the calculated CPU utilization reflects the cloud platform's true load and resource allocation.
[0057] In order to enable those skilled in the art to better understand the present application, the present application is further described in detail below with reference to the accompanying drawings and specific implementation methods. Figure 1 A flowchart of a method for obtaining the CPU usage of a cloud platform provided in an embodiment of the present application is shown as follows: Figure 1 As shown, the method includes:
[0058] S10: Obtain the node list of the cloud platform and the kernel of each node;
[0059] S11: Obtain the usage time of the core of each node within a preset time period;
[0060] S12: Determine the cloud platform CPU usage rate according to the usage time and the preset time.
[0061] A cloud platform is usually composed of multiple servers, and each server can be considered as a node of the cloud platform. Assuming that the cloud platform is composed of 3 servers, the node list obtained is node1, node2, and node3. For each server, there are large differences in CPU performance, and for the same server, there may also be large differences in the number of CPU cores. In order to be able to more accurately obtain the cloud platform CPU utilization rate, this embodiment calculates the cloud platform CPU utilization rate based on the CPU core situation. Therefore, after obtaining the node list of the cloud platform, the cores of each node are further obtained. Taking node1, node2, and node3 as an example, it is assumed that the CPU cores obtained are 4, 4, and 8 respectively.
[0062] Get the usage time of the core of each node within the preset time. There is no limit on the specific value of the preset time. For the convenience of calculation, the preset time is selected as 1s, that is, the usage time of the core of each node in the unit time is obtained. Taking node node1 as an example, it is assumed that the usage time of the 4 CPUs in the unit time is time[1][1], time[1][2], time[1][3], time[1][4]. In implementation, the usage time of each CPU can be obtained at the same time and in the same time window. After obtaining the node list of the cloud platform, the core of each node and the usage time of the core of each node in the preset time, these values can be obtained when it is necessary to calculate the CPU usage of the cloud platform; these values can also be obtained in advance and stored in the database. When calculating the CPU of the cloud platform, these data can be directly obtained from the database.
[0063] The method for obtaining the cloud platform CPU usage provided in this embodiment includes obtaining a list of cloud platform nodes and the cores of each node; obtaining the usage time of each node's core within a preset time period; and determining the cloud platform CPU usage based on the usage time and the preset time period. Compared to the previous method of taking the average of the CPU usage of all nodes as the cloud platform CPU usage, the method provided in this application refines the node's CPU usage to the usage of the node's CPU core, and determines the cloud platform CPU usage based on the node's CPU core usage, making the obtained cloud platform CPU usage more accurate.
[0064] In order to cope with different scenarios, in implementation, the preferred implementation method is that the cloud platform CPU usage includes the CPU usage of the operation and maintenance end or the CPU usage of the operation end.
[0065] The purpose of calculating CPU usage on the operation and maintenance side is to understand the performance of cloud platform nodes and facilitate the use of operation and maintenance; the purpose of calculating CPU usage on the operation side is to understand the resource usage of tenants and provide guidance for operations such as resource application.
[0066] In practice, in order to obtain the CPU usage rate of the operation and maintenance end, a preferred implementation method is that, when the CPU usage rate of the cloud platform is the CPU usage rate of the operation and maintenance end, determining the CPU usage rate of the operation and maintenance end based on the usage time and the preset time includes:
[0067] Get the control node and computing node in the node;
[0068] Setting a first influence coefficient for the control node and a second influence coefficient for the computing node;
[0069] The CPU usage of the operation and maintenance end is determined based on the usage time, the preset time, the first impact coefficient, and the second impact coefficient.
[0070] The nodes of the cloud platform include different types of nodes, specifically control nodes and computing nodes. The utilization rate of control nodes and computing nodes represent different meanings. For example, if the same CPU is used up by 90%, if it is a control node, it means that the cloud platform is consuming too much resources and needs to locate the problem or add resources. If it is a computing node, it means that the system has no resources for users to apply for. Therefore, the control node and the computing node have different impacts on the cluster. Therefore, in the process of calculating the CPU utilization of the cloud platform, different influence coefficients need to be set for the control node and the computing node. In this embodiment, the first influence coefficient X is set for the control node. 1n , set the second influence coefficient X for the computing node 2n The CPU usage of the control node represents the load of the entire cluster. Therefore, under normal circumstances, the influence coefficient of the control node is usually greater than the influence coefficient of the computing node, that is, X 1n Greater than X 2n .
[0071] In large-scale clusters, system components are deployed separately on control nodes with different roles. Therefore, different control nodes with different roles require different influence coefficients. Specifically, the first influence coefficient contains multiple sub-influence coefficients, each of which is set based on the role of the control node. For example, RabbitMQ nodes and MariaDB nodes require different influence coefficients.
[0072] The present embodiment provides a method for calculating the CPU usage rate on the operation side based on the control nodes and the computing nodes, and sets different influence coefficients for the control nodes and the computing nodes during the calculation. Since the control node usage rate and the computing node usage rate represent different meanings, the control nodes and the computing nodes are distinguished, and the control nodes and the computing nodes have different impacts on the cluster. Therefore, the method for calculating the CPU usage rate on the operation side, taking into account the differences in nodes and the different impacts of the nodes, can more realistically reflect the CPU usage rate of the cloud platform. The calculated cloud platform CPU usage rate has a greater reference value for users.
[0073] Based on the above embodiment, specifically, determining the CPU usage rate of the operation and maintenance end according to the usage time, the preset time, the first impact coefficient, and the second impact coefficient includes:
[0074] Obtaining respectively a first product result of the usage time corresponding to each core of each control node and the first influence coefficient and a second product result of the usage time corresponding to each core of each computing node and the second influence coefficient;
[0075] Obtaining a sum of the first multiplication results and a sum of the second multiplication results;
[0076] Adding the sum of the first multiplication results and the sum of the second multiplication results to obtain a first total usage time of all cores;
[0077] Obtaining a third product of the preset duration and the first influence coefficient for each core of each control node, and obtaining a fourth product of the preset duration and the second influence coefficient for each core of each computing node;
[0078] Obtaining a sum of the third multiplication results and a sum of the fourth multiplication results;
[0079] Adding the sum of the third multiplication results and the sum of the fourth multiplication results to obtain a first total allocated time used by all cores;
[0080] Obtaining a first ratio of a first total usage time to a first total allocation time;
[0081] The first ratio is used as the CPU usage of the operation and maintenance end.
[0082] The main steps for calculating CPU usage on the operation and maintenance side are as follows:
[0083] a. Configure the influence coefficient. Since the control node and the computing node have different effects on the cluster, an influence coefficient must be added to the calculation of the platform CPU usage. Assume that the first influence coefficient of the control node is X 1n , the second influence coefficient of the calculation node is X 2n .
[0084] b. Obtain the cloud platform node list. Obtain the number of cloud platform nodes n from the cloud platform deployment configuration file, and label them as node1, node2, node3, etc.
[0085] c. Get the CPU list of all nodes. For each node in the obtained cloud platform node class table, get the node CPU list.
[0086] d. Data collection. At the same time and within the same time window T, obtain the usage time of each CPU. Taking node n as an example, the usage time of m CPUs within time T is time[n][1], time[n][2], ..., time[n][m] respectively.
[0087] e. Calculate the CPU usage of the cloud platform on the operation and maintenance side using the following formula (1).
[0088] Usage platform operation and maintenance = ∑(time[n][m]*X n *100) / ∑(Xn*T) (1)
[0089] In formula (1), X n It represents the influence coefficient, n is the number of cloud platform nodes, and m is the number of CPUs in each node. n The value of is determined by the type of the corresponding node. When the node is a control node, the selected X n The value of X 1n , when the node is a computing node, the selected X n The value of X 2n ,In addition, for the control node, X n The value of also depends on the role of the controlling node.
[0090] The calculation method for obtaining the CPU usage of the operation and maintenance end provided in this embodiment takes into account the different impact effects of different nodes and sets different impact coefficients, that is, sets weights, so that the CPU usage of the operation and maintenance end obtained is more realistic and has more reference value.
[0091] The above embodiment describes the method for determining the CPU usage rate of the operation and maintenance end. This embodiment describes the method for determining the CPU usage rate of the operation end. When the CPU usage rate of the cloud platform is the CPU usage rate of the operation end, determining the CPU usage rate of the operation end based on the usage time and the preset time includes:
[0092] Get the usage time of each core of each computing node respectively;
[0093] Adding the usage duration corresponding to each core of each computing node to obtain a second total usage duration of all cores of all computing nodes;
[0094] Get the total number of cores of all computing nodes;
[0095] Obtaining a product of the total number of cores of all computing nodes and a preset duration to obtain a second total allocated duration used by all cores of all computing nodes;
[0096] Obtaining a second ratio of the second total usage time to the second total allocation time;
[0097] The second ratio is used as the CPU usage of the operation side.
[0098] The main steps for calculating CPU usage on the cloud platform operation side are as follows:
[0099] a. Obtain a list of computing nodes on the cloud platform. Obtain the number of computing nodes n on the cloud platform from the cloud platform deployment configuration file, labeling them as node1, node2, node3, and so on.
[0100] b. Get the CPU list of all computing nodes. For each node in the obtained cloud platform computing node class table, get the node's CPU list.
[0101] c. Data collection. From the same time and within the same time window T, obtain the usage time of each CPU. Taking computing node n as an example, the usage time of m CPUs within time T is time[n][1], time[n][2], ..., time[n][m] respectively;
[0102] d. Calculate the CPU usage of the cloud platform on the operation side using the following formula (2).
[0103] Usage platform operation = ∑(time[n][m]*100) / ∑T (2)
[0104] Taking a small cloud platform as an example, if the platform consists of three machines, node1, node2, and node3, with 4, 4, and 8 CPUs respectively, and the CPU usage time in one second is 0.5s, 0.5s, 0s, 0s, 1s, 0.5s, 0s, 0s, 1s, 1s, 0.5s, 0.5s, 0s, 0s, 0s, 0s, then the CPU utilization rate of the cloud platform is (0.5+0.5+1+0.5+0.5+1+1+0.5+0.5) / 16*100%=37.5%.
[0105] It should be noted that in the process of calculating the CPU usage rate on the operation and maintenance side, it is calculated based on all nodes, including control nodes and computing nodes, and different influence coefficients are set for control nodes and computing nodes respectively. When calculating the CPU usage rate on the operation side, only the computing nodes need to be calculated. Since different computing nodes have the same influence, there is no need to set different influence coefficients for different nodes in the computing node, but a unified influence coefficient is used. The method provided in this embodiment can obtain the CPU usage rate on the operation side.
[0106] In practice, the scale of cloud platforms often reaches hundreds or even thousands of nodes. Using a monitoring server to initiate and pull data from each node simultaneously will cause concurrency pressure and time differences, resulting in inaccurate data. Therefore, the preferred implementation method is to obtain the cloud platform node list and the kernel of each node including:
[0107] Collect monitoring data through the client; wherein the monitoring data includes at least a list of nodes of the cloud platform, the core of each node, and the usage time of the core of each node within a preset time period;
[0108] Store monitoring data in a time series database;
[0109] Upon receiving an instruction to obtain a list of nodes of the cloud platform and a kernel of each node, the list of nodes of the cloud platform and the kernel of each node are obtained from a time series database;
[0110] Correspondingly, obtaining the usage time of the core of each node within the preset time period includes:
[0111] When an instruction to obtain the usage time of the core of each node within a preset time period is received, the usage time of the core of each node within the preset time period is obtained from a time series database.
[0112] The method provided in this embodiment for obtaining the node list of the cloud platform, the core of each node, and the usage time of the core of each node within a preset time period from the database can reduce the pressure when collecting corresponding node data from each node at the same time, and improve the accuracy of the monitoring data obtained.
[0113] In the above embodiments, a method for obtaining the CPU usage of a cloud platform is described in detail. This application also provides an embodiment of a device for obtaining the CPU usage of a cloud platform. It should be noted that this application describes the embodiments of the device from two perspectives: one is based on the functional module perspective, and the other is based on the hardware perspective.
[0114] Figure 2 This is a structural diagram of an apparatus for obtaining the CPU usage of a cloud platform provided in one embodiment of the present application. This embodiment, based on the perspective of functional modules, includes:
[0115] The first acquisition module 10 is used to obtain a list of nodes of the cloud platform and the kernel of each node;
[0116] The second acquisition module 11 is used to obtain the usage time of the core of each node within a preset time period;
[0117] The determination module 12 is used to determine the cloud platform CPU usage rate according to the usage time and the preset time.
[0118] Since the embodiments of the apparatus part correspond to the embodiments of the method part, please refer to the description of the embodiments of the method part for the embodiments of the apparatus part, and they will not be repeated here.
[0119] The device for obtaining the cloud platform CPU usage provided in this embodiment obtains the cloud platform's node list and the cores of each node through a first acquisition module; obtains the usage time of each node's core within a preset time period through a second acquisition module; and determines the cloud platform CPU usage based on the usage time and the preset time period through a determination module. Compared to previous devices that use the average of the CPU usage of all nodes as the cloud platform CPU usage, the device provided in this embodiment refines the node's CPU usage to the node's CPU core usage, and determines the cloud platform CPU usage based on the node's CPU core usage, making the obtained cloud platform CPU usage more accurate.
[0120] Figure 3 This is a structural diagram of a device for obtaining the CPU usage of a cloud platform provided by another embodiment of the present application. This embodiment is based on the hardware perspective, such as Figure 3 As shown, the device for obtaining the CPU usage of the cloud platform includes:
[0121] Memory 20, for storing computer programs;
[0122] The processor 21 is configured to implement the steps of the method for obtaining the CPU usage of the cloud platform as mentioned in the above embodiment when executing a computer program.
[0123] The device for obtaining the CPU usage of the cloud platform provided in this embodiment may include but is not limited to a smart phone, a tablet computer, a laptop computer, or a desktop computer.
[0124] Among them, the processor 21 may include one or more processing cores, such as a 4-core processor, an 8-core processor, etc. The processor 21 can be implemented in at least one hardware form of a digital signal processor (DSP), a field-programmable gate array (FPGA), and a programmable logic array (PLA). The processor 21 may also include a main processor and a coprocessor. The main processor is a processor for processing data in the awake state, also known as a CPU; the coprocessor is a low-power processor for processing data in the standby state. In some embodiments, the processor 21 may be integrated with a graphics processing unit (GPU), which is responsible for rendering and drawing the content to be displayed on the display screen. In some embodiments, the processor 21 may also include an artificial intelligence (AI) processor, which is used to process computing operations related to machine learning.
[0125] The memory 20 may include one or more computer-readable storage media, which may be non-transitory. The memory 20 may also include high-speed random access memory, and non-volatile memory, such as one or more disk storage devices, flash memory storage devices. In this embodiment, the memory 20 is at least used to store the following computer program 201, wherein, after the computer program is loaded and executed by the processor 21, it can implement the relevant steps of the method for obtaining the CPU usage of the cloud platform disclosed in any of the aforementioned embodiments. In addition, the resources stored in the memory 20 may also include an operating system 202 and data 203, etc., and the storage method may be temporary storage or permanent storage. Among them, the operating system 202 may include Windows, Unix, Linux, etc. The data 203 may include but is not limited to the data involved in the above-mentioned method for obtaining the CPU usage of the cloud platform.
[0126] In some embodiments, the device for obtaining the CPU usage of the cloud platform may also include a display screen 22 , an input and output interface 23 , a communication interface 24 , a power supply 25 , and a communication bus 26 .
[0127] Those skilled in the art will understand that Figure 3 The structure shown in does not constitute a limitation on the device for obtaining the CPU usage of the cloud platform, and may include more or fewer components than shown in the figure.
[0128] The device for obtaining the CPU usage rate of a cloud platform provided in an embodiment of the present application includes a memory and a processor. When the processor executes the program stored in the memory, it can implement the following method: a method for obtaining the CPU usage rate of a cloud platform, with the same effect as above.
[0129] Finally, the present application also provides an embodiment corresponding to a computer-readable storage medium. The computer-readable storage medium stores a computer program, which, when executed by a processor, implements the steps described in the above method embodiment.
[0130] It is understandable that if the method in the above embodiment 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 technical solution of the present application, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium and executes all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0131] The computer-readable storage medium provided in this application includes the above-mentioned method for obtaining the CPU usage of the cloud platform, and the effect is the same as above.
[0132] In order to make the technical personnel in this field better understand the present application scheme, the following Figure 4 The present application is further described in detail with specific implementation methods. Figure 4 This is a schematic diagram of an application scenario of a method for calculating the CPU usage of a cloud platform provided in an embodiment of the present application. Figure 4 As shown:
[0133] On the collection client: The collection client uses a scheduled task to collect data. By executing the collection code and processing the data, the node's CPU usage data is obtained. To reduce collection pressure, the collection cycle is 5 minutes, and the CPU time window is 1 second.
[0134] The collection code includes the following:
[0135] 1. Obtain the hostname of this node through system commands;
[0136] 2. Obtain the number of CPU cores of this node through the operating system configuration file;
[0137] 3. Obtain the CPU usage time within the node unit window through the operating system interface;
[0138] 4. Assemble the above data to obtain monitoring data in tag-value format.
[0139] On the monitoring server:
[0140] The monitoring server obtains the cloud platform node list and roles, receives monitoring data sent by all nodes, determines data integrity, and calculates the cloud platform CPU usage. The main steps are as follows:
[0141] 1. Receive monitoring data reported by all acquisition clients and store it in the time series database.
[0142] 2. Start the calculation task regularly. The scheduled task mainly performs the following operations:
[0143] a. Obtain the node list and roles through the cloud platform management interface to determine whether the monitoring data within the task window (number of nodes and data for each core) is complete.
[0144] b. For all nodes, perform calculations according to formula (1) to obtain the CPU usage of the operation and maintenance end.
[0145] c. For the computing nodes, perform calculations according to formula (2) to obtain the CPU usage of the operation side.
[0146] The method for obtaining cloud platform CPU utilization provided in this embodiment uses different calculation methods for different users, weighting their respective focus points, and refining CPU usage down to the core usage perspective, thereby achieving the goal of overall cloud platform monitoring. This method is suitable for various types of cloud platforms and can not only assess platform bottlenecks and provide reference for operations and maintenance personnel, but also determine business resource usage and evaluate tenant resource allocation.
[0147] The above is a detailed introduction to the method, device and medium for obtaining the CPU usage of a cloud platform provided by the present application. The various embodiments in the specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same and similar parts between the embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part description. It should be pointed out that for ordinary technicians in this technical field, without departing from the principles of this application, several improvements and modifications can be made to the present application, and these improvements and modifications also fall within the scope of protection of the claims of this application.
[0148] It should also be noted that, in this specification, relational terms such as first and second, etc., are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variants thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or apparatus. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of additional identical elements in the process, method, article, or apparatus comprising the element.
Claims
1. A method for obtaining the CPU usage of a cloud platform, characterized in that: include: Obtain a list of nodes on the cloud platform and the kernel of each node; Obtaining the usage time of the core of each node within a preset time period; Determine the CPU usage rate of the cloud platform according to the usage duration and the preset duration; The cloud platform CPU usage includes the CPU usage of the operation and maintenance end or the CPU usage of the operation end; When the cloud platform CPU usage is the operation and maintenance end CPU usage, determining the operation and maintenance end CPU usage according to the usage duration and the preset duration includes: Obtaining a control node and a computing node from the nodes; Setting a first influence coefficient for the control node and setting a second influence coefficient for the computing node; The CPU usage rate of the operation and maintenance end is determined according to the usage time, the preset time, the first impact coefficient, and the second impact coefficient.
2. The method for obtaining the CPU usage of a cloud platform according to claim 1, characterized in that: Determining the CPU usage of the operation and maintenance end according to the usage duration, the preset duration, the first impact coefficient, and the second impact coefficient includes: Respectively obtaining a first product result of the usage time corresponding to each core of each control node and the first influence coefficient, and a second product result of the usage time corresponding to each core of each computing node and the second influence coefficient; Obtaining a sum of the first multiplication results and a sum of the second multiplication results; Adding a sum of the first multiplication results and a sum of the second multiplication results to obtain a first total usage time of all the cores; Obtaining a third product result of the preset duration and the first influence coefficient for each core of each control node, and obtaining a fourth product result of the preset duration and the second influence coefficient for each core of each computing node; Obtaining a sum of the third multiplication results and a sum of the fourth multiplication results; adding a sum of the third multiplication results and a sum of the fourth multiplication results to obtain a first total allocated duration used by all the cores; Obtaining a first ratio of the first total usage time to the first total allocation time; The first ratio is used as the CPU usage of the operation and maintenance end.
3. The method for obtaining the CPU usage of a cloud platform according to claim 2, characterized in that: The first influence coefficient includes a plurality of sub-influence coefficients, wherein the sub-influence coefficients are set according to the control nodes of different roles.
4. The method for obtaining the CPU usage of a cloud platform according to claim 1, characterized in that: When the cloud platform CPU usage rate is the operation end CPU usage rate, determining the operation end CPU usage rate according to the usage duration and the preset duration includes: Obtaining the usage time corresponding to each core of each computing node respectively; Adding the usage durations corresponding to the cores of the computing nodes to obtain a second total usage duration of all the cores of all the computing nodes; Get the total number of cores of all the computing nodes; Obtaining a product of a total number of cores of all the computing nodes and the preset duration to obtain a second total allocated duration used by all the cores of all the computing nodes; Obtaining a second ratio of the second total usage time to the second total allocation time; The second ratio is used as the CPU usage of the operation end.
5. The method for obtaining the CPU usage of a cloud platform according to any one of claims 1 to 4, characterized in that: The obtaining of a list of nodes of the cloud platform and the kernel of each node includes: Collecting monitoring data through a client; wherein the monitoring data includes at least a list of nodes of the cloud platform, a kernel of each of the nodes, and the usage time of the kernel of each of the nodes within the preset time period; Storing the monitoring data in a time series database; Upon receiving an instruction to obtain a list of nodes of the cloud platform and a kernel of each node, obtaining the list of nodes of the cloud platform and a kernel of each node from the time series database; Correspondingly, obtaining the usage time of the core of each node within a preset time period includes: When an instruction to obtain the usage time of the core of each node within the preset time is received, the usage time of the core of each node within the preset time is obtained from the time series database.
6. A device for obtaining the CPU usage of a cloud platform, characterized in that: include: A first acquisition module is used to obtain a list of nodes of the cloud platform and the kernel of each node; A second acquisition module is used to obtain the usage time of the core of each node within a preset time period; A determination module, configured to determine the CPU usage of the cloud platform according to the usage duration and the preset duration; The cloud platform CPU usage includes the CPU usage of the operation and maintenance end or the CPU usage of the operation end; When the cloud platform CPU usage is the operation and maintenance end CPU usage, determining the operation and maintenance end CPU usage according to the usage duration and the preset duration includes: Obtaining a control node and a computing node from the nodes; Setting a first influence coefficient for the control node and setting a second influence coefficient for the computing node; The CPU usage rate of the operation and maintenance end is determined according to the usage time, the preset time, the first impact coefficient, and the second impact coefficient.
7. A device for obtaining the CPU usage of a cloud platform, characterized in that: include: memory for storing computer programs; A processor, configured to implement the steps of the method for obtaining the CPU usage of a cloud platform as described in any one of claims 1 to 5 when executing the computer program.
8. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, which, when executed by a processor, implements the steps of the method for obtaining the CPU usage of a cloud platform according to any one of claims 1 to 5.
Citation Information
Patent Citations
Method and device for task scheduling on heterogeneous multi-core reconfigurable computing platform
CN104778083A
Balancing CPU Utilization In A Massively Parallel Processing Heterogeneous Cluster
US20180352024A1