Method and device for calculating log retention time

By calculating the log growth rate reference value and the alarm ratio, the log retention period is determined, which solves the storage resource waste and disk alarm problems caused by improper log retention period settings, and achieves rational utilization of resources and improvement of user experience.

CN112035066BActive Publication Date: 2024-10-11BANK OF CHINA
View PDF 7 Cites 0 Cited by

Patent Information

Application Number
CN202010909833.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-09-02
Publication Date
2024-10-11
Estimated Expiration
2040-09-02

AI Technical Summary

Technical Problem

In the existing technology, if the log retention time is set too short, storage resources will be wasted. If the log retention time is set too long and the amount of log records increases suddenly, it will easily cause disk alarms and fail to effectively utilize storage resources.

Method used

By obtaining the storage space data of the storage disk, the log recording period and the log incremental data, calculate the log growth reference value, determine the reference retention time based on the storage space and alarm ratio, and take the shorter of the preset minimum retention time and the reference retention time. The larger value is used as the log retention period, and the log saving and cleaning strategy can be adjusted.

Benefits of technology

It effectively avoids disk alarms caused by excessive log growth, while rationally utilizing storage resources to provide a better user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112035066B_ABST
    Figure CN112035066B_ABST
Patent Text Reader

Abstract

The present invention provides a method and device for calculating the log retention time, the method comprising: obtaining storage space data of a storage disk, a log recording period, a log alarm ratio, and log increment data corresponding to each of s recording periods; calculating a log growth rate reference value according to the log recording period and the log increment data corresponding to each of s recording periods; determining a reference retention time of the log based on the storage space data of the storage disk, the log alarm ratio, and the log growth rate reference value; determining the larger value of a preset minimum retention time and a reference retention time as the log retention time. The present invention can save or clean up logs according to the log retention time, and then can adjust the strategy for storing or cleaning logs, ensuring that when the log grows too fast, no disk alarm will be caused, and when the log grows too slowly, the storage resources of the disk can be reasonably utilized, providing a better user experience.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a method and device for calculating log retention time. Background Art

[0002] A log is an event record named log generated by a log source (such as network equipment, system, and service program) during operation. It is a collection of data generated by the log source during operation. Each line of the log records the date, time, user, action, and other descriptive information of related operations. The log records the life cycle of the log source. By consulting and analyzing the log, you can know the state of the log source at a certain moment. Users can use the log to check the cause of an error or find traces left by the attacker when attacked.

[0003] Log storage is to temporarily allocate corresponding disk storage space according to the logs sent by the log source, so as to achieve the purpose of storing logs on disk. At present, the log retention period is a work based on experience. The log retention period is set according to the size of the disk space or according to business requirements. If the log retention period is set too short, storage resources will be wasted. If the log retention period is set too long and the log record volume increases suddenly, it is easy to generate disk alarms. Summary of the invention

[0004] In view of the problems in the prior art, the present invention provides a method and device for calculating the log retention time, which can ensure that a sudden increase in the number of log records will not cause a disk alarm and can reasonably utilize storage resources.

[0005] In order to solve the above technical problems, the present invention provides the following technical solutions:

[0006] In a first aspect, the present invention provides a method for calculating a log retention period, comprising:

[0007] Obtain storage space data of the storage disk, log recording period, log alarm ratio, and log increment data corresponding to each of the s recording periods;

[0008] Calculate the log growth rate reference value according to the log recording period and the log increment data corresponding to each of the s recording periods;

[0009] Determine the reference retention time of logs based on the storage space data of the storage disk, the alarm ratio of logs, and the reference value of log growth rate;

[0010] The larger value between the preset minimum retention period and the reference retention period is determined as the log retention period.

[0011] Further, after determining the larger value of the preset minimum retention time and the reference retention time as the log retention time, the method further includes:

[0012] The logs are stored on the storage disk according to the log retention period.

[0013] Further, after determining the larger value of the preset minimum retention time and the reference retention time as the log retention time, the method further includes:

[0014] Determine a log cleanup cycle based on the log retention period;

[0015] The logs stored on the storage disk are cleaned up according to the log cleanup cycle.

[0016] The step of calculating the log growth rate reference value according to the log recording period and the log increment data corresponding to each of the s recording periods includes:

[0017] At least one of the average speed method, the closest speed method, the farthest speed method, the closest acceleration method and the average acceleration method is adopted, and at least one log growth rate reference value is calculated according to the recording period and the s log increment data.

[0018] The step of determining the larger value of the preset minimum retention time and the reference retention time as the log retention time includes:

[0019] Determine the maximum value of the shortest retention time and the reference retention time of at least one log as the log retention time.

[0020] The alarm ratio of the log is 5% or 10%.

[0021] In a second aspect, the present invention provides a device for calculating a log retention period, comprising:

[0022] An acquisition unit, used to acquire storage space data of the storage disk, a log recording period, a log alarm ratio, and log increment data corresponding to each of the s recording periods;

[0023] A speed increasing unit, used to calculate a log speed increasing reference value according to the log recording period and the log increment data corresponding to each of the s recording periods;

[0024] A calculation unit, used to determine a reference retention time of the log based on storage space data of the storage disk, an alarm ratio of the log, and a reference value of a log growth rate;

[0025] The comparison unit is used to determine the larger value between a preset minimum retention time and a reference retention time as the log retention time.

[0026] Furthermore, it also includes:

[0027] The storage unit is used to store the logs on the storage disk according to the log retention period.

[0028] Furthermore, it also includes:

[0029] A processing unit, configured to determine a log cleaning cycle according to the log retention period;

[0030] The cleaning unit is used to clean up the logs stored on the storage disk according to the log cleaning cycle.

[0031] Wherein, the speed increasing unit comprises:

[0032] The speed increasing subunit is used to adopt at least one of the average speed method, the nearest speed method, the farthest speed method, the nearest acceleration method and the average acceleration method, and calculate at least one log speed increasing reference value according to the recording period and s log increment data.

[0033] Wherein, the comparison unit comprises:

[0034] The comparison subunit is used to determine the maximum value of the shortest retention time and the reference retention time of at least one log as the log retention time.

[0035] In a third aspect, the present invention provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the method for calculating the log retention time when executing the program.

[0036] In a fourth aspect, the present invention provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the method for calculating the log retention period.

[0037] It can be seen from the above technical scheme that the present invention provides a method and device for calculating the log retention period, by obtaining the storage space data of the storage disk, the recording period of the log, the alarm ratio of the log and the log incremental data corresponding to each of the s recording periods; calculating the log growth rate reference value according to the log recording period and the log incremental data corresponding to each of the s recording periods; determining the reference retention period of the log based on the storage space data of the storage disk, the alarm ratio of the log and the log growth rate reference value; determining the larger value of the preset minimum retention period and the reference retention period as the log retention period, and being able to save or clean up the log according to the log retention period, and then being able to adjust the strategy for storing or cleaning the log, to ensure that when the log grows too fast, no disk alarm will be caused, and when the log grows too slowly, the storage resources of the disk can be reasonably utilized, thereby providing a better user experience. BRIEF DESCRIPTION OF THE DRAWINGS

[0038] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. 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 creative work.

[0039] Figure 1 This is a first flow chart of a method for calculating log retention time in an embodiment of the present invention.

[0040] Figure 2 This is a second flow chart of the method for calculating the log retention time in an embodiment of the present invention.

[0041] Figure 3 This is a third flow chart of the method for calculating the log retention time in an embodiment of the present invention.

[0042] Figure 4 Schematic diagram of the structure of a device for calculating log retention time in an embodiment of the present invention.

[0043] Figure 5 Schematic diagram of the structure of an electronic device in an embodiment of the present invention. DETAILED DESCRIPTION

[0044] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the 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 ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0045] The present invention provides an embodiment of a method for calculating the log retention time. Figure 1 The calculation method of the log retention period specifically includes the following contents:

[0046] S101: Obtain storage space data of a storage disk, a log recording period, a log alarm ratio, and log increment data corresponding to each of s recording periods;

[0047] S102: Calculating a log growth rate reference value according to the log recording period and the log increment data corresponding to each of the s recording periods;

[0048] It is understandable that the log recording period is the time span unit for counting the incremental size of the logs, and usually one statistical period is one day.

[0049] In the specific implementation, at least one method selected from the average speed method, the nearest speed method, the farthest speed method, the nearest acceleration method and the average acceleration method is adopted, and at least one log growth rate reference value is calculated according to the recording period and the s log increment data, as follows:

[0050] Average speed method:

[0051]

[0052] Among them, S is the log recording period, s is the number of recording periods, l1 is the log increment data corresponding to the first recording period in s recording periods, l s is the log increment data corresponding to the sth recording period in s recording periods, and v is the log growth rate reference value.

[0053] Nearest speed method:

[0054]

[0055] Among them, v is the reference value of log growth rate, l s is the log incremental data corresponding to the s-th recording period in s recording periods, and S is the log recording period.

[0056] Maximum speed method:

[0057]

[0058] Wherein, v is the reference value of log growth rate, l1 is the log increment data corresponding to the first recording period in s recording periods, and S is the log recording period.

[0059] Recent acceleration method:

[0060] v=v s +v s -v s-1 ;

[0061] Among them, v is the reference value of log growth rate, v s is the growth rate of the sth recording cycle in s recording cycles, is the ratio of the log increment data of the sth recording cycle to the sth recording cycle, v s-1 is the growth rate of the s-1th recording period in s recording periods, and is the ratio of the log increment data of the s-1th recording period to the s-1th recording period.

[0062] Average acceleration method:

[0063]

[0064] Among them, v is the reference value of log growth rate, v sis the growth rate of the sth recording cycle in s recording cycles, is the ratio of the log increment data of the sth recording cycle to the sth recording cycle, v s-1 is the growth rate of the s-1th recording period in s recording periods, and is the ratio of the log increment data of the s-1th recording period to the s-1th recording period.

[0065] S103: Determine a reference retention time of the log based on the storage space data of the storage disk, the alarm ratio of the log, and the log growth rate reference value;

[0066] In this step, the reference retention time is calculated according to the log speed increase reference value in step S102, specifically including:

[0067]

[0068] Wherein, W is the storage space data of the storage disk, and w is the alarm ratio of the log, which is adaptively set according to user needs. In this embodiment, the alarm ratio of the log is 5% or 10%.

[0069] S104: Determine the larger value between the preset minimum retention time and the reference retention time as the log retention time.

[0070] It should be noted that if there are multiple ways to calculate the reference retention time of the log in step S103, the maximum value of the shortest retention time and the reference retention time of at least one log in this step is the log retention time, as follows:

[0071] In step S102, a method is used to calculate the log growth rate reference value, according to the formula A reference retention period can be obtained, and the larger value between the preset minimum retention period and the reference retention period is determined as the log retention period.

[0072] Step S102 uses k methods to calculate the log growth rate reference value, then according to the formula K reference retention time lengths (t1 to tk) can be obtained, the minimum value among the k reference retention time lengths is compared with the preset shortest retention time length T, and the larger value of the two is taken as the retention time length.

[0073] From the above description, it can be seen that the method for calculating the log retention time provided in this embodiment obtains the storage space data of the storage disk, the recording period of the log, the alarm ratio of the log, and the log incremental data corresponding to each of the s recording periods; calculates the log growth rate reference value based on the log recording period and the log incremental data corresponding to each of the s recording periods; determines the reference retention time of the log based on the storage space data of the storage disk, the alarm ratio of the log, and the log growth rate reference value; determines the larger value of the preset minimum retention time and the reference retention time as the log retention time, and can save or clean up the log according to the log retention time, and then can adjust the strategy for storing or cleaning the log to ensure that when the log grows too fast, it will not cause a disk alarm, and when the log grows too slowly, it can reasonably utilize the storage resources of the disk to provide a better user experience.

[0074] In one embodiment of the present invention, see Figure 2 After step S104, the method for calculating the log retention time specifically includes the following contents:

[0075] S105: Storing logs on a storage disk according to the log retention period.

[0076] In this embodiment, during the log recording process, the log retention time records the incremental log size. When the log grows too fast, the retention time is shortened; when the log grows too slowly, the retention time is lengthened.

[0077] In one embodiment of the present invention, see Figure 3 After step S105, the method for calculating the log retention time specifically includes the following contents:

[0078] S106: Determine a log cleaning cycle according to the log retention period;

[0079] It should be noted that the log cleaning cycle is the time span unit for cleaning the logs. In this embodiment, the log retention time is the same as the log cleaning cycle.

[0080] S107: Clean up the logs stored on the storage disk according to the log cleaning cycle.

[0081] In this embodiment, the transaction system records the incremental log size according to the statistical period during the log recording process. When cleaning the log, the log growth rate is calculated, and the log retention time is calculated based on the growth rate. If the log grows too fast, the retention time will be shortened; if the log grows too slowly, the retention time will be lengthened.

[0082] From the above description, it can be seen that the embodiment of the present invention can save or clean up logs according to the log retention period, and then adjust the strategy for storing or cleaning logs to ensure that disk alarms will not be caused when the log grows too fast, and that the disk storage resources can be reasonably utilized when the log grows too slowly, thereby providing a better user experience.

[0083] The embodiment of the present invention provides a specific implementation of a log retention time calculation device that can implement all the contents of the log retention time calculation method, see Figure 4 The calculation device for the log retention time specifically includes the following contents:

[0084] The acquisition unit 10 is used to acquire storage space data of the storage disk, the log recording period, the log alarm ratio and the log increment data corresponding to each of the s recording periods;

[0085] The speed increasing unit 20 is used to calculate a log speed increasing reference value according to the log recording period and the log increment data corresponding to each of the s recording periods;

[0086] The calculation unit 30 is used to determine the reference retention time of the log based on the storage space data of the storage disk, the alarm ratio of the log and the reference value of the log growth rate;

[0087] The comparison unit 40 is used to determine a larger value between a preset minimum retention time and a reference retention time as the log retention time.

[0088] Furthermore, it also includes:

[0089] The storage unit is used to store the logs on the storage disk according to the log retention period.

[0090] Furthermore, it also includes:

[0091] A processing unit, configured to determine a log cleaning cycle according to the log retention period;

[0092] The cleaning unit is used to clean up the logs stored on the storage disk according to the log cleaning cycle.

[0093] Wherein, the speed increasing unit 20 comprises:

[0094] The speed increasing subunit is used to adopt at least one of the average speed method, the nearest speed method, the farthest speed method, the nearest acceleration method and the average acceleration method, and calculate at least one log speed increasing reference value according to the recording period and s log increment data.

[0095] Wherein, the comparison unit 40 comprises:

[0096] The comparison subunit is used to determine the maximum value of the shortest retention time and the reference retention time of at least one log as the log retention time.

[0097] The embodiment of the log retention time calculation device provided by the present invention can be specifically used to execute the processing flow of the embodiment of the log retention time calculation method in the above embodiment. Its functions are not repeated here, and reference can be made to the detailed description of the above method embodiment.

[0098] From the above description, it can be seen that the log retention time calculation device provided by the embodiment of the present invention obtains the storage space data of the storage disk, the recording period of the log, the alarm ratio of the log and the log incremental data corresponding to each of the s recording periods; calculates the log growth rate reference value according to the log recording period and the log incremental data corresponding to each of the s recording periods; determines the reference retention time of the log based on the storage space data of the storage disk, the alarm ratio of the log and the log growth rate reference value; determines the larger value of the preset minimum retention time and the reference retention time as the log retention time, and can save or clean up the log according to the log retention time, and then can adjust the strategy for storing or cleaning the log to ensure that when the log grows too fast, it will not cause a disk alarm, and when the log grows too slowly, it can reasonably utilize the storage resources of the disk to provide a better user experience.

[0099] The present application provides an embodiment of an electronic device for implementing all or part of the contents of the log retention time method. The electronic device specifically includes the following contents:

[0100] Processor, memory, communication interface and bus; wherein the processor, memory and communication interface communicate with each other through the bus; the communication interface is used to realize information transmission between related devices; the electronic device can be a desktop computer, a tablet computer and a mobile terminal, etc., but the present embodiment is not limited thereto. In the present embodiment, the electronic device can be implemented with reference to the embodiment for realizing the method for log retention duration and the embodiment for realizing the device for log retention duration, and the contents thereof are incorporated herein and the repeated parts are not repeated.

[0101] Figure 5 FIG. 9 is a schematic block diagram of the system structure of the electronic device 9600 according to an embodiment of the present application. Figure 5 As shown, the electronic device 9600 may include a central processor 9100 and a memory 9140; the memory 9140 is coupled to the central processor 9100. It is worth noting that Figure 5 is exemplary; other types of structures may also be used to supplement or replace this structure to implement telecommunication functions or other functions.

[0102] In one embodiment, the log retention time function may be integrated into the central processing unit 9100. The central processing unit 9100 may be configured to perform the following control:

[0103] Obtain storage space data of the storage disk, log recording period, log alarm ratio, and log increment data corresponding to each of the s recording periods;

[0104] Calculate the log growth rate reference value according to the log recording period and the log increment data corresponding to each of the s recording periods;

[0105] Determine the reference retention time of logs based on the storage space data of the storage disk, the alarm ratio of logs, and the reference value of log growth rate;

[0106] The larger value between the preset minimum retention period and the reference retention period is determined as the log retention period.

[0107] From the above description, it can be seen that the electronic device provided by the embodiment of the present application obtains the storage space data of the storage disk, the recording period of the log, the alarm ratio of the log and the log incremental data corresponding to each of the s recording periods; calculates the log growth rate reference value according to the log recording period and the log incremental data corresponding to each of the s recording periods; determines the reference retention time of the log based on the storage space data of the storage disk, the alarm ratio of the log and the log growth rate reference value; determines the larger value of the preset minimum retention time and the reference retention time as the log retention time, and can save or clean up the log according to the log retention time, and then can adjust the strategy for storing or cleaning the log to ensure that when the log grows too fast, it will not cause a disk alarm, and when the log grows too slowly, it can reasonably utilize the storage resources of the disk to provide a better user experience.

[0108] In another embodiment, the log retention time device may be configured separately from the central processor 9100. For example, the log retention time may be configured as a chip connected to the central processor 9100, and the log retention time function may be implemented through the control of the central processor.

[0109] like Figure 5 As shown, the electronic device 9600 may also include: a communication module 9110, an input unit 9120, an audio processor 9130, a display 9160, and a power supply 9170. It is worth noting that the electronic device 9600 does not necessarily have to include Figure 5 In addition, the electronic device 9600 may also include Figure 5 For components not shown, reference may be made to the prior art.

[0110] like Figure 5As shown, the central processing unit 9100 is sometimes also referred to as a controller or an operation control, and may include a microprocessor or other processor device and / or logic device. The central processing unit 9100 receives input and controls the operation of various components of the electronic device 9600.

[0111] The memory 9140 may be, for example, one or more of a cache, a flash memory, a hard drive, a removable medium, a volatile memory, a non-volatile memory or other suitable devices. The above-mentioned information related to the failure may be stored, and a program for executing the relevant information may also be stored. The CPU 9100 may execute the program stored in the memory 9140 to implement information storage or processing, etc.

[0112] The input unit 9120 provides input to the central processing unit 9100. The input unit 9120 is, for example, a key or a touch input device. The power supply 9170 is used to provide power to the electronic device 9600. The display 9160 is used to display display objects such as images and texts. The display may be, for example, an LCD display, but is not limited thereto.

[0113] The memory 9140 may be a solid-state memory, such as a read-only memory (ROM), a random access memory (RAM), a SIM card, etc. It may also be a memory that saves information even when the power is off, can be selectively erased, and is provided with more data, examples of which are sometimes referred to as EPROMs, etc. The memory 9140 may also be some other type of device. The memory 9140 includes a buffer memory 9141 (sometimes referred to as a buffer). The memory 9140 may include an application / function storage unit 9142, which is used to store application programs and function programs or processes for executing the operation of the electronic device 9600 through the central processor 9100.

[0114] The memory 9140 may also include a data storage unit 9143 for storing data, such as contacts, digital data, pictures, sounds, and / or any other data used by the electronic device. The driver storage unit 9144 of the memory 9140 may include various drivers for communication functions of the electronic device and / or for executing other functions of the electronic device (such as messaging applications, address book applications, etc.).

[0115] The communication module 9110 is a transmitter / receiver 9110 that sends and receives signals via an antenna 9111. The communication module (transmitter / receiver) 9110 is coupled to the central processor 9100 to provide input signals and receive output signals, which may be the same as the case of a conventional mobile communication terminal.

[0116] Based on different communication technologies, multiple communication modules 9110 may be provided in the same electronic device, such as a cellular network module, a Bluetooth module and / or a wireless LAN module, etc. The communication module (transmitter / receiver) 9110 is also coupled to a speaker 9131 and a microphone 9132 via an audio processor 9130 to provide an audio output via the speaker 9131 and receive an audio input from the microphone 9132, thereby realizing a common telecommunication function. The audio processor 9130 may include any suitable buffer, decoder, amplifier, etc. In addition, the audio processor 9130 is also coupled to the central processor 9100, so that recording can be performed on the local machine through the microphone 9132, and the sound stored on the local machine can be played through the speaker 9131.

[0117] An embodiment of the present invention also provides a computer-readable storage medium capable of implementing all steps in the method for calculating the log retention period in the above embodiment. The computer-readable storage medium stores a computer program. When the computer program is executed by a processor, all steps of the method for calculating the log retention period in the above embodiment are implemented. For example, when the processor executes the computer program, the following steps are implemented:

[0118] Obtain storage space data of the storage disk, log recording period, log alarm ratio, and log increment data corresponding to each of the s recording periods;

[0119] Calculate the log growth rate reference value according to the log recording period and the log increment data corresponding to each of the s recording periods;

[0120] Determine the reference retention time of logs based on the storage space data of the storage disk, the alarm ratio of logs, and the reference value of log growth rate;

[0121] The larger value between the preset minimum retention period and the reference retention period is determined as the log retention period.

[0122] From the above description, it can be seen that the computer-readable storage medium provided by the embodiment of the present invention obtains the storage space data of the storage disk, the recording period of the log, the alarm ratio of the log and the log incremental data corresponding to each of the s recording periods; calculates the log growth rate reference value according to the log recording period and the log incremental data corresponding to each of the s recording periods; determines the reference retention period of the log based on the storage space data of the storage disk, the alarm ratio of the log and the log growth rate reference value; determines the larger value of the preset minimum retention period and the reference retention period as the log retention period, and can save or clean up the log according to the log retention period, and then can adjust the strategy for storing or cleaning the log to ensure that when the log grows too fast, it will not cause a disk alarm, and when the log grows too slowly, it can reasonably utilize the storage resources of the disk to provide a better user experience.

[0123] Although the present invention provides method operation steps as described in the embodiments or flowcharts, more or fewer operation steps may be included based on conventional or non-creative labor. The order of steps listed in the embodiments is only one way of executing the order of many steps and does not represent the only execution order. When the actual device or client product is executed, it can be executed in sequence or in parallel according to the method shown in the embodiments or the drawings (for example, in a parallel processor or multi-threaded processing environment).

[0124] It should be understood by those skilled in the art that the embodiments of this specification may be provided as methods, devices (systems) or computer program products. Therefore, the embodiments of this specification may take the form of complete hardware embodiments, complete software embodiments or embodiments combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.

[0125] The present invention is described with reference to flowcharts and / or block diagrams of methods, apparatus (systems) and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as a combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0126] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0127] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0128] Each embodiment in this specification is described in a progressive manner, and the same and similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment. In this article, relational terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply that there is any such actual relationship or order between these entities or operations. It should be noted that, in the absence of conflict, the embodiments of the present invention and the features in the embodiments can be combined with each other. The present invention is not limited to any single aspect, nor is it limited to any single embodiment, nor is it limited to any combination and / or permutation of these aspects and / or embodiments. Moreover, each aspect and / or embodiment of the present invention can be used alone or in combination with one or more other aspects and / or embodiments thereof.

[0129] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein by equivalents. These modifications or replacements do not make the essence of the corresponding technical solutions deviate from the scope of the technical solutions of the embodiments of the present invention, and they should all be included in the scope of the claims and specification of the present invention.

Claims

1. A method for calculating the log retention period, characterized in that: include: Obtain storage space data of the storage disk, log recording period, log alarm ratio, and log increment data corresponding to each of the s recording periods; The log recording period is the time span unit for counting log increments; the alarm ratio is adaptively set according to user needs; Calculate the log growth rate reference value according to the log recording period and the log increment data corresponding to each of the s recording periods; s should be greater than 1; Determine the reference retention time of logs based on the storage space data of the storage disk, the alarm ratio of logs, and the reference value of log growth rate; The larger value between the preset minimum retention period and the reference retention period is determined as the log retention period.

2. The method for calculating the log retention time according to claim 1, characterized in that: After determining that the larger value of the preset minimum retention time and the reference retention time is the log retention time, the method further includes: The logs are stored on the storage disk according to the log retention period.

3. The method for calculating the log retention time according to claim 1, characterized in that: After determining that the larger value of the preset minimum retention time and the reference retention time is the log retention time, the method further includes: Determine a log cleanup cycle based on the log retention period; The logs stored on the storage disk are cleaned up according to the log cleanup cycle.

4. The method for calculating the log retention time according to claim 1, characterized in that: The calculating of the log growth rate reference value according to the log recording period and the log increment data corresponding to each of the s recording periods includes: At least one of the average speed method, the closest speed method, the farthest speed method, the closest acceleration method and the average acceleration method is adopted, and at least one log growth rate reference value is calculated according to the recording period and the s log increment data.

5. The method for calculating the log retention time according to claim 4, characterized in that: The step of determining the larger value of the preset minimum retention time and the reference retention time as the log retention time includes: Determine the maximum value of the shortest retention time and the reference retention time of at least one log as the log retention time.

6. The method for calculating the log retention time according to claim 1, characterized in that: The alarm ratio of the log is 5% or 10%.

7. A device for calculating the log retention time, characterized in that: include: The acquisition unit is used to acquire the storage space data of the storage disk, the log recording period, the log alarm ratio and the log increment data corresponding to each of the s recording periods; the log recording period is the time span unit for counting the log increment size; the alarm ratio is adaptively set according to user needs; A speed increasing unit, used to calculate a log speed increasing reference value according to the log recording period and the log increment data corresponding to each of the s recording periods; s should be greater than 1; A calculation unit, used to determine a reference retention time of the log based on storage space data of the storage disk, an alarm ratio of the log, and a reference value of a log growth rate; The comparison unit is used to determine the larger value between a preset minimum retention time and a reference retention time as the log retention time.

8. The device for calculating the log retention time according to claim 7, characterized in that: Also includes: The storage unit is used to store the logs on the storage disk according to the log retention period.

9. The device for calculating the log retention time according to claim 7, characterized in that: Also includes: A processing unit, configured to determine a log cleaning cycle according to the log retention period; The cleaning unit is used to clean up the logs stored on the storage disk according to the log cleaning cycle.

10. The device for calculating log retention time according to claim 7, characterized in that: The speed increasing unit comprises: The speed increasing subunit is used to adopt at least one of the average speed method, the nearest speed method, the farthest speed method, the nearest acceleration method and the average acceleration method, and calculate at least one log speed increasing reference value according to the recording period and s log increment data.

11. The device for calculating log retention time according to claim 10, characterized in that: The comparison unit comprises: The comparison subunit is used to determine the maximum value of the shortest retention time and the reference retention time of at least one log as the log retention time.

12. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the program, the steps of the method for calculating the log retention time length described in any one of claims 1 to 6 are implemented.

13. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method for calculating the log retention time described in any one of claims 1 to 6 are implemented.

Citation Information

Patent Citations

  • File recovery method and device, server and computer readable storage medium

    CN107590283A

  • Data self-increasing method and device

    CN108153488A

  • Log file management method

    CN109885539A

  • Log cleaning method and device

    CN110188075A

  • System log management method and device, storage medium and equipment

    CN110908971A