Log collection method, device and equipment, computer readable storage medium and product
By collecting and predicting the load indicators of the management equipment, judging the device's steady state and selecting the target equipment for log collection, the problem of coordination between log collection and system business is solved, and efficient execution of system business is achieved.
Patent Information
- Application Number
- CN202510644733.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-19
- Publication Date
- 2025-08-08
AI Technical Summary
In the prior art, log collection and system business cannot be coordinated, resulting in a decrease in system business execution efficiency.
By collecting preset load indicators of management equipment, predicting the value of load indicators, and judging the device steady state based on the collected value and predicted value, selecting the target device for log collection, achieving a balance between log collection and system services.
Effectively avoid network congestion and high loads, and ensure efficient execution of system services.
Smart Images

Figure CN120455263A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a log collection method, apparatus, device, computer-readable storage medium, and product. Background Art
[0002] The log of a service device is a detailed record of events, operations, status changes, etc. that occur during the operation of the device. The log usually includes the startup and shutdown time of the device, fault information, user operations, configuration changes, etc. At present, the log management of service devices mainly uses log management tools such as Syslog to collect, parse, store or forward the logs of service devices. For the scenario of single log management of multiple devices, the relevant solutions are often unable to effectively balance the performance of device resources, and are unable to dynamically coordinate log collection with system services. There are situations where the efficiency of business execution is affected due to the occupation of system resources by log collection. Therefore, how to coordinate log collection with system services to prevent the impact on the efficiency of system business execution has become a technical problem that needs to be solved urgently by those skilled in the art. Summary of the Invention
[0003] The present application provides a log collection method, apparatus, device, computer-readable storage medium, and product to at least solve the problem in related technologies that log collection cannot be coordinated with system services, thereby affecting the execution efficiency of system services.
[0004] This application provides a log collection method, including:
[0005] Collecting a preset load indicator and obtaining a collection value of the preset load indicator;
[0006] Obtaining a predicted value of the preset load indicator according to the collected value of the preset load indicator;
[0007] Determining whether the management device is in a steady state based on the collected value and the predicted value of the preset load indicator;
[0008] If the management device is in a steady state, a target device is selected from each managed device, and target information is sent to the target device, so that the target device transmits a log according to the target information.
[0009] This application also provides a log collection device, including:
[0010] A collection module, used to collect a preset load indicator and obtain a collection value of the preset load indicator;
[0011] A prediction module, configured to predict a predicted value of the preset load indicator based on the collected value of the preset load indicator;
[0012] A judgment module, configured to judge whether the management device is in a steady state based on the collected value and the predicted value of the preset load indicator;
[0013] The sending module is used to select a target device from each managed device if the management device is in a steady state, and send target information to the target device, so that the target device transmits a log according to the target information.
[0014] The present application also provides an electronic device, comprising: a memory for storing a computer program; and a processor for implementing the steps of any of the above-mentioned log collection methods when executing the computer program.
[0015] The present application also provides a computer-readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, the steps of any of the above-mentioned log collection methods are implemented.
[0016] The present application also provides a computer program product, including a computer program, which implements the steps of any of the above-mentioned log collection methods when executed by a processor.
[0017] This application determines whether the management device is in a steady state based on the load condition of the management device itself. When the management device is in a steady state, the logs of the managed devices are collected. This can achieve a balance between log collection and system business, avoid the occurrence of scenarios such as network congestion and high load, and solve the problem of being unable to coordinate log collection and system business, affecting the execution efficiency of system business. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] In order to more clearly illustrate the embodiments of the present application, the following is a brief introduction to the drawings required for use in the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0019] Figure 1 A flow chart of a log collection method provided in an embodiment of the present application;
[0020] Figure 2 A log collection process diagram provided in an embodiment of the present application;
[0021] Figure 3 A schematic diagram of a log collection device provided in an embodiment of the present application;
[0022] Figure 4 A schematic diagram of a log collection device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0023] The following will be combined with the accompanying drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are only part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.
[0024] It should be noted that, in the description of this application, the terms "comprises," "includes," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or device. The terms "first," "second," etc., in this application are used to distinguish similar objects, and are not used to describe a particular order or sequence.
[0025] In order to enable those skilled in the art to better understand the present application, the present application is further described in detail below with reference to the accompanying drawings and specific implementation methods.
[0026] An embodiment of the present application provides a log collection method. Combined with the execution process of the log collection method, the method is described in detail below.
[0027] refer to Figure 1 As shown, the log collection method provided in the embodiment of the present application includes:
[0028] S101: Collecting a preset load indicator and obtaining a collection value of the preset load indicator.
[0029] The execution entity of the embodiments of the present application is a management device. After configuring the log collection policy, the management device initiates a scheduled indicator collection task. This task periodically collects and caches the management device's preset load indicators. Preset load indicators are pre-set load indicators, such as CPU (Central Processing Unit) load.
[0030] In some embodiments, collecting a preset load indicator and obtaining a collected value of the preset load indicator includes:
[0031] Collecting the processor load and the memory load to obtain collected values of the processor load and the memory load.
[0032] The preset load indicators in this embodiment include processor load, i.e., CPU load, and memory load. CPU load refers to the load condition of the CPU, which can be represented by CPU usage. CPU usage refers to the proportion of time consumed by the computer's CPU when processing tasks and processes, usually expressed as a percentage. 100% represents full utilization of the CPU's processing power. Memory load refers to the load condition of the memory, which can be represented by memory utilization. Memory utilization refers to the proportion of physical memory currently being used by the system to the total available memory. The calculation formula for memory utilization is: memory utilization = (used memory / total memory) * 100%.
[0033] S102: Obtain a predicted value of the preset load indicator according to the collected value of the preset load indicator.
[0034] The indicator prediction task schedules the indicator timing collection task to collect the collection value of the preset load indicator, and predicts the predicted value of the preset load indicator based on the collection value of the preset load indicator.
[0035] In the case where the processor load and the memory load are collected to obtain the collected values of the processor load and the memory load, correspondingly, in some embodiments, obtaining the predicted value of the preset load indicator according to the collected value of the preset load indicator includes:
[0036] The predicted value of the processor load is obtained based on the collected value of the processor load, and the predicted value of the memory load is obtained based on the collected value of the memory load.
[0037] In some embodiments, predicting the predicted value of the preset load indicator according to the collected value of the preset load indicator includes:
[0038] A predicted value of the preset load indicator is predicted based on a preset number of collected values of the preset load indicator, a linear regression coefficient corresponding to the collected values, a preset constant, and a preset error amount.
[0039] This embodiment uses a linear regression algorithm to predict the predicted value of the preset load indicator based on the collected value of the preset load indicator.
[0040] For example, if the preset number is 6, the predicted value of the preset load index predicted by the linear regression algorithm can be expressed as follows:
[0041] .
[0042] In the above formula, is a constant, ~ is the linear regression coefficient, is the error amount, y is the predicted value, ~ is the collected value.
[0043] ~ When the collected values of the CPU load are collected at different times, the predicted value of the CPU load can be obtained based on the above formula.
[0044] ~ When the memory load is collected at different times, a predicted value of the memory load can be obtained based on the above formula.
[0045] In some embodiments, before obtaining the predicted value of the preset load indicator according to the collected value of the preset load indicator, the method further includes:
[0046] Determining whether the number of collected values of the preset load indicator reaches a preset number;
[0047] If the number of collected values of the preset load indicator reaches the preset number, a predicted value of the preset load indicator is obtained according to the collected values of the preset load indicator.
[0048] If the number of collected values of the preset load indicator reaches a preset number, it is considered that the collected values of the preset load indicator satisfy the prediction model, and the predicted value of the preset load indicator is predicted based on the collected values of the preset load indicator. If the number of collected values of the preset load indicator does not reach the preset number, it is considered that the collected values of the preset load indicator do not satisfy the prediction model, and the preset load indicator is not predicted based on the collected values of the preset load indicator. After the number of collected values of the preset load indicator reaches the preset number, the predicted value of the preset load indicator is predicted based on the collected values of the preset load indicator.
[0049] For example, when predicting a preset load indicator based on the aforementioned linear regression formula, the preset number is set to 6. If the number of collected values of the preset load indicator reaches 6, the collected values of the preset load indicator are deemed to satisfy the prediction model (in this case, the aforementioned linear regression formula), and the predicted value of the preset load indicator is then predicted based on the collected values of the preset load indicator. If the number of collected values of the preset load indicator does not reach 6, the collected values of the preset load indicator are deemed to not satisfy the prediction model, and the preset load indicator is not predicted based on the collected values of the preset load indicator. After the number of collected values of the preset load indicator reaches 6, the predicted value of the preset load indicator is predicted based on the collected values of the preset load indicator.
[0050] S103: Determine whether the management device is in a steady state based on the collected value and the predicted value of the preset load indicator.
[0051] Based on the collected and predicted values of the preset load indicators, the status of the management device is evaluated to determine whether the management device is in a steady state. Steady state refers to a stable state, which mainly means that the preset load indicators of the management device are stable and maintained at a low load.
[0052] In some embodiments, judging whether the management device is in a steady state according to the collected value and the predicted value of the preset load indicator includes:
[0053] Determining whether the collected value and the predicted value of each of the preset load indicators are both less than the corresponding threshold value;
[0054] If the collected value and the predicted value of each of the preset load indicators are both less than the corresponding threshold value, the management device is in a steady state;
[0055] If the collected value or predicted value of each of the preset load indicators is greater than the corresponding threshold value, the management device is not in a steady state.
[0056] If the log collection task is not started, determine whether the collected value and predicted value of the preset load indicator are both less than the corresponding threshold. If the collected value and predicted value of each preset load indicator are both less than the corresponding threshold, the management device is considered to be in a steady state. Otherwise, the management device is not in a steady state.
[0057] When the log collection task is started, it is determined whether the collected values or predicted values of the preset load indicators are all greater than the corresponding thresholds. If the collected values or predicted values of the preset load indicators are greater than the corresponding thresholds, the management device is not in a steady state.
[0058] Based on the embodiment in which the preset load indicator includes processor load and memory load, in some embodiments, determining whether the management device is in a steady state based on the collected value and predicted value of the preset load indicator includes:
[0059] When the log collection task is not started, determining whether a current collected value of the processor load is less than a corresponding threshold, and a predicted value of the processor load is less than a corresponding threshold, and a current collected value of the memory load is less than a corresponding threshold, and a predicted value of the memory load is less than a corresponding threshold;
[0060] If the currently collected value of the processor load is less than the corresponding threshold value, and the predicted value of the processor load is less than the corresponding threshold value, and the currently collected value of the memory load is less than the corresponding threshold value, and the predicted value of the memory load is less than the corresponding threshold value, then the management device is in a steady state;
[0061] When the log collection task is started, determining whether the current collected value of the processor load is greater than the corresponding threshold or the predicted value of the processor load is greater than the corresponding threshold, and whether the current collected value of the memory load is greater than the corresponding threshold or the predicted value of the memory load is greater than the corresponding threshold;
[0062] If the currently collected value of the processor load is greater than the corresponding threshold or the predicted value of the processor load is greater than the corresponding threshold, and the currently collected value of the memory load is greater than the corresponding threshold or the predicted value of the memory load is greater than the corresponding threshold, the management device is not in a steady state;
[0063] Among them, the predicted value of the processor load is predicted based on a preset number of collected values of the processor load, the linear regression coefficient corresponding to the collected values of the processor load, a preset constant and a preset error amount; the predicted value of the memory load is predicted based on a preset number of collected values of the memory load, the linear regression coefficient corresponding to the collected values of the memory load, a preset constant and a preset error amount.
[0064] The collected and predicted values of the processor load, i.e., the CPU load and the memory load, are both less than the corresponding thresholds, which can be expressed as follows:
[0065] . (1)
[0066] in, is the current collection value of the CPU load, is the predicted value of CPU load, The threshold corresponding to the CPU load. is the current collection value of the memory load, is the predicted value of memory load, The threshold corresponding to the memory load.
[0067] When the log collection task is not started, if the above formula (1) holds true, that is, the collected value and the predicted value of the CPU load are both less than the corresponding threshold, and the collected value and the predicted value of the memory load are both less than the corresponding threshold, then it is considered that the management device is in a steady state and the log collection task can be started.
[0068] If the collected or predicted values of the processor load and memory load are greater than the corresponding thresholds, it can be represented as follows:
[0069] . (2)
[0070] in, is the current collection value of the CPU load, is the predicted value of CPU load, The threshold corresponding to the CPU load. is the current collection value of the memory load, is the predicted value of memory load, The threshold corresponding to the memory load.
[0071] When the log collection task has been started, if the above formula (2) holds true, that is, the collected value of the CPU load is greater than the corresponding threshold or the predicted value of the CPU load is greater than the corresponding threshold, and the collected value of the memory load is greater than the corresponding threshold or the predicted value of the memory load is greater than the corresponding threshold, then it is considered that the management device is not in a steady state and the log collection task can be suspended.
[0072] The steady state judgment solution provided in this embodiment can avoid resource overhead caused by starting / pausing log collection tasks due to excessive instantaneous sampling.
[0073] S104: If the management device is in a steady state, a target device is selected from each managed device, and target information is sent to the target device, so that the target device transmits a log according to the target information.
[0074] If the log collection task is not started and the management device is in a stable state, you can start the log collection task, select a target device from among the managed devices, and send log collection information to the target device. The target device then transmits logs to the management device based on the log collection information. If the log collection task is already started and the management device is not in a stable state, you can pause the task.
[0075] In some embodiments, selecting a target device from among the managed devices includes:
[0076] Determining the weight of the managed device;
[0077] The managed device with the largest weight is selected as the target device.
[0078] This embodiment collects logs from highly weighted managed devices first. The management device calculates the weight of each managed device and selects the device with the highest weight as the target device. The management device sends log collection information to the target device, causing it to transmit logs based on the log collection information.
[0079] In some embodiments, determining the weight of the managed device includes:
[0080] The weight of the managed device is calculated based on the number of remaining log blocks of the managed device, the maximum number of log blocks of each managed device, the maximum log block time of each managed device, and the time required for log block collection of the managed device.
[0081] The number of remaining log blocks refers to the number of remaining untransmitted log blocks. The maximum number of log blocks for each managed device refers to the maximum value among the numbers of log blocks for each managed device. For example, the managed devices include managed device A and managed device B, the number of log blocks for managed device A is 4, and the number of log blocks for managed device B is 6, then the maximum number of log blocks for each managed device is 6. The maximum log block time for each managed device refers to the maximum time required for each managed device to complete log block segmentation. For example, the managed devices include managed device A and managed device B, the log block block time for managed device A is 10s, and the number of log blocks for managed device B is 7s, then the maximum log block block time for each managed device is 10s. The time required for log block collection of a managed device refers to the time required to collect log blocks of the managed device.
[0082] As a specific implementation, the weight of the managed device may be calculated as follows:
[0083] .
[0084] is the weight, The number of remaining log blocks for the managed device. The maximum number of log blocks in all managed devices. The maximum time for log chunking. The time required to collect log blocks for managed devices.
[0085] For example, The value is the number of remaining log blocks of the managed device A. The maximum number of log blocks in all managed devices. The maximum time of log block. The time required to collect log blocks of managed device A is taken as the value. At this point, the weight of managed device A can be calculated.
[0086] After the log collection task is started, the managed device with the highest weight is selected and the log blocks of the managed device are transmitted.
[0087] If there are more than one managed device with the highest weight, the device with the fewest remaining log blocks is preferentially selected as the target device. This allows for faster log collection for the device with the fewest remaining log blocks. After completing log collection for this device, selecting a target device again reduces the number of weight calculations, saving computing resources.
[0088] In some embodiments, sending target information to the target device so that the target device transmits a log according to the target information includes:
[0089] The log block number is issued to the target device, so that the target device transmits log blocks starting from the log block corresponding to the log block number.
[0090] In this embodiment, the managed device adopts a log fragmentation strategy. Log fragmentation refers to segmenting and numbering log information. The log driver collects the logs of the device, analyzes the content of the logs, caches the logs according to the block size, and records the start time and end time of the block cached logs. The log driver collects log information and calculates the log size. The log driver divides the log information into blocks according to the block size and calculates the start time and end time of each block of logs. The managed device reports the log fragmentation status in [log size, number of blocks]. The management device can cache the information of the specified log block based on [device name, block size, block number, collection time].
[0091] Log segmentation enables fine-grained management of log information, making it easier to collect log information when idle resources of management equipment are available.
[0092] In some embodiments, sending the log block number to the target device includes:
[0093] Determine whether there is a log collection information context of the target device; the log collection information context includes a log block number;
[0094] If the log collection information context of the target device exists, sending the log block number to the target device according to the log collection information context;
[0095] If the log collection information context of the log device does not exist, the first log block number is sent to the target device.
[0096] If the management device is in a steady state, the log collection task is started to collect device block information. The device block information includes the log size and the number of blocks. Determine whether there is a log collection information context. If so, the log block number is issued according to the log collection information context. The log block number in the log collection information context can be the number of the collected log block. For example, for the managed device A, the number of the currently collected log block of the managed device A is 3, then the corresponding log block number in the log collection information context is 3, indicating that the log block numbered 3 has been collected. The issued log block number is the number of the log block to be transmitted next. The target device receives the log block number and transmits the corresponding log block. If it does not exist, the log block number is issued from the beginning so that the target device starts uploading from the first log block.
[0097] By issuing log block numbers according to the log collection context, the managed device can start transmitting log blocks from the point where the untransmitted log blocks were disconnected, thus achieving breakpoint-resume transmission of log blocks.
[0098] In addition, the log collection information context may also include device name, block size, and collection time.
[0099] In some embodiments, further comprising:
[0100] When the log collection task is started and the management device is not in a steady state, the log collection information context is recorded and the log collection task is suspended.
[0101] If the log collection task has not been started, determine whether the collected value and predicted value of the preset load indicator are both less than the corresponding threshold. If the collected value and predicted value of each preset load indicator are both less than the corresponding threshold, start the log collection task. If the log collection task has been started, determine whether the collected value or predicted value of each preset load indicator is greater than the corresponding threshold. If the collected value or predicted value of each preset load indicator is greater than the corresponding threshold, record the log collection task context and suspend the log collection task.
[0102] Combine Figure 2 As shown, a specific embodiment is described below:
[0103] The user configures the policy, including the configuration time period, the CPU threshold, which is the threshold corresponding to the CPU load, and the memory threshold, which is the threshold corresponding to the memory load. The scheduled collection task collects the CPU load and the memory load to obtain the collected value of the CPU load and the collected value of the memory load. Based on the collected value of the CPU load and the collected value of the memory load, the predicted value of the CPU load and the predicted value of the memory load are predicted. A steady-state judgment is performed. If the collected value and the predicted value of the CPU load are both less than the corresponding threshold, and the collected value and the predicted value of the memory load are both less than the corresponding threshold, then the steady state is entered. If the collected value or the predicted value of the CPU load is greater than the corresponding threshold, and the collected value or the predicted value of the memory load is greater than the corresponding threshold, then the steady state is exited. When entering the steady state, the weight of each managed device is calculated, the managed device with the largest weight is selected, and the log block number is sent to the selected managed device so that the managed device transmits the log block corresponding to the log block number.
[0104] To sum up, this application determines whether the management device is in a steady state based on the load situation of the management device itself. When the management device is in a steady state, the logs of the managed devices are collected. This can achieve a balance between log collection and system services, avoid network congestion, high load and other scenarios, and solve the problem of being unable to coordinate log collection and system services, affecting the execution efficiency of system services.
[0105] Through the description of the above implementation methods, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus the necessary general hardware platform, and of course it can also be implemented by hardware, but in many cases the former is a better implementation method.
[0106] The embodiment of the present application also provides a log collection device, referring to Figure 3 As shown, the device includes:
[0107] The collection module 10 is used to collect a preset load indicator and obtain a collection value of the preset load indicator;
[0108] A prediction module 20, configured to predict a predicted value of the preset load indicator based on the collected value of the preset load indicator;
[0109] A judgment module 30 is used to judge whether the management device is in a steady state based on the collected value and the predicted value of the preset load indicator;
[0110] The sending module 40 is configured to select a target device from the managed devices if the management device is in a steady state, and send target information to the target device, so that the target device transmits logs according to the target information.
[0111] Based on the above embodiment, as a specific implementation method, the judgment module 30 is used to:
[0112] Determining whether the collected value and the predicted value of each of the preset load indicators are both less than the corresponding threshold value;
[0113] If the collected value and the predicted value of each of the preset load indicators are both less than the corresponding threshold value, the management device is in a steady state;
[0114] If the collected value or predicted value of each of the preset load indicators is greater than the corresponding threshold value, the management device is not in a steady state.
[0115] Based on the above embodiment, as a specific implementation method, the sending module 40 is used to:
[0116] The log block number is issued to the target device, so that the target device transmits log blocks starting from the log block corresponding to the log block number.
[0117] Based on the above embodiment, as a specific implementation method, the sending module 40 includes:
[0118] A judging unit, configured to judge whether a log collection information context of the target device exists; the log collection information context includes a log block number;
[0119] a first sending unit, configured to send a log block number to the target device according to the log collection information context if the log collection information context of the target device exists;
[0120] The second sending unit is configured to send the first log block number to the target device if the log collection information context of the log device does not exist.
[0121] Based on the above embodiment, as a specific implementation method, the sending module 40 includes:
[0122] a determining unit, configured to determine a weight of the managed device;
[0123] A selection unit is configured to select a managed device with the largest weight as the target device.
[0124] Based on the above embodiment, as a specific implementation manner, the determining unit is configured to:
[0125] The weight of the managed device is calculated based on the number of remaining log blocks of the managed device, the maximum number of log blocks of each managed device, the maximum log block time of each managed device, and the time required for log block collection of the managed device.
[0126] Based on the above embodiment, as a specific implementation, the prediction module 20 is used to:
[0127] A predicted value of the preset load indicator is predicted based on a preset number of collected values of the preset load indicator, a linear regression coefficient corresponding to the collected values, a preset constant, and a preset error amount.
[0128] Based on the above embodiment, as a specific implementation method, the following is also included:
[0129] A quantity determination module is used to determine whether the number of collected values of the preset load indicator reaches a preset number;
[0130] If the number of the collected values of the preset load indicator reaches the preset number, the prediction module 20 predicts and obtains a predicted value of the preset load indicator based on the collected values of the preset load indicator.
[0131] Based on the above embodiment, as a specific implementation method, the acquisition module 10 is used to:
[0132] Collecting processor load and memory load to obtain collected values of the processor load and the memory load;
[0133] Accordingly, the prediction module 20 is used to:
[0134] Obtaining a predicted value of the processor load according to the collected value of the processor load;
[0135] A predicted value of the memory load is obtained based on the collected value of the memory load.
[0136] Based on the above embodiment, as a specific implementation method, the judgment module 30 includes:
[0137] a first judgment unit, configured to, when the log collection task is not started, judge whether a current collected value of a processor load is less than a corresponding threshold, and a predicted value of the processor load is less than the corresponding threshold, and a current collected value of a memory load is less than a corresponding threshold, and a predicted value of the memory load is less than the corresponding threshold;
[0138] a first determining unit, configured to determine that the management device is in a steady state if the currently collected value of the processor load is less than a corresponding threshold value, the predicted value of the processor load is less than a corresponding threshold value, the currently collected value of the memory load is less than a corresponding threshold value, and the predicted value of the memory load is less than the corresponding threshold value;
[0139] a second judgment unit, configured to, when the log collection task has been started, judge whether the current collected value of the processor load is greater than the corresponding threshold or the predicted value of the processor load is greater than the corresponding threshold, and whether the current collected value of the memory load is greater than the corresponding threshold or the predicted value of the memory load is greater than the corresponding threshold;
[0140] a second determining unit, configured to determine that the management device is not in a steady state if the currently collected value of the processor load is greater than the corresponding threshold or the predicted value of the processor load is greater than the corresponding threshold, and the currently collected value of the memory load is greater than the corresponding threshold or the predicted value of the memory load is greater than the corresponding threshold;
[0141] Among them, the predicted value of the processor load is predicted based on a preset number of collected values of the processor load, the linear regression coefficient corresponding to the collected values of the processor load, a preset constant and a preset error amount; the predicted value of the memory load is predicted based on a preset number of collected values of the memory load, the linear regression coefficient corresponding to the collected values of the memory load, a preset constant and a preset error amount.
[0142] Based on the above embodiment, as a specific implementation method, the following is also included:
[0143] The recording module is used to record the log collection information context and suspend the log collection task when the log collection task is started and the management device is not in a steady state.
[0144] For descriptions of features in the embodiments corresponding to the log collection device, please refer to the relevant descriptions of the embodiments corresponding to the log collection method, and will not be repeated here.
[0145] An embodiment of the present application further provides an electronic device, including a memory 1 and a processor 2, wherein the memory 1 stores a computer program, and the processor 2 is configured to run the computer program to execute the steps in any of the above-mentioned log collection method embodiments.
[0146] An embodiment of the present application further provides a computer-readable storage medium, in which a computer program is stored. The computer program is configured to execute the steps of any of the above-mentioned log collection method embodiments when running.
[0147] In an exemplary embodiment, the computer-readable storage medium may include, but is not limited to, various media that can store computer programs, such as a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk, or an optical disk.
[0148] An embodiment of the present application further provides a computer program product, which includes a computer program. When the computer program is executed by a processor, the steps of any of the above-mentioned log collection method embodiments are implemented.
[0149] An embodiment of the present application further provides another computer program product, including a non-volatile computer-readable storage medium, wherein the non-volatile computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of any of the above-mentioned log collection method embodiments are implemented.
[0150] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the above description has generally described the components and steps of each example according to their functions. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0151] The above is a detailed introduction to the log collection method, device, equipment, computer-readable storage medium and product provided by this application. Specific examples are used herein to illustrate the principles and implementation methods of this application. The description of the above embodiments is only used to help understand the method and core ideas of this application. It should be pointed out that for ordinary technicians in this technical field, without departing from the principles of this application, several improvements and modifications can be made to this application, and these improvements and modifications also fall within the scope of protection of the claims of this application.
Claims
1. A log collection method, characterized in that: include: Collecting a preset load indicator and obtaining a collection value of the preset load indicator; Obtaining a predicted value of the preset load indicator according to the collected value of the preset load indicator; Determining whether the management device is in a steady state based on the collected value and the predicted value of the preset load indicator; If the management device is in a steady state, a target device is selected from each managed device, and target information is sent to the target device, so that the target device transmits a log according to the target information.
2. The log collection method according to claim 1, characterized in that: Determining whether the management device is in a steady state according to the collected value and the predicted value of the preset load indicator includes: Determining whether the collected value and the predicted value of each of the preset load indicators are both less than the corresponding threshold value; If the collected value and the predicted value of each of the preset load indicators are both less than the corresponding threshold value, the management device is in a steady state; If the collected value or predicted value of each of the preset load indicators is greater than the corresponding threshold value, the management device is not in a steady state.
3. The log collection method according to claim 1, wherein: Sending target information to the target device so that the target device transmits a log according to the target information includes: The log block number is issued to the target device, so that the target device transmits log blocks starting from the log block corresponding to the log block number.
4. The log collection method according to claim 3, characterized in that: Sending the log block number to the target device includes: Determine whether there is a log collection information context of the target device; the log collection information context includes a log block number; If the log collection information context of the target device exists, sending the log block number to the target device according to the log collection information context; If the log collection information context of the log device does not exist, the first log block number is sent to the target device.
5. The log collection method according to claim 1, wherein: Select target devices from various managed devices including: Determining the weight of the managed device; The managed device with the largest weight is selected as the target device.
6. The log collection method according to claim 5, characterized in that: Determining the weight of the managed device includes: The weight of the managed device is calculated based on the number of remaining log blocks of the managed device, the maximum number of log blocks of each managed device, the maximum log block time of each managed device, and the time required for log block collection of the managed device.
7. The log collection method according to claim 1, wherein: Predicting the predicted value of the preset load indicator according to the collected value of the preset load indicator includes: A predicted value of the preset load indicator is predicted based on a preset number of collected values of the preset load indicator, a linear regression coefficient corresponding to the collected values, a preset constant, and a preset error amount.
8. The log collection method according to claim 1, wherein: Before obtaining the predicted value of the preset load indicator according to the collected value of the preset load indicator, the method further includes: Determining whether the number of collected values of the preset load indicator reaches a preset number; If the number of collected values of the preset load indicator reaches the preset number, a predicted value of the preset load indicator is obtained according to the collected values of the preset load indicator.
9. The log collection method according to claim 1, wherein: Collecting a preset load indicator and obtaining a collection value of the preset load indicator includes: Collecting processor load and memory load to obtain collected values of the processor load and the memory load; Correspondingly, predicting the predicted value of the preset load indicator according to the collected value of the preset load indicator includes: Obtaining a predicted value of the processor load according to the collected value of the processor load; A predicted value of the memory load is obtained based on the collected value of the memory load.
10. The log collection method according to claim 1, wherein: Determining whether the management device is in a steady state according to the collected value and the predicted value of the preset load indicator includes: When the log collection task is not started, determining whether a current collected value of the processor load is less than a corresponding threshold, and a predicted value of the processor load is less than a corresponding threshold, and a current collected value of the memory load is less than a corresponding threshold, and a predicted value of the memory load is less than a corresponding threshold; If the currently collected value of the processor load is less than the corresponding threshold value, and the predicted value of the processor load is less than the corresponding threshold value, and the currently collected value of the memory load is less than the corresponding threshold value, and the predicted value of the memory load is less than the corresponding threshold value, then the management device is in a steady state; When the log collection task is started, determining whether the current collected value of the processor load is greater than the corresponding threshold or the predicted value of the processor load is greater than the corresponding threshold, and whether the current collected value of the memory load is greater than the corresponding threshold or the predicted value of the memory load is greater than the corresponding threshold; If the currently collected value of the processor load is greater than the corresponding threshold or the predicted value of the processor load is greater than the corresponding threshold, and the currently collected value of the memory load is greater than the corresponding threshold or the predicted value of the memory load is greater than the corresponding threshold, the management device is not in a steady state; Among them, the predicted value of the processor load is predicted based on a preset number of collected values of the processor load, the linear regression coefficient corresponding to the collected values of the processor load, a preset constant and a preset error amount; the predicted value of the memory load is predicted based on a preset number of collected values of the memory load, the linear regression coefficient corresponding to the collected values of the memory load, a preset constant and a preset error amount.
11. The log collection method according to claim 10, characterized in that: Also includes: When the log collection task is started and the management device is not in a steady state, the log collection information context is recorded and the log collection task is suspended.
12. A log collection device, characterized in that: include: A collection module, used to collect a preset load indicator and obtain a collection value of the preset load indicator; A prediction module, configured to predict a predicted value of the preset load indicator based on the collected value of the preset load indicator; A judgment module, configured to judge whether the management device is in a steady state based on the collected value and the predicted value of the preset load indicator; The sending module is used to select a target device from each managed device if the management device is in a steady state, and send target information to the target device, so that the target device transmits a log according to the target information.
13. An electronic device, characterized in that: include: memory for storing computer programs; A processor, configured to implement the steps of the log collection method according to any one of claims 1 to 11 when executing the computer program.
14. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, wherein when the computer program is executed by a processor, the steps of the log collection method according to any one of claims 1 to 11 are implemented.
15. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the log collection method according to any one of claims 1 to 11 are implemented.
Citation Information
Patent Citations
IT automatic operation and maintenance system and method
CN110278102A
Dynamic log collection method and device, computer equipment and storage medium
CN114238056A
Log-based operation and maintenance monitoring method
CN116069595A
Multi-server log collection method, device and system
CN119603133A
Log information collection system, monitor device log information collection method
JP2023141448A