Fault repair method, device, computer equipment and storage medium
By automatically performing fault detection and repair operations through the server and selecting the optimal repair strategy using the target repair strategy table and weight index values, the problem of low efficiency in network fault repair is solved, and efficient automated fault repair and rapid recovery of network equipment are achieved.
Patent Information
- Application Number
- CN202411194655.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-28
- Publication Date
- 2025-09-09
- Estimated Expiration
- 2044-08-28
AI Technical Summary
Current network fault repair operations are inefficient and rely on manual analysis and troubleshooting, resulting in a high risk of network service interruption.
Automatically perform fault detection and repair operations through the server, use the target repair strategy table and weight index value to select the optimal repair strategy, and realize automated fault repair.
It improves the efficiency of fault repair, reduces manual intervention, and ensures the rapid recovery and stable operation of network equipment.
Smart Images

Figure CN119155161B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of storage technology, and in particular to a fault repair method, device, computer equipment and storage medium. Background Art
[0002] With the rapid development of information technology and the continuous expansion of networks, the stable operation of network equipment plays a vital role in the stability of the entire network. However, in real-world network environments, network equipment may experience various failures, such as physical connection problems, device aging, configuration errors, or external interference. If these failures are not discovered and addressed promptly, they can cause network service interruptions, seriously impacting the normal business activities of businesses and individuals.
[0003] Current network monitoring relies primarily on the Simple Network Management Protocol (SNMP). SNMP monitors network link status and basic performance indicators. When abnormal network link status or performance indicators are detected, it notifies technicians, who then analyze and troubleshoot the problem.
[0004] Thus, the efficiency of the fault recovery operation is low. Summary of the Invention
[0005] In view of this, the present invention provides a fault repair method, apparatus, computer equipment, storage medium and program product to solve the problem of low fault repair operation efficiency.
[0006] In a first aspect, the present invention provides a fault repair method, which is applied to a network fault detection system, wherein the network fault detection system includes a server and at least one network device, and the method is executed by the server, and the method includes:
[0007] When a detection instruction is obtained, performing a fault detection operation on each of the network devices according to the detection instruction, wherein the detection instruction includes a target fault type;
[0008] receiving a target log generated by any network device during the fault detection operation, wherein the target log includes a target event type, a target network level, and a target communication address;
[0009] determining whether the target event type is the target fault type;
[0010] When it is determined that the target event type is the target fault type, obtaining a target repair strategy table corresponding to the target fault type;
[0011] A repair operation is performed on a target network device corresponding to the target communication address according to the target network level and the target repair policy table.
[0012] The fault repair method provided by the present invention has the following advantages:
[0013] When receiving a detection instruction, the server can perform fault detection operations based on the target fault type contained in the detection instruction and collect target logs during the fault detection operation. If the target event type in the target log is determined to be the target fault type, the server will perform repair operations on the target network device using the target repair strategy table and target network level corresponding to the target fault type. Throughout the detection process, the server can automatically perform fault repair operations, eliminating the need for technical personnel to perform complex analysis and troubleshooting operations, thereby improving the efficiency of fault repair operations.
[0014] In an optional embodiment, the target repair strategy table includes at least one network level, at least one repair strategy corresponding to each of the network levels, and a weight index value corresponding to each of the repair strategies;
[0015] The performing a repair operation on the target network device corresponding to the target communication address according to the target network level and the target repair strategy table includes:
[0016] Determining, according to the target network level, at least one target repair strategy corresponding to the target network level in the target repair strategy table;
[0017] According to the weight index value corresponding to each target repair strategy, a first repair strategy with the largest weight index value is selected from at least one target repair strategy;
[0018] According to the first repair strategy, obtaining a first repair script corresponding to the first repair strategy;
[0019] A first repair operation is performed on the target network device according to the first repair script.
[0020] Specifically, because the causes of the same fault may differ across different network layers, the target repair strategy table includes a corresponding repair strategy for each network layer. This allows for a more comprehensive approach to addressing the fault repair needs of each network layer. Furthermore, the weighted index value indicates the success probability of each target repair strategy. Therefore, using the first repair strategy with the largest weighted index value during the initial repair process increases the probability of success and, in turn, improves the efficiency of the repair operation.
[0021] In an optional implementation, after performing the first repair operation on the target network device according to the first repair script, the method further includes:
[0022] Obtaining a target time point for completing the first repair operation;
[0023] Obtain at least one log generated by the target network device after the target time point;
[0024] Determine whether there is a log of the target fault type in at least one of the logs;
[0025] When it is determined that the log of the target fault type does not exist in at least one of the logs, determining that the fault corresponding to the target fault type in the target network device has been repaired;
[0026] or,
[0027] When it is determined that at least one of the logs contains a log of the target fault type, a second repair strategy is selected from at least one of the target repair strategies according to the weight index value corresponding to each of the repair strategies, wherein the weight index value of the second repair strategy is less than the weight index value of the first repair strategy and greater than the weight index values of other repair strategies in the target repair strategy table except the first repair strategy;
[0028] Adjusting the weight index value of the second repair strategy to a value greater than the weight index value of the first repair strategy, so that the weight index value of the second repair strategy is the adjustment strategy with the largest weight index value among at least one of the repair strategies;
[0029] According to the second repair strategy, obtaining a second repair script corresponding to the second repair strategy;
[0030] A second repair operation is performed on the target network device according to the second repair script.
[0031] Specifically, after completing the repair operation, the result of the repair operation can be learned from the log. If the repair fails, other alternative repair strategies can be adopted to further increase the probability of successful repair, that is, to improve the efficiency of the repair operation.
[0032] In an optional embodiment, the method further includes:
[0033] Acquire historical repair data corresponding to the target fault type and the target network level, wherein the historical repair data includes at least one repair strategy and the number of successful repairs for each repair strategy;
[0034] Determining whether a third repair strategy is one of the at least one repair strategy included in the historical repair data, wherein the third repair strategy is a strategy that successfully repairs the target network device;
[0035] When it is determined that the third repair strategy is one of the at least one repair strategy included in the historical repair data, updating the number of successful repairs corresponding to the third repair strategy;
[0036] Determining a weight index value for each of the repair strategies in the historical repair data according to the number of successful repairs corresponding to each of the repair strategies in the historical repair data;
[0037] The target repair strategy table is updated according to the weight index value of each repair strategy in the historical repair data.
[0038] Specifically, after each successful repair, the target repair strategy table is updated. This allows the next time a fault of the target fault type occurs at the target network layer, the repair strategy can be selected based on the latest repair situation. This allows the target repair strategy table to be adjusted in real time based on the real-time repair situation, ensuring that the repair strategy with the highest probability of success is used in subsequent failures of the same type, thereby improving repair efficiency.
[0039] In an optional implementation, when it is determined that the third repair strategy is not any of the at least one repair strategy included in the historical repair data, the method further includes:
[0040] The third repair strategy is added to the historical repair data, and the number of successful repairs corresponding to the third repair strategy is set to one.
[0041] Specifically, since technicians may add new repair strategies based on actual situations, technicians can add new repair strategies to historical repair data accordingly to facilitate subsequent statistics and adjust weight index values for them, so that the target repair strategy table is more consistent with the actual situation and more accurate.
[0042] In an optional embodiment, the method further includes:
[0043] When a target trigger instruction is detected, obtaining current configuration information and preset configuration information of each of the network devices;
[0044] Determining whether the current configuration information of the target network device is consistent with the preset configuration information;
[0045] When it is determined that the current configuration information of the target network device is inconsistent with the preset configuration information, an alarm notification is generated according to the communication address of the target network device.
[0046] Specifically, by timely comparing the current configuration information of the network device with the preset configuration information, it can be discovered whether the configuration information of the network device has been modified incorrectly, so that technical personnel can make timely corrections to avoid more serious faults.
[0047] In an optional embodiment, when the target repair strategy table is an initial repair strategy table used when performing the initial detection operation corresponding to the target fault type, the target fault type is a loop fault, and the target network layer is the access layer, the first repair strategy is to restart the port, and the second repair strategy is to shut down the port.
[0048] Specifically, since the loop failure is likely to be caused by the access layer itself, when a loop failure occurs in the access layer, the port of the target network device can be restarted to determine whether the corresponding problem is solved after restarting the port. If it cannot be solved, the port can be closed to avoid more serious failures.
[0049] In a second aspect, the present invention provides a fault repair device, which is applied to a network fault detection system, wherein the network fault detection system includes a server and at least one network device, and the device includes:
[0050] a detection module, configured to, upon obtaining a detection instruction, perform a fault detection operation on each of the network devices according to the detection instruction, wherein the detection instruction includes a target fault type;
[0051] a receiving module, configured to receive a target log generated by any network device during the fault detection operation, wherein the target log includes a target event type, a target network level, and a target communication address;
[0052] A determination module, configured to determine whether the target event type is the target fault type;
[0053] an acquisition module, configured to, when determining that the target event type is the target fault type, acquire a target repair strategy table corresponding to the target fault type;
[0054] A repair module is used to perform a repair operation on the target network device corresponding to the target communication address according to the target network layer and the target repair strategy table.
[0055] In a third aspect, the present invention provides a computer device comprising: a memory and a processor, the memory and the processor being communicatively connected to each other, the memory storing computer instructions, and the processor executing the fault repair method of the first aspect or any corresponding embodiment thereof by executing the computer instructions.
[0056] In a fourth aspect, the present invention provides a computer-readable storage medium having computer instructions stored thereon, the computer instructions being used to enable a computer to execute the fault repair method of the first aspect or any corresponding embodiment thereof.
[0057] In a fifth aspect, the present invention provides a computer program product, comprising computer instructions for causing a computer to execute the fault repair method of the first aspect or any corresponding embodiment thereof. BRIEF DESCRIPTION OF THE DRAWINGS
[0058] In order to more clearly illustrate the specific embodiments of the present invention or the technical solutions in related technologies, the following briefly introduces the drawings required for use in the specific embodiments or related technical descriptions. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0059] Figure 1 is a schematic diagram of the architecture of a network fault detection system according to an embodiment of the present invention;
[0060] Figure 2 is a schematic diagram of the architecture of another network fault detection system according to an embodiment of the present invention;
[0061] Figure 3 is a flowchart of a fault repair method according to an embodiment of the present invention;
[0062] Figure 4 is a flowchart of another fault repair method according to an embodiment of the present invention;
[0063] Figure 5 is a structural block diagram of a fault repair device according to an embodiment of the present invention;
[0064] Figure 6 Schematic diagram of the hardware structure of a computer device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0065] To make the purpose, technical solutions, and advantages of the embodiments of the present invention more clear, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without making creative efforts shall fall within the scope of protection of the present invention.
[0066] The embodiment of the present invention provides a network fault detection system, such as Figure 1 As shown, the network fault detection system includes a server and at least one network device, wherein the network device can be a switch, a router, etc. The server establishes a network communication connection with each network device. In some optional implementations, the network layer is generally divided into a core layer, a convergence layer, and an access layer. Accordingly, when each network device is a switch, the architecture of the network fault detection system can be as follows: Figure 2 As shown, the server is first connected to the core layer switch, the core layer switch is connected to the aggregation layer switch, and the aggregation layer switch is then connected to the access layer switch.
[0067] Network devices may experience various errors during operation, such as disconnections between devices, configuration modifications, and other issues. To ensure the safe operation of the network fault detection system, the server can detect each network device connected to it and promptly restore it when a fault is detected.
[0068] In the above application scenario, an embodiment of the present invention provides a fault repair method, which improves the efficiency of the fault repair operation by automatically repairing the fault.
[0069] According to an embodiment of the present invention, an embodiment of a fault repair method is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0070] In this embodiment, a fault repair method is provided, which can be executed by the above-mentioned server. Figure 3 FIG. 1 is a flow chart of a fault repair method according to an embodiment of the present invention. Figure 3 As shown, the process includes the following steps:
[0071] Step S301: When a detection instruction is obtained, a fault detection operation is performed on each network device according to the detection instruction.
[0072] The detection instruction may include a target fault type, which may be a loop fault, link fault, hardware fault, configuration fault, etc. A loop fault refers to a situation where data packets in the network continuously circulate in one or more network paths.
[0073] Specifically, the technician can actively initiate a test, that is, can select a fault type on his own terminal, so that the terminal can generate a detection instruction according to the fault type selected by the technician and send it to the server.
[0074] Alternatively, the server may periodically generate detection instructions according to preset rules, which may be:
[0075] The server may store at least one fault type and a detection sequence corresponding to each fault type. In each cycle, the server may determine the fault type for the current detection cycle based on the fault type detected last time and the detection sequence corresponding to each fault type, and generate a detection instruction based on the fault type for the current detection cycle.
[0076] In some optional implementations, in order to improve the flexibility of detection, the detection instruction may further include identification information or communication address of at least one network device, so that the server can perform detection on a specified network device.
[0077] In some optional implementations, the server may also obtain the current configuration of each of its own resources, determine a first number of network devices currently detectable based on the number of network devices in the network fault detection system and a preset basic number, determine a second number of fault types detectable based on the current configuration of each of its own resources and basic configuration resource information for each fault type, and select the first number of network devices from at least one network device connected to the server for the second number of detections. For example, the resources may be network resources, computing resources, storage resources, etc.
[0078]
[0079] Wherein, N is the first number, D is the number of network devices in the network fault detection system, k is the preset basic number, i.e., the pre-specified basic number of network devices when detecting any type of fault, q is the total number of fault types, R net is the current remaining network resources of the server, R net is the current remaining computing resources of the server, R stor is the current remaining storage resource of the server, F i,net is the network resources required for the i-th fault type, F i,comp is the computing resources required for the i-th fault type, F i,compis the computing resources required for the i-th fault type, F i,stor is the storage resource required for the i-th fault type. net 、R net and R stor It constitutes the current resource configuration of the server itself.
[0080] In this way, the server can automatically initiate fault detection and perform fault recovery operations in a timely manner when its own resources are sufficient. When its own resources are insufficient, it does not perform fault detection and recovery operations, or performs relatively few fault detection and recovery operations to reasonably use resources.
[0081] Step S302: Receive a target log generated by any network device during the fault detection operation.
[0082] The target log may include the target event type, target network level, and target communication address.
[0083] Specifically, the server can integrate network management protocols such as System Log (SysLog) and Simple Network Management Protocol (SNMP). During the network device detection process, logs can be collected from the detected network devices through network management protocols. For each collected log, the server can use pre-built regular expressions or JavaScript Object Notation (JSON) to extract key information from the log, such as the log generation time, event source (for example, whether the log originated from a router or switch), physical location, event type, network layer, communication address, port information, etc. For example, the log can be shown in Table 1.
[0084] Table 1
[0085]
[0086] Step S303: Determine whether the target event type is a target fault type.
[0087] Step S304: When it is determined that the target event type is a target fault type, a target repair strategy table corresponding to the target fault type is obtained.
[0088] The target repair strategy table includes at least one network level, at least one repair strategy corresponding to each network level, and a weight index value corresponding to each repair strategy. For example, when the target fault type is a loop fault, the target repair strategy table corresponding to the target fault type can be shown in Table 2. Table 2 is the initial repair strategy table corresponding to the initial detection of a loop fault.
[0089] Table 2
[0090]
[0091]
[0092] Specifically, the server may store a fault strategy table corresponding to each fault type. The server may determine whether the target event type is the target fault type. When the target event type is determined to be the target fault type, it may be considered that the network device corresponding to the target communication address has a fault of the target fault type and needs to be repaired. At this point, the server may determine a target repair strategy table corresponding to the target fault type based on the target fault type. Alternatively, when it is determined that the target event type is not the target fault type, it may be considered that the network device corresponding to the target communication address does not have a fault of the target fault type and does not need to be repaired. At this point, the server may continue to process the next log.
[0093] Step S305 : performing a repair operation on the target network device corresponding to the target communication address according to the target network level and the target repair strategy table.
[0094] Specifically, because the causes of the same fault may be different at different network layers, the server can perform repair operations on the target network device according to the following steps:
[0095] Step 1: According to the target network level, at least one target repair strategy corresponding to the target network level is determined in the target repair strategy table.
[0096] Step 2: According to the weight index value corresponding to each target repair strategy, a first repair strategy with the largest weight index value is selected from at least one target repair strategy.
[0097] Step three: according to the first repair strategy, obtain a first repair script corresponding to the first repair strategy.
[0098] Step 4: Perform a first repair operation on the target network device according to the first repair script.
[0099] Step 5: Obtain the target time point for completing the first repair operation.
[0100] Step 6: Obtain at least one log generated by the target network device after the target time point.
[0101] Step 7: Determine whether there is a log of the target fault type in at least one log.
[0102] Step eight: when it is determined that the log of the target fault type does not exist in the at least one log, it is determined that the fault corresponding to the target fault type in the target network device has been repaired.
[0103] Step nine: when it is determined that at least one log contains a log of the target fault type, a second repair strategy is selected from the at least one target repair strategy according to a weight index value corresponding to each repair strategy.
[0104] The weight index value of the second repair strategy is smaller than the weight index value of the first repair strategy, and is larger than the weight index values of other repair strategies except the first repair strategy in the target repair strategy table.
[0105] Step 10: Adjust the weight index value of the second repair strategy to a value greater than the weight index value of the first repair strategy, so that the weight index value of the second repair strategy is the adjusted strategy with the largest weight index value among at least one repair strategy.
[0106] Step 11: According to the second repair strategy, obtain a second repair script corresponding to the second repair strategy.
[0107] Step 12: Perform a second repair operation on the target network device according to the second repair script.
[0108] In Table 2, when the target network layer is the access layer, the first repair strategy is to restart the port and the second repair strategy is to shut down the port; or, when the target network layer is the core layer or the aggregation layer, the first repair strategy is to ignore and the second repair strategy is to restart the port.
[0109] For example, the target fault type is a loop fault, and the target network layer is the core layer. In step one, three target repair strategies corresponding to the "core layer" can be determined, namely "Ignore", "Restart Port" and "Close Port". The weight index values corresponding to these three target repair strategies are "100", "99" and "98" respectively. The target repair strategy with the largest weight index value is "Ignore", that is, the first repair strategy is "Ignore". The server can obtain the first repair script according to the first repair strategy and perform the first repair operation. After completing the first repair operation, the server can record the target time point for completing the first repair operation, and select the log after the target time point from the received log for specific analysis, that is, determine whether the event type in the log is the target fault type. If so, it is determined that the fault of the target fault type in the server has not been repaired. If not, it is determined that the fault of the target fault type in the server has been repaired.
[0110] If it is determined that the target fault type in the server has not been repaired, the server can select the target repair strategy "Restart Port" with the second largest weight index value, that is, the second repair strategy is "Restart Port". Then, the server can adjust the weight index value of the second repair strategy to "100" and the weight index value of the first repair strategy to "99". At this time, the second repair strategy in the target repair strategy corresponding to the "core layer" is the target repair strategy with the largest weight index value. Similarly, the server can obtain the second repair script based on the second repair strategy and execute the second repair operation, and so on, to complete the entire repair operation process.
[0111] For example, after the weight index value is modified, the target repair strategy table may be as shown in Table 3.
[0112] Table 3
[0113]
[0114]
[0115] In some optional implementations, when the server has performed repair operations according to all target repair strategies corresponding to the target network layer, and the target fault type of the server has not been repaired, the server can generate a first alarm notification (the first alarm notification may include information such as the communication address, network layer and physical location of the target network device) and send it to the terminal where the technician is located to resolve it through manual intervention, so that all faults can be resolved in a timely manner.
[0116] In some optional implementations, after the repair operation is successfully completed using a target repair strategy (e.g., the third repair strategy) corresponding to the target network layer, the server may further update the target repair strategy table according to the third repair strategy. Accordingly, the update may be performed through the following specific steps:
[0117] Step 1: Obtain historical repair data corresponding to the target fault type and target network layer.
[0118] The historical repair data may include at least one repair strategy and the number of successful repairs for each repair strategy.
[0119] Step 2: Determine whether the third repair strategy is one of the at least one repair strategy included in the historical repair data.
[0120] The third repair strategy is a strategy for successfully repairing the target network device, and may be the first repair strategy or the second repair strategy mentioned above.
[0121] Step three: when it is determined that the third repair strategy is one of the at least one repair strategy included in the historical repair data, the number of successful repairs corresponding to the third repair strategy is updated.
[0122] Step 4: Determine the weight index value of each repair strategy in the historical repair data according to the number of successful repairs corresponding to each repair strategy in the historical repair data.
[0123] Step 5: Update the target repair strategy table according to the weight index value of each repair strategy in the historical repair data.
[0124] Step six: when it is determined that the third repair strategy is not any of the at least one repair strategy included in the historical repair data, the first repair strategy is added to the historical repair data, and the number of successful repairs corresponding to the third repair strategy is set to one.
[0125] In some optional implementations, the server may update the target repair strategy table each time after executing a repair operation, regardless of success or failure. Accordingly, the update may be performed through the following specific steps:
[0126] Step 1: Obtain historical repair data corresponding to the target fault type and target network layer.
[0127] Among them, the historical repair data may include at least one repair strategy, as well as the number of successful repairs, the number of failed repairs, the total number of repairs for each repair strategy, and the first proportion of the number of successful repairs in the total number of repairs and the second proportion of the number of failed repairs in the total number of repairs.
[0128] Step 2: Determine whether the fourth repair strategy is one of the at least one repair strategy included in the historical repair data.
[0129] Among them, the fourth repair strategy is any target repair strategy.
[0130] Step three: when it is determined that the third repair strategy is one of the at least one repair strategy included in the historical repair data, the number of successful repairs, number of failed repairs, total number of repairs, first ratio and second ratio corresponding to the fourth repair strategy are updated respectively.
[0131] Step 4: Determine a weight index value for each repair strategy in the historical repair data according to the first ratio or the second ratio corresponding to each repair strategy in the historical repair data.
[0132] The first ratio is directly proportional to the weight index value, and the second ratio is inversely proportional to the weight index value.
[0133] Step 5: Update the target repair strategy table according to the weight index value of each repair strategy in the historical repair data.
[0134] Step six: When it is determined that the fourth repair strategy is not any of the at least one repair strategy included in the historical repair data, the fourth repair strategy is added to the historical repair data, and the number of successful repairs, number of failed repairs, total number of repairs, first ratio and second ratio corresponding to the fourth repair strategy are updated.
[0135] The fault repair method provided in this embodiment allows the server to, upon receiving a detection instruction, perform a fault detection operation based on the target fault type carried in the detection instruction, collect target logs from the fault detection operation, and, upon determining that the target event type in the target log is the target fault type, perform a repair operation on the target network device using the target repair strategy table and target network level corresponding to the target fault type. Throughout the entire detection process, the server can automatically perform fault repair operations, eliminating the need for technical personnel to perform complex analysis and troubleshooting, thereby improving the efficiency of fault repair operations.
[0136] Since the configuration information failure of the network device is a serious problem, in addition to the log detection, this embodiment provides a fault repair method specifically for detecting the configuration failure of the network device, which can be executed by the above-mentioned server. Figure 4 FIG. 1 is a flow chart of a fault repair method according to an embodiment of the present invention. Figure 4 As shown, the process includes the following steps:
[0137] Step S401: When a target trigger instruction is detected, current configuration information and preset configuration information of each network device are obtained.
[0138] The configuration information may include identification information, communication address, network level, physical location, port information, host name, etc. of the network device.
[0139] Specifically, the server can periodically generate target trigger instructions, or a technician can perform configuration detection operations on the terminal, so that the terminal generates a target trigger instruction based on the technician's operation and sends it to the server. In this way, the server can detect the target trigger instruction and obtain the communication address of each network device connected to it. Furthermore, based on the communication address of each network device, it can obtain the current configuration information and preset configuration information of each network device.
[0140] In some optional implementations, the server can use Ansible's Expect script to capture the configuration information of the network device. For example, the Expect script can be as follows:
[0141] "#! / usr / bin / expect
[0142] set timeout 10
[0143] setipaddr[lindex$argv 0]
[0144] setcmd[lindex$argv 1]
[0145] set username AAA
[0146] set password 123456
[0147] spawnsshruijie@$ipaddr
[0148] expect"*password:"{send"$password\n"}
[0149] expect"#"{send"configure terminal\n"}
[0150] expect"#"{send"$cmd\n"}
[0151] expect"#"{send"end\n"}
[0152] expect"#"{send"wr\n"}
[0153] expect"#"{send"exit\n"}
[0154] expect eof”
[0155] The script begins by setting several variables, including the timeout (timeout), the communication address of the network device to connect to (ipaddr), the command to execute (cmd), the username (username), and the password (password). It then uses the spawn command to start a new SSH session. When prompted with "*password:", it sends the password. After a successful login, it waits for the "#" prompt to appear. It then sends the "configure terminal" command, the user-defined command ($cmd), the end of the configuration (end), the save configuration (wr), and the exit (exit) command.
[0156] Step S402: Determine whether the current configuration information of the target network device is consistent with the preset configuration information.
[0157] Step S403: When it is determined that the current configuration information of the target network device is inconsistent with the preset configuration information, an alarm notification is generated according to the communication address of the target network device.
[0158] Specifically, for a target network device, the server compares each item in its current configuration with each item in its preset configuration. If any item is inconsistent, it is considered configuration drift. In this case, the server generates an alert based on the target network device's communication address and sends it to a technician's terminal, allowing the technician to modify the configuration.
[0159] The fault repair method provided in this embodiment can detect whether the configuration information of the network device has been modified incorrectly by timely comparing the current configuration information of the network device with the preset configuration information, so that technical personnel can make timely corrections to avoid more serious faults.
[0160] This embodiment also provides a fault recovery device for implementing the above-mentioned embodiments and preferred implementations. Details already described will not be repeated. As used below, the term "module" may refer to a combination of software and / or hardware that implements a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, implementation using hardware, or a combination of software and hardware, is also possible and contemplated.
[0161] This embodiment provides a fault repair device, such as Figure 5 Shown, including:
[0162] The detection module 501 is configured to perform a fault detection operation on each network device according to the detection instruction when a detection instruction is obtained, wherein the detection instruction includes a target fault type;
[0163] A receiving module 502 is configured to receive a target log generated by any network device during a fault detection operation, wherein the target log includes a target event type, a target network level, and a target communication address;
[0164] Determination module 503, used to determine whether the target event type is a target fault type;
[0165] An acquisition module 504 is configured to acquire a target repair strategy table corresponding to the target fault type when the target event type is determined to be a target fault type;
[0166] The repair module 505 is configured to perform a repair operation on the target network device corresponding to the target communication address according to the target network layer and the target repair policy table.
[0167] In some optional embodiments, the target repair strategy table includes at least one network level, at least one repair strategy corresponding to each network level, and a weight index value corresponding to each repair strategy;
[0168] The repair module 505 is specifically used to:
[0169] Determining, according to the target network level, at least one target repair strategy corresponding to the target network level in the target repair strategy table;
[0170] According to the weight index value corresponding to each target repair strategy, a first repair strategy with the largest weight index value is selected from at least one target repair strategy;
[0171] According to the first repair strategy, obtaining a first repair script corresponding to the first repair strategy;
[0172] According to the first repair script, a first repair operation is performed on the target network device.
[0173] In some optional implementations, the repair module 505 is further configured to:
[0174] Obtaining a target time point for completing the first repair operation;
[0175] Obtain at least one log generated by the target network device after the target time point;
[0176] Determine whether there is a log of the target fault type in at least one log;
[0177] When it is determined that no log of the target fault type exists in the at least one log, determining that the fault corresponding to the target fault type in the target network device has been repaired;
[0178] or,
[0179] When it is determined that at least one log contains a log of the target fault type, a second repair strategy is selected from at least one target repair strategy according to the weight index value corresponding to each repair strategy, wherein the weight index value of the second repair strategy is less than the weight index value of the first repair strategy and greater than the weight index values of other repair strategies in the target repair strategy table except the first repair strategy;
[0180] Adjusting the weight index value of the second repair strategy to a value greater than the weight index value of the first repair strategy, so that the weight index value of the second repair strategy is the adjustment strategy with the largest weight index value among the at least one repair strategy;
[0181] According to the second repair strategy, obtaining a second repair script corresponding to the second repair strategy;
[0182] According to the second repair script, a second repair operation is performed on the target network device.
[0183] In some optional implementations, the repair module 505 is further configured to:
[0184] Obtaining historical repair data corresponding to a target fault type and a target network level, wherein the historical repair data includes at least one repair strategy and the number of successful repairs for each repair strategy;
[0185] Determining whether the third repair strategy is one of the at least one repair strategy included in the historical repair data, wherein the third repair strategy is a strategy that successfully repairs the target network device;
[0186] When it is determined that the third repair strategy is one of the at least one repair strategy included in the historical repair data, updating the number of successful repairs corresponding to the third repair strategy;
[0187] Determine the weight index value of each repair strategy in the historical repair data according to the number of successful repairs corresponding to each repair strategy in the historical repair data;
[0188] The target repair strategy table is updated according to the weight index value of each repair strategy in the historical repair data.
[0189] In some optional implementations, the repair module 505 is further configured to:
[0190] When it is determined that the third repair strategy is not any of the at least one repair strategy included in the historical repair data, the third repair strategy is added to the historical repair data, and the number of successful repairs corresponding to the third repair strategy is set to one.
[0191] In some optional implementations, the determining module 503 is further configured to:
[0192] When a target trigger instruction is detected, the current configuration information and preset configuration information of each network device are obtained;
[0193] Determine whether the current configuration information of the target network device is consistent with the preset configuration information;
[0194] When it is determined that the current configuration information of the target network device is inconsistent with the preset configuration information, an alarm notification is generated according to the communication address of the target network device.
[0195] In some optional embodiments, when the target repair strategy table is an initial repair strategy table used when performing the initial detection operation corresponding to the target fault type, the target fault type is a loop fault, and the target network layer is the access layer, the first repair strategy is to restart the port, and the second repair strategy is to shut down the port.
[0196] The further functional description of each of the above modules and units is the same as that of the above corresponding embodiments and will not be repeated here.
[0197] The fault repair device in this embodiment is presented in the form of a functional unit, where the unit refers to an ASIC (Application Specific Integrated Circuit) circuit, a processor and memory that executes one or more software or fixed programs, and / or other devices that can provide the above functions.
[0198] The embodiment of the present invention also provides a computer device having the above Figure 5 Fault repair device shown.
[0199] See also Figure 6 , Figure 6 is a structural diagram of a computer device provided by an optional embodiment of the present invention, such as Figure 6As shown, the computer device includes: one or more processors 10, memory 20, and interfaces for connecting various components, including high-speed interfaces and low-speed interfaces. Various components utilize different buses to communicate with each other and can be installed on a common mainboard or installed in other ways as needed. The processor can process the instructions executed in the computer device, including instructions stored in the memory or on the memory to display the graphical information of the GUI on an external input / output device (such as, a display device coupled to the interface). In some optional embodiments, if necessary, multiple processors and / or multiple buses can be used together with multiple memories and multiple memories. Equally, multiple computer devices can be connected, and each device provides part of the necessary operations (for example, as a server array, a group of blade servers, or a multi-processor system). Figure 6 A processor 10 is taken as an example.
[0200] The processor 10 may be a central processing unit, a network processor, or a combination thereof. The processor 10 may further include a hardware integrated circuit. The hardware integrated circuit may be an application-specific integrated circuit, a programmable logic device, or a combination thereof. The programmable logic device may be a complex programmable logic device, a field programmable gate array, a general purpose array logic, or any combination thereof.
[0201] The memory 20 stores instructions that can be executed by at least one processor 10, so that the at least one processor 10 executes the method shown in the above embodiment.
[0202] The memory 20 may include a program storage area and a data storage area, wherein the program storage area may store an operating system and application programs required for at least one function; the data storage area may store data created based on the use of the computer device, etc. In addition, the memory 20 may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some optional embodiments, the memory 20 may optionally include a memory remotely located relative to the processor 10, and these remote memories may be connected to the computer device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0203] The memory 20 may include a volatile memory, such as a random access memory; the memory may also include a non-volatile memory, such as a flash memory, a hard disk or a solid-state drive; the memory 20 may also include a combination of the above types of memory.
[0204] The computer device further includes a communication interface 30 for the computer device to communicate with other devices or a communication network.
[0205] The embodiment of the present invention also provides a computer-readable storage medium. The above-mentioned method according to the embodiment of the present invention can be implemented in hardware, firmware, or implemented as a computer code that can be recorded in a storage medium, or implemented as a computer code that is originally stored in a remote storage medium or a non-temporary machine-readable storage medium and downloaded through a network and will be stored in a local storage medium, so that the method described herein can be stored in such software processing on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware. Among them, the storage medium can be a magnetic disk, an optical disk, a read-only storage memory, a random access memory, a flash memory, a hard disk or a solid-state drive, etc.; further, the storage medium can also include a combination of the above-mentioned types of memory. It can be understood that a computer, a processor, a microprocessor controller or programmable hardware includes a storage component that can store or receive software or computer code. When the software or computer code is accessed and executed by a computer, a processor or hardware, the method shown in the above embodiment is implemented.
[0206] A portion of the present invention may be applied as a computer program product, such as a computer program instruction, which, when executed by a computer, can call or provide the method and / or technical solution according to the present invention through the operation of the computer. Those skilled in the art should understand that the form in which the computer program instruction exists in a computer-readable medium includes, but is not limited to, a source file, an executable file, an installation package file, etc. Accordingly, the way in which the computer program instruction is executed by the computer includes, but is not limited to: the computer directly executes the instruction, or the computer compiles the instruction and then executes the corresponding compiled program, or the computer reads and executes the instruction, or the computer reads and installs the instruction and then executes the corresponding installed program. Here, the computer-readable medium may be any available computer-readable storage medium or communication medium that can be accessed by the computer.
[0207] Although the embodiments of the present invention have been described with reference to the accompanying drawings, those skilled in the art may make various modifications and variations without departing from the spirit and scope of the present invention. Such modifications and variations are all within the scope defined by the appended claims.
Claims
1. A fault repair method, characterized in that: The method is applied to a network fault detection system, which includes a server and at least one network device. The method is executed by the server and includes: When a detection instruction is obtained, performing a fault detection operation on each of the network devices according to the detection instruction, wherein the detection instruction includes a target fault type; receiving a target log generated by any network device during the fault detection operation, wherein the target log includes a target event type, a target network level, and a target communication address; determining whether the target event type is the target fault type; When it is determined that the target event type is the target fault type, obtaining a target repair strategy table corresponding to the target fault type, wherein the target repair strategy table includes at least one network layer, at least one repair strategy corresponding to each of the network layers, and a weight index value corresponding to each of the repair strategies; Determining, according to the target network level, at least one target repair strategy corresponding to the target network level in the target repair strategy table; According to the weight index value corresponding to each target repair strategy, a first repair strategy with the largest weight index value is selected from at least one target repair strategy; According to the first repair strategy, obtaining a first repair script corresponding to the first repair strategy; According to the first repair script, a first repair operation is performed on the target network device corresponding to the target communication address.
2. The method according to claim 1, characterized in that After performing the first repair operation on the target network device according to the first repair script, the method further includes: Obtaining a target time point for completing the first repair operation; Obtain at least one log generated by the target network device after the target time point; Determine whether there is a log of the target fault type in at least one of the logs; When it is determined that the log of the target fault type does not exist in at least one of the logs, determining that the fault corresponding to the target fault type in the target network device has been repaired; or, When it is determined that at least one of the logs contains a log of the target fault type, a second repair strategy is selected from at least one of the target repair strategies based on the weight index value corresponding to each of the repair strategies, wherein the weight index value of the second repair strategy is less than the weight index value of the first repair strategy and greater than the weight index values of other repair strategies in the target repair strategy table except the first repair strategy; Adjusting the weight index value of the second repair strategy to a value greater than the weight index value of the first repair strategy, so that the weight index value of the second repair strategy is the adjustment strategy with the largest weight index value among at least one of the repair strategies; According to the second repair strategy, obtaining a second repair script corresponding to the second repair strategy; A second repair operation is performed on the target network device according to the second repair script.
3. The method according to claim 2, characterized in that The method further comprises: Acquire historical repair data corresponding to both the target fault type and the target network level, wherein the historical repair data includes at least one repair strategy and the number of successful repairs corresponding to each repair strategy; Determining whether a third repair strategy is one of the at least one repair strategy included in the historical repair data, wherein the third repair strategy is a strategy that successfully repairs the target network device; When it is determined that the third repair strategy is one of the at least one repair strategy included in the historical repair data, updating the number of successful repairs corresponding to the third repair strategy; Determining a weight index value for each of the repair strategies in the historical repair data according to the number of successful repairs corresponding to each of the repair strategies in the historical repair data; The target repair strategy table is updated according to the weight index value of each repair strategy in the historical repair data.
4. The method according to claim 3, characterized in that When it is determined that the third repair strategy is not any of the at least one repair strategy included in the historical repair data, the method further includes: The third repair strategy is added to the historical repair data, and the number of successful repairs corresponding to the third repair strategy is set to one.
5. The method according to any one of claims 1 to 4, characterized in that The method further comprises: When a target trigger instruction is detected, obtaining current configuration information and preset configuration information of each of the network devices; Determining whether the current configuration information of the target network device is consistent with the preset configuration information; When it is determined that the current configuration information of the target network device is inconsistent with the preset configuration information, an alarm notification is generated according to the communication address of the target network device.
6. The method according to claim 2 or 3, characterized in that When the target repair strategy table is an initial repair strategy table used when performing the initial detection operation corresponding to the target fault type, the target fault type is a loop fault, and the target network layer is the access layer, the first repair strategy is to restart the port and the second repair strategy is to shut down the port.
7. A fault repair device, characterized in that: The device is applied to a network fault detection system, wherein the network fault detection system includes a server and at least one network device, and the device includes: a detection module, configured to, upon obtaining a detection instruction, perform a fault detection operation on each of the network devices according to the detection instruction, wherein the detection instruction includes a target fault type; a receiving module, configured to receive a target log generated by any network device during the fault detection operation, wherein the target log includes a target event type, a target network level, and a target communication address; A determination module, configured to determine whether the target event type is the target fault type; an acquisition module, configured to, when determining that the target event type is the target fault type, acquire a target repair strategy table corresponding to the target fault type, wherein the target repair strategy table includes at least one network layer, at least one repair strategy corresponding to each of the network layers, and a weight index value corresponding to each of the repair strategies; A repair module is used to determine, in the target repair strategy table, at least one target repair strategy corresponding to the target network level according to the target network level; select, according to the weight index value corresponding to each of the target repair strategies, a first repair strategy with the largest weight index value among at least one of the target repair strategies; obtain, according to the first repair strategy, a first repair script corresponding to the first repair strategy; and perform a first repair operation on the target network device corresponding to the target communication address according to the first repair script.
8. A computer device, characterized in that: include: A memory and a processor, wherein the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the fault repair method according to any one of claims 1 to 6 by executing the computer instructions.
9. A computer-readable storage medium, characterized in that The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a computer to execute the fault repair method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Fault repairing method and device, computer equipment and storage medium
CN110191003A
Container repairing method and device, computer storage medium and electronic equipment
CN116541198A