A method, device and related components for managing alarm tasks
By receiving and judging the execution status of alarm tasks in a distributed cluster, it avoids multiple nodes executing the same task at the same time and calculates the task time, which solves the task balancing problem in the distributed cluster, improves resource utilization efficiency and reduces system maintenance. Difficulty.
Patent Information
- Application Number
- CN202110873771.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-07-30
- Publication Date
- 2024-10-29
- Estimated Expiration
- 2041-07-30
AI Technical Summary
In a distributed cluster, the lack of a reasonable alarm task scheduling method may cause multiple nodes to execute the same task at the same time, which cannot reduce the computing pressure of a single node and increase the difficulty of system maintenance.
By receiving the alarm tasks issued by the dispatch center, we obtain task data, determine the task execution status and running status, avoid multiple nodes executing the same task at the same time, and calculate the task time, so that the dispatch center can determine the next execution node and balance the node tasks. .
It achieves a balanced distribution of tasks for each node in a distributed cluster, improves node resource utilization efficiency, reduces the computing pressure on a single node, and reduces the difficulty of system maintenance.
Smart Images

Figure CN113722060B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of distributed clusters, and in particular to an alarm task management method, device and related components. Background Art
[0002] In the era of cloud computing, with the expansion of enterprise business, the types of resources required are also increasing, including physical machines, cloud hosts, cloud physical machines, storage clusters, network devices, etc. Correspondingly, in order to support the business, the number of resources that the monitoring system needs to monitor is increasing. In this case, the enterprise's IT architecture has developed from a single node to a distributed cluster. Distributed clustering can disperse alarm tasks on multiple nodes, thereby reducing the computing pressure of a single node and improving the utilization efficiency of node resources. However, if there is no reasonable alarm task scheduling method, multiple nodes may execute the same task at the same time, which not only fails to reduce the computing pressure of a single node, but also increases the difficulty of system maintenance.
[0003] Therefore, how to provide a solution to the above technical problems is a problem that those skilled in the art need to solve at present. Summary of the invention
[0004] The purpose of this application is to provide an alarm task management method, device, electronic device and computer-readable storage medium, which can prevent multiple nodes from executing the same alarm task at the same time, balance the tasks of each node in a distributed cluster, improve the utilization efficiency of node resources, reduce the pressure of single-node computing, and reduce the difficulty of system maintenance.
[0005] To solve the above technical problems, the present application provides an alarm task management method, which is applied to each node in a distributed cluster. The alarm task management method includes:
[0006] Receive the alarm task issued by the dispatch center, and obtain task data corresponding to the alarm task, wherein the task data includes the execution status and the operation status of the node that last executed the alarm task, and the alarm task is an alarm task executed according to the monitoring cycle;
[0007] Determine whether the alarm task is in an executable state according to the execution state and the running state;
[0008] If not, the alarm task is not executed;
[0009] If yes, execute the alarm task and calculate the time taken to execute the alarm task, so that the dispatch center can determine the node that will execute the alarm task next time according to the time taken, so that the tasks of each node in the distributed cluster are balanced.
[0010] Optionally, the process of acquiring task data corresponding to the alarm task includes:
[0011] The task data corresponding to the alarm task is obtained in a database, and the task data in the database is locked so that other nodes cannot obtain the task data.
[0012] Optionally, the process of judging whether the alarm task is in an executable state according to the execution state and the running state includes:
[0013] When the execution state is an unexecuted state, determining that the alarm task is an executable state;
[0014] When the execution state is the executing state and the running state is the abnormal state, determining that the alarm task is in the executable state;
[0015] When the execution state is the executing state and the running state is the normal running state, it is determined that the alarm task is in an unexecutable state.
[0016] Optionally, the process of judging whether the alarm task is in an executable state according to the execution state and the running state further includes:
[0017] When the execution state is in the executing state, determining whether the node that last executed the alarm task is a local node;
[0018] If so, determining that the alarm task is in the executable state;
[0019] If not, when the running state is a normal running state, the alarm task is determined to be in an unexecutable state; and when the running state is an abnormal state, the alarm task is determined to be in an executable state.
[0020] Optionally, when the execution state is an unexecuted state, the process of determining that the alarm task is in an executable state includes:
[0021] When the execution state is the unexecuted state and the alarm task has not been executed in the current monitoring cycle, it is determined that the alarm task is in the executable state.
[0022] Optionally, after executing the alarm task, the alarm task management method further includes:
[0023] The execution status of the alarm task is set to an unexecuted state.
[0024] Optionally, the process of the dispatch center determining the node that will perform the alarm task next time according to the time consumption includes:
[0025] The dispatch center obtains the average time consumption of the alarm task, and allocates a node for executing the alarm task next time to the alarm task, so that the difference in total time consumption between any two nodes in the distributed cluster that are in normal operation is less than a preset value.
[0026] In order to solve the above technical problems, the present application also provides an alarm task management device, which is applied to each node in the distributed cluster. The alarm task management device includes:
[0027] An acquisition module is used to receive the alarm task issued by the dispatch center and acquire task data corresponding to the alarm task, wherein the task data includes the execution status and the operation status of the node that last executed the alarm task, and the alarm task is an alarm task executed according to the monitoring cycle;
[0028] A judging module, used for judging whether the alarm task is in an executable state according to the execution state and the running state, if not, not executing the alarm task, if yes, triggering the execution module;
[0029] The execution module is used to execute the alarm task and calculate the time consumed to execute the alarm task, so that the scheduling center determines the node to execute the alarm task next time according to the time consumed, so as to balance the tasks of each node in the distributed cluster.
[0030] In order to solve the above technical problems, the present application also provides an electronic device, including:
[0031] Memory for storing computer programs;
[0032] A processor is used to implement the steps of the alarm task management method as described in any one of the above when executing the computer program.
[0033] 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 alarm task management method as described in any one of the above are implemented.
[0034] The present application provides an alarm task management method. After receiving the alarm task sent by the dispatch center, each node in the distributed cluster determines whether there are other nodes executing the alarm task based on the execution status of the alarm task and the running status of the node that executed the alarm task last time, thereby determining whether the alarm task is executable on the local node to avoid multiple nodes executing the same alarm task at the same time. In addition, when the local node executes the alarm task, the time consumed by the alarm task is calculated so that the dispatch center can determine the node that will execute the alarm task next time based on the time consumed, so that the tasks of each node in the distributed cluster are balanced, the utilization efficiency of node resources is improved, the pressure of single-node calculation is reduced, and the difficulty of system maintenance is reduced. The present application also provides an alarm task management device, an electronic device, and a computer-readable storage medium, which have the same beneficial effects as the above-mentioned alarm task management method. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] 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 paying any creative work.
[0036] Figure 1 A flowchart of the steps of an alarm task management method provided by this application;
[0037] Figure 2 A schematic diagram of the structure of an alarm task management device provided in this application. DETAILED DESCRIPTION
[0038] The core of this application is to provide an alarm task management method, device, electronic device and computer-readable storage medium, which can prevent multiple nodes from executing the same alarm task at the same time, balance the tasks of each node in the distributed cluster, improve the utilization efficiency of node resources, reduce the pressure of single-node computing, and reduce the difficulty of system maintenance.
[0039] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0040] First of all, it should be noted that in the era of cloud computing, with the expansion of enterprise business, the types of resources required are increasing, including physical machines, cloud hosts, cloud physical machines, storage clusters, and network devices. Each alarm item indicator under various resource categories is used as an alarm task, such as host CPU usage alarm, network traffic alarm, etc. In this embodiment, the alarm task is an alarm task executed according to the monitoring cycle, and the alarm task is coordinated and sent by the scheduling center to each node of the distributed cluster.
[0041] The solution in this embodiment is completed by each node of the distributed cluster. The alarm task management method provided in this application is described in detail below.
[0042] Please refer to Figure 1 , Figure 1 A flowchart of a method for managing an alarm task provided by the present application, the method for managing an alarm task comprising:
[0043] S101: Receive an alarm task issued by a dispatch center, and obtain task data corresponding to the alarm task, where the task data includes an execution status and an operation status of a node that last executed the alarm task. The alarm task is an alarm task executed according to a monitoring cycle.
[0044] It can be understood that before executing this step, the alarm task management method also includes the operation of pre-creating a database, which is used to store task data corresponding to each alarm task. The task data includes but is not limited to task name, execution node name, running status, task monitoring cycle, the last start time of task execution, monitoring data and the running status of each node, etc.
[0045] Specifically, when the local node receives the alarm task sent by the dispatch center, it first searches the database for the execution status corresponding to the alarm task and the running status of the node that last executed the alarm task, so as to subsequently determine whether the local node needs to execute the alarm task.
[0046] Specifically, each node will also send a heartbeat message to the database once according to a preset period to update the operating status of the local node.
[0047] S102: judging whether the alarm task is executable according to the execution status and the running status, if not, executing S103, if yes, executing S104;
[0048] S103: Do not execute the alarm task;
[0049] S104: Execute the alarm task and calculate the time consumed to execute the alarm task, so that the dispatch center can determine the node that will execute the alarm task next time according to the time consumed, so that the tasks of each node in the distributed cluster are balanced.
[0050] Specifically, based on the execution status and the running status of the node that last executed the alarm task, it is determined whether the alarm task is in an executable state for the local node. If it is determined to be in an unexecutable state, the local node does not execute the alarm task. If it is determined to be in an execution state, the alarm task is executed. At the same time, the execution time of the alarm task is timed to obtain the time consumption of the alarm task. The time consumption can also be written into the database so that the scheduling center can assign corresponding nodes to each alarm task based on the average time consumption of each alarm task.
[0051] As an optional embodiment, the process of the dispatch center determining the node to perform the alarm task next time according to the time consumption includes:
[0052] The dispatch center obtains the average time consumption of the alarm task and allocates the node that will execute the alarm task next time to the alarm task, so that the difference in the total time consumption between any two nodes in the distributed cluster that are in normal operation is less than a preset value.
[0053] Specifically, the dispatch center can reallocate the execution nodes of the alarm tasks at regular intervals, and can allocate them according to the average time consumption of each alarm task, so that the total execution time consumption of tasks on each normally operating node is close, so that each node shares the computing pressure, and avoids the problem of large differences in computing pressure caused by the average distribution of tasks to each node, so as to achieve the purpose of balancing tasks among nodes in the distributed cluster. Of course, on the basis of ensuring that the total execution time consumption of tasks on each normally operating node is close, the alarm task will be preferentially allocated to the node that executed the alarm task last time, so as to improve the task execution efficiency of the node and avoid resource waste.
[0054] It can be seen that in this embodiment, after receiving the alarm task issued by the dispatch center, each node in the distributed cluster determines whether other nodes are executing the alarm task based on the execution status of the alarm task and the running status of the node that executed the alarm task last time, thereby determining whether the alarm task is executable on the local node to avoid multiple nodes executing the same alarm task at the same time. In addition, when the local node executes the alarm task, the time consumed by the alarm task is calculated so that the dispatch center can determine the node that will execute the alarm task next time based on the time consumed, so that the tasks of each node in the distributed cluster are balanced, the utilization efficiency of node resources is improved, the pressure of single-node calculation is reduced, and the difficulty of system maintenance is reduced.
[0055] Based on the above embodiments:
[0056] As an optional embodiment, the process of obtaining task data corresponding to the alarm task includes:
[0057] The task data corresponding to the alarm task is obtained in the database, and the task data in the database is locked so that other nodes cannot obtain the task data.
[0058] Specifically, in this embodiment, it is taken into account that the dispatching center may mistakenly send the same alarm task to multiple nodes. Therefore, when a certain node first receives the alarm task, it obtains the task data corresponding to the alarm task from the database and locks the task data in the database, such as adding a lock mark. When other nodes search for the task data corresponding to the alarm task in the database, if the lock mark is recognized, the task data will no longer be obtained, that is, the alarm task will not be executed, ensuring that the same alarm task can only be accessed once at the same time, further avoiding the problem of multiple nodes executing the same alarm task in the distributed cluster, thereby avoiding waste of resources.
[0059] As an optional embodiment, the process of judging whether the alarm task is in an executable state according to the execution state and the running state includes:
[0060] When the execution status is not executed, the alarm task is determined to be executable;
[0061] When the execution status is in the executing state and the running state is in the abnormal state, the alarm task is determined to be in the executable state;
[0062] When the execution state is in the executing state and the operation state is in the normal operation state, the alarm task is determined to be in the non-executable state.
[0063] Specifically, if the execution status of the alarm task received by the local node is not executed, and the alarm task has not been executed in the current monitoring cycle, then the alarm task is determined to be executable for the local node, and the local node allows the alarm task to be executed. If the execution status of the alarm task received by the local node is in the executing state, first determine whether the node that executed the alarm task last time still has a heartbeat, that is, whether it is in a normal operating state. If so, it means that the alarm task takes a long time, and other nodes are still executing normally, and the local node does not need to repeat the execution. If the node that executed the alarm task last time has no heartbeat, that is, it is in an abnormal state, which means that the node that executed the alarm task last time was hung during the task execution. At this time, the local node allows the alarm task to be executed.
[0064] As an optional embodiment, the process of judging whether the alarm task is in an executable state according to the execution state and the running state further includes:
[0065] When the execution status is in the executing state, determine whether the node that last executed the alarm task is the local node;
[0066] If so, the alarm task is determined to be executable;
[0067] If not, when the running state is a normal running state, the alarm task is determined to be in an unexecutable state; when the running state is an abnormal state, the alarm task is determined to be in an executable state.
[0068] Specifically, based on the above embodiment, when the execution state is determined to be the executing state, first determine whether the node that last executed the alarm task is a local node. If so, it means that the local node was restarted during the last execution of the alarm task, and the alarm task is allowed to continue to be executed. Further, if the node that last executed the alarm task is not a local node, determine whether the node that last executed the alarm task still has a heartbeat, that is, whether it is in a normal operating state. If so, it means that the alarm task takes a long time, and other nodes are still executing normally, and the local node does not need to repeat the execution. If the node that last executed the alarm task has no heartbeat, that is, it is in an abnormal state, it means that the node that last executed the alarm task was hung during the task execution. At this time, the local node is allowed to execute the alarm task.
[0069] As an optional embodiment, after executing the alarm task, the alarm task management method further includes:
[0070] Set the execution status of the alarm task to unexecuted.
[0071] It is understandable that after each execution of the alarm task, the execution state of the alarm task is set to an unexecuted state, so that each subsequent node can determine whether it can execute the alarm task.
[0072] In summary, the scheme of the present application is adopted to complete unified scheduling of the alarm tasks of the entire distributed cluster through the dispatch center, ensuring that the monitoring system can run stably and efficiently. Each node obtains the alarm task, and before preparing to execute it, it will detect whether the local node still needs to execute the task. After each node successfully executes the alarm task, the execution status of the alarm task will be set to the unexecuted state, and the execution data of the alarm task will be collected for subsequent performance analysis and optimization. The dispatch center regularly balances the alarm tasks of each node to balance the computing pressure of each node, improves the real-time and high availability of monitoring alarms, and improves the execution efficiency of alarm tasks.
[0073] Please refer to Figure 2 , Figure 2 A schematic diagram of the structure of an alarm task management device provided by the present application is applied to each node in a distributed cluster. The alarm task management device includes:
[0074] Acquisition module 1 is used to receive the alarm task issued by the dispatch center and acquire the task data corresponding to the alarm task. The task data includes the execution status and the operation status of the node that last executed the alarm task. The alarm task is an alarm task executed according to the monitoring cycle.
[0075] The judging module 2 is used to judge whether the alarm task is in an executable state according to the execution state and the running state. If not, the alarm task is not executed. If so, the execution module 3 is triggered.
[0076] Execution module 3 is used to execute the alarm task and calculate the time consumed to execute the alarm task, so that the dispatch center can determine the node to execute the alarm task next time according to the time consumed, so as to balance the tasks of each node in the distributed cluster.
[0077] It can be seen that in this embodiment, after receiving the alarm task issued by the dispatch center, each node in the distributed cluster determines whether other nodes are executing the alarm task based on the execution status of the alarm task and the running status of the node that executed the alarm task last time, thereby determining whether the alarm task is executable on the local node to avoid multiple nodes executing the same alarm task at the same time. In addition, when the local node executes the alarm task, the time consumed by the alarm task is calculated so that the dispatch center can determine the node that will execute the alarm task next time based on the time consumed, so that the tasks of each node in the distributed cluster are balanced, the utilization efficiency of node resources is improved, the pressure of single-node calculation is reduced, and the difficulty of system maintenance is reduced.
[0078] As an optional embodiment, the process of judging whether the alarm task is in an executable state according to the execution state and the running state includes:
[0079] When the execution status is not executed, the alarm task is determined to be executable;
[0080] When the execution status is in the executing state and the running state is in the abnormal state, the alarm task is determined to be in the executable state;
[0081] When the execution state is in the executing state and the operation state is in the normal operation state, the alarm task is determined to be in the non-executable state.
[0082] As an optional embodiment, the process of judging whether the alarm task is in an executable state according to the execution state and the running state further includes:
[0083] When the execution status is in the executing state, determine whether the node that last executed the alarm task is the local node;
[0084] If so, the alarm task is determined to be executable;
[0085] If not, when the running state is a normal running state, the alarm task is determined to be in an unexecutable state; when the running state is an abnormal state, the alarm task is determined to be in an executable state.
[0086] As an optional embodiment, when the execution state is the unexecuted state, the process of determining that the alarm task is in the executable state includes:
[0087] When the execution state is the unexecuted state and the alarm task has not been executed in the current monitoring cycle, the alarm task is determined to be in the executable state.
[0088] As an optional embodiment, the alarm task management device further includes:
[0089] The setting module is used to set the execution status of the alarm task to an unexecuted state after the alarm task is executed.
[0090] As an optional embodiment, the process of the dispatch center determining the node to perform the alarm task next time according to the time consumption includes:
[0091] The dispatch center obtains the average time consumption of the alarm task and allocates the node that will execute the alarm task next time to the alarm task, so that the difference in the total time consumption between any two nodes in the distributed cluster that are in normal operation is less than a preset value.
[0092] On the other hand, the present application also provides an electronic device, including:
[0093] Memory for storing computer programs;
[0094] A processor is used to implement the steps of the alarm task management method described in any one of the above embodiments when executing a computer program.
[0095] For an introduction to an electronic device provided in the present application, please refer to the above-mentioned embodiments, and the present application will not go into details here.
[0096] The electronic device provided in the present application has the same beneficial effects as the above-mentioned alarm task management method.
[0097] On the other hand, 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 alarm task management method described in any one of the above embodiments are implemented.
[0098] For an introduction to a computer-readable storage medium provided in the present application, please refer to the above-mentioned embodiments, and the present application will not go into details here.
[0099] A computer-readable storage medium provided in the present application has the same beneficial effects as the above-mentioned alarm task management method.
[0100] It should also be noted that, in this specification, relational terms such as first and second, etc. are only used 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, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the statement "comprising a ..." does not exclude the presence of other identical elements in the process, method, article or device including the element.
[0101] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A method for managing alarm tasks, characterized in that: Applied to each node in a distributed cluster, the alarm task management method includes: Receive the alarm task issued by the dispatch center, and obtain task data corresponding to the alarm task, wherein the task data includes the execution status and the operation status of the node that last executed the alarm task, and the alarm task is an alarm task executed according to the monitoring cycle; Determine whether the alarm task is in an executable state according to the execution state and the running state; If not, the alarm task is not executed; If yes, execute the alarm task and calculate the time taken to execute the alarm task, so that the dispatch center determines the node that will execute the alarm task next time according to the time taken, so that the tasks of each node in the distributed cluster are balanced; The process of judging whether the alarm task is in an executable state according to the execution state and the running state includes: When the execution state is an unexecuted state, determining that the alarm task is an executable state; When the execution state is the executing state and the running state is the abnormal state, determining that the alarm task is in the executable state; When the execution state is the executing state and the operation state is the normal operation state, determining that the alarm task is in an unexecutable state; The process of judging whether the alarm task is in an executable state according to the execution state and the running state further includes: When the execution state is in the executing state, determining whether the node that last executed the alarm task is a local node; If so, determining that the alarm task is in the executable state; If not, when the running state is a normal running state, the alarm task is determined to be in an unexecutable state; and when the running state is an abnormal state, the alarm task is determined to be in an executable state.
2. The alarm task management method according to claim 1, characterized in that: The process of obtaining the task data corresponding to the alarm task includes: The task data corresponding to the alarm task is obtained in a database, and the task data in the database is locked so that other nodes cannot obtain the task data.
3. The alarm task management method according to claim 1, characterized in that: When the execution state is the unexecuted state, the process of determining that the alarm task is in the executable state includes: When the execution state is the unexecuted state and the alarm task has not been executed in the current monitoring cycle, it is determined that the alarm task is in the executable state.
4. The alarm task management method according to claim 1, characterized in that: After executing the alarm task, the alarm task management method further includes: The execution status of the alarm task is set to an unexecuted state.
5. The alarm task management method according to any one of claims 1 to 4, characterized in that: The process of the dispatch center determining the node for executing the alarm task next time according to the time consumption includes: The dispatch center obtains the average time consumption of the alarm task, and allocates a node for executing the alarm task next time to the alarm task, so that the difference in total time consumption between any two nodes in the distributed cluster that are in normal operation is less than a preset value.
6. An alarm task management device, characterized in that: Applied to each node in a distributed cluster, the alarm task management device includes: An acquisition module is used to receive the alarm task issued by the dispatch center and acquire task data corresponding to the alarm task, wherein the task data includes the execution status and the operation status of the node that last executed the alarm task, and the alarm task is an alarm task executed according to the monitoring cycle; A judging module, used for judging whether the alarm task is in an executable state according to the execution state and the running state, if not, not executing the alarm task, if yes, triggering the execution module; The execution module is used to execute the alarm task and calculate the time consumed to execute the alarm task, so that the dispatch center determines the node to execute the alarm task next time according to the time consumed, so that the tasks of each node in the distributed cluster are balanced; The process of judging whether the alarm task is in an executable state according to the execution state and the running state includes: When the execution state is an unexecuted state, determining that the alarm task is an executable state; When the execution state is the executing state and the running state is the abnormal state, determining that the alarm task is in the executable state; When the execution state is the executing state and the operation state is the normal operation state, determining that the alarm task is in an unexecutable state; The process of judging whether the alarm task is in an executable state according to the execution state and the running state further includes: When the execution state is in the executing state, determining whether the node that last executed the alarm task is a local node; If so, determining that the alarm task is in the executable state; If not, when the running state is a normal running state, the alarm task is determined to be in an unexecutable state; and when the running state is an abnormal state, the alarm task is determined to be in an executable state.
7. An electronic device, characterized in that: include: Memory for storing computer programs; A processor, configured to implement the steps of the alarm task management method as described in any one of claims 1 to 5 when executing the computer program.
Citation Information
Patent Citations
Cluster task scheduling method and device and related components
CN112463315A
Task management system, task management method, and task management program
US20190138358A1
