A method, device, electronic device and medium for collecting system monitoring logs

By parsing the log file naming format and predicting the target file name, combining the directory structure to generate a download address, and directly downloading the log file, it solves the high efficiency problem caused by multiple directory levels in the existing technology, and significantly improves the collection efficiency of system monitoring logs.

CN112685270BActive Publication Date: 2024-10-01EVERSEC BEIJING TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202011547304.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-12-24
Publication Date
2024-10-01
Estimated Expiration
2040-12-24

AI Technical Summary

Technical Problem

The existing technology, when the system monitoring log has many directory levels and a large directory magnitude, leads to frequent server access and increased bandwidth usage, affecting collection efficiency.

Method used

By monitoring log download events, parsing the log file naming format to obtain the time field content, predicting the target file name, and generating a download address based on the directory structure, it avoids requesting a file directory list for each download and directly downloads the target log file.

Benefits of technology

It reduces the time-consuming and bandwidth usage of log collection operations and significantly improves log collection efficiency, especially when there are many directory levels.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112685270B_ABST
    Figure CN112685270B_ABST
Patent Text Reader

Abstract

The present invention discloses a method, device, electronic device and medium for collecting system monitoring logs. The method includes: when a log download event is detected to be triggered, parsing the log file name corresponding to the previous download task according to the naming format of the log file to obtain the time field content; predicting the target file name of the target log file corresponding to the current download task according to the time field content and the log generation time interval; generating the download address of the target log file according to the target file name and the directory structure, and downloading the target log file according to the download address, wherein the directory structure is used to represent the structural relationship of the directory under the monitored directory of the collected server, avoiding requesting the file directory list from the server each time the log download task is executed, so as to obtain the download address of each log file by parsing the file directory list, which can reduce the time consumption and bandwidth occupation of the log collection operation and improve the log collection efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present invention relate to communication technology, and in particular to a method, device, electronic device and medium for collecting system monitoring logs. Background Art

[0002] System monitoring logs are the basis for system maintenance, troubleshooting, and fault detection. The prior art generally uses a timer traversal solution to collect system monitoring logs, that is, at fixed intervals, the client obtains a list of all files in a directory from the server, and parses the file list locally to obtain each file included in the file list. Each file is downloaded from the server and backed up locally, that is, after obtaining the file list by traversing the specified directory, the files included in the file list are collected one by one.

[0003] However, when the system monitoring log has many directory levels and a large number of directories, the above method will cause a large number of server access behaviors due to the recursive operation of the hierarchical directory, and the size of the returned file list will increase with the increase of directories, resulting in a linear increase in the running time and bandwidth usage with the increase in the number of directories and files, affecting the collection efficiency of the system monitoring log. Summary of the invention

[0004] The present invention provides a method, device, electronic equipment and medium for collecting system monitoring logs, which can improve the collection efficiency of system monitoring logs.

[0005] In a first aspect, an embodiment of the present invention provides a method for collecting system monitoring logs, including:

[0006] When a log download event is detected, the log file name corresponding to the previous download task is parsed according to the naming format of the log file to obtain the time field content, wherein the naming format is used to indicate the position of the time field in the log file name;

[0007] Predicting the target file name of the target log file corresponding to the download task according to the time field content and the log generation time interval;

[0008] A download address of the target log file is generated according to the target file name and directory structure, and the target log file is downloaded according to the download address, wherein the directory structure is used to represent the structural relationship of the directories under the monitored directory of the collected server.

[0009] In a second aspect, an embodiment of the present invention further provides a system monitoring log collection device, the device comprising:

[0010] A time field determination module is used to parse the log file name corresponding to the previous download task according to the naming format of the log file to obtain the time field content when a log download event is detected to be triggered, wherein the naming format is used to indicate the position of the time field in the log file name;

[0011] A file name prediction module, used to predict the target file name of the target log file corresponding to the current download task according to the content of the time field and the log generation time interval;

[0012] The file download module is used to generate a download address of the target log file according to the target file name and directory structure, and download the target log file according to the download address, wherein the directory structure is used to represent the structural relationship of the directories under the monitored directory of the collected server.

[0013] In a third aspect, an embodiment of the present invention further provides an electronic device, the electronic device comprising:

[0014] one or more processors;

[0015] A memory for storing one or more programs;

[0016] When the one or more programs are executed by the one or more processors, the one or more processors implement the method for collecting system monitoring logs as described in any embodiment of the present invention.

[0017] In a fourth aspect, an embodiment of the present invention further provides a storage medium comprising computer executable instructions, wherein the computer executable instructions, when executed by a computer processor, are used to execute the method for collecting system monitoring logs as described in any embodiment of the present invention.

[0018] The present invention provides a method, device, electronic device and medium for collecting system monitoring logs. When a log download event is detected, the name of the log file corresponding to the previous download task is parsed according to the log file naming format to obtain the time field content, the target file name of the target file corresponding to the current download task is predicted according to the time field content and the log generation time interval, the download address of the target log file is generated according to the target file name and the directory structure, and the target log file is downloaded according to the download address. The embodiment of the present invention downloads the directory structure of the monitored directory in advance and saves it locally. When executing the log download event, the target file name of the target log file of the current download task is inferred according to the time field content in the log file name corresponding to the previous download task, and the target log file name and directory structure are assembled locally to obtain the download address of the target log file, so as to avoid requesting a file directory list from the server each time the log download task is executed, so as to obtain the download address of each log file by parsing the file directory list, thereby reducing the time consumption and bandwidth occupation of the log collection operation and improving the log collection efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] Figure 1 A flowchart of a method for collecting system monitoring logs provided by an embodiment of the present invention;

[0020] Figure 2 A schematic diagram of a directory structure of a monitored directory in a telecommunications system;

[0021] Figure 3 A flowchart of another method for collecting system monitoring logs provided by an embodiment of the present invention;

[0022] Figure 4 A structural block diagram of a system monitoring log collection device provided by an embodiment of the present invention;

[0023] Figure 5 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0024] The present invention will be further described in detail below in conjunction with the accompanying drawings and embodiments. It is to be understood that the specific embodiments described herein are only used to explain the present invention, rather than to limit the present invention. It should also be noted that, for ease of description, only parts related to the present invention, rather than all structures, are shown in the accompanying drawings.

[0025] Figure 1The flowchart of a method for collecting system monitoring logs provided by an embodiment of the present invention is applicable to scenarios where the number of directory levels of monitoring logs is large and the number of directories is large, such as the collection of system monitoring logs in telecommunications systems. The method can be executed by a system monitoring log collection device, which can be implemented by software and / or hardware and is usually integrated in a client, and the client is set in an electronic device. Figure 1 As shown, the method includes:

[0026] Step 110: When a log download event is detected, the log file name corresponding to the previous download task is parsed according to the naming format of the log file to obtain the time field content.

[0027] It should be noted that the client can maintain a long connection message channel with the server. The maintenance personnel can log in to the server through the client and use the above long connection message channel to send various instructions to the server for execution. For example, the communication connection between the client and the collected server is realized through the TCP protocol. The user name authentication operation is realized through the USER instruction in the FTP protocol. The authentication password operation is realized through the PASS instruction in the FTP protocol. Enter the passive mode through the PASV instruction in the FTP protocol. Access the monitored directory through the RMD instruction in the FTP protocol, where the log files are stored in the monitored directory.

[0028] Among them, the log download event is a trigger event for executing the log download task in the client, that is, when the client detects the log download event, the log download task is executed. It should be noted that there are many conditions for triggering the log download event, and the embodiment of the present invention does not specifically limit it. For example, when the execution interval with the previous download task is equal to the log generation time interval, the log download event is triggered. It can also be a timed triggering of the log download event, etc. Specifically, the timing starts when the client completes a log download task. Since the log generation time interval is pre-set, when the timing time is equal to the log generation time interval, the client determines that the execution interval with the previous download task is equal to the log generation time interval.

[0029] Log files are stored in the monitored directory of the server. The monitored directory can include multiple layers of directories. Figure 2 FIG. 1 is a schematic diagram of a directory structure of a monitored directory in a telecommunications system, such as Figure 2 As shown, the directory structure under the monitoring directory of the server may include:

[0030] First-level directory: regional directory, directory names are Z1, Z2, ..., Z1000;

[0031] Second level directory: base station directory, directory names 1A, 1B, ... correspond to regional directory Z1; and directory names 2A, 2B, ... correspond to regional directory Z2, etc.;

[0032] The third-level directory: log type directory, the directory names are TYPE1, TYPE2, ..., each type directory contains log files. For example, Z1_1A_TYPE1_XXXX_202011011500_XXXX.LOG corresponds to log type TYPE1. For another example, Z1_1A_TYPE2_XXXX_202011011530_XXXX.LOG corresponds to log type TYPE2, and so on.

[0033] Optionally, the directory structure and the naming format of the log files under the FTP monitoring directory of the remote server can be obtained through the LIST instruction under the FTP protocol when the set conditions are met. For example, the directory structure and the naming format of the log files under the FTP monitoring directory of the remote server can be obtained through the LIST instruction under the FTP protocol only when the client is started.

[0034] It should be noted that the hierarchical structure of the monitored directory is not limited to the structure listed in the above example. Depending on the actual application scenario, the monitored directory may include more or fewer levels, and the embodiment of the present invention does not make any specific limitation.

[0035] The name of the log file is used to uniquely identify a log file, and the name of the log file needs to comply with the naming format requirements of the log file. The naming format of the log file can exist in the form of a file name template, and the file name template can be stored locally on the server or client in the form of a configuration file. Specifically, the naming format of the log file is used to indicate the position of the time field in the log file name. The time field position in the log file name is defined and configured through the naming format of the log file, and the content corresponding to the time field, that is, the time field content, can be obtained by parsing the log file name based on the naming format. Among them, the time field content can be understood as the content at the time field position in the log file name. For example, the naming format configuration defines the meaning of different fields in different log file names by describing the character ''. For the naming rule 'Z1_1A_TYPE1_XXXX_'+'time'+'_XXXX.LOG', where XXXX represents an omitted field, the time field can be configured as the fifth field by definition, and accordingly, the time field content is the field content between the fourth '-' and the fifth '-'. Taking the log file name Z1_1A_TYPE1_XXXX_202011011500_XXXX.LOG as an example, the log file name can be parsed according to the above naming rules to extract the field content between the fourth '-' and the fifth '-', which is the time field content 202011011500. Based on the time field content 202011011500, it is determined that the monitoring log was generated at 15:00 on November 01, 2020.

[0036] Exemplarily, the log download task is executed each time a new log is generated. If the time interval between the current time and the execution time of the previous download task is equal to the log generation time interval, the log download event is triggered to execute the log download task. When the log download time is triggered, the client obtains the log file name of the log downloaded by the previous download task, and extracts the field content at the corresponding position in the log file name corresponding to the previous download task according to the position of the time field indicated by the naming format of the log file in the log file name, and obtains the time field content in the log file name.

[0037] Optionally, after executing the log file download task, the log file name corresponding to this log file download task can be parsed according to the naming format of the log file, and the time field content in the log file name can be obtained, so as to infer the log file name that needs to be downloaded when the log file download task is executed next time through the time field content, and the log file name corresponding to the next log download task can be cached locally, so as to download the corresponding log file when the next log file download task is executed.

[0038] Step 120: predict the target file name of the target log file corresponding to the current download task according to the time field content and the log generation time interval.

[0039] Among them, the log generation time interval represents the file generation time interval of the monitoring log. It should be noted that the log generation time interval is set by the user based on the actual application scenario. For example, the log generation time interval of the log file can be defined as 5 minutes. Assuming that the file name of the current log file is Z1_1A_TYPE1_XXXX_202011011500_XXXX.LOG, based on the log generation time interval, the next log file is generated at 15:05 on November 01, 2020, that is, the file name of the next log file is Z1_1A_TYPE1_XXXX_202011011505_XXXX.LOG.

[0040] Specifically, the addition result of the time field content in the name of the log file corresponding to the previous download task and the log generation time interval is calculated, and the addition result is used as the generation time of the target log file corresponding to this download task. The generation time is used to replace the time field content in the name of the log file corresponding to the previous download task, and the target file name of the target log file corresponding to this download task is obtained.

[0041] For example, if the log generation interval is 5 minutes and the log file name corresponding to the previous download task is Z1_1A_TYPE1_XXXX_202011011500_XXXX.LOG, the time field content of Z1_1A_TYPE1_XXXX_202011011500_XXXX.LOG is parsed through the naming format of the log file, which is 202011011500, representing 15:00 on November 1, 2020. Since the log generation interval is 5 minutes, 15:00 on November 1, 2020 plus 5 minutes is 15:05 on November 1, 2020, that is, 202011011505. 202011011505 is used to replace 202011011500 in the above log file name. Therefore, the target file name corresponding to this download task is Z1_1A_TYPE1_XXXX_202011011505_XXXX.LOG.

[0042] Step 130: Generate a download address for the target log file according to the target file name and directory structure, and download the target log file according to the download address.

[0043] The directory structure is used to represent the structural relationship of the directories under the monitored directory of the collected server. It should be noted that the directory structure of the monitored directory in different application scenarios or different servers may be different.

[0044] The download address is used to indicate the location information of the log file in a certain level directory under a specific monitored directory in the server. In the embodiment of the present invention, it is not necessary to request the monitored directory file list from the server each time before downloading the log file, so as to obtain the download address of each file in the monitored directory file list by local parsing. Instead, the target file name corresponding to the current download task is predicted, combined with the directory structure and the IP address of the collected server, to assemble a complete URL (uniform resource locator)

[0045] Specifically, the access address of the collected server is obtained; the domain name, access address, directory structure and target file name of the communication protocol are combined in accordance with the preset field combination order to obtain the download address of the target log file. It should be noted that the server that establishes a communication connection with the client based on the TCP protocol is called the collected server, and the IP of the collected server can be used as the access address of the collected server. The preset field combination order is determined based on the naming rules of the URL. For example, the preset field combination order can be: domain name of the communication protocol / / access address of the collected server / directory structure / target file name. The domain name, access address, directory structure and target file name of the communication protocol are sequentially spliced ​​according to the preset field combination order to obtain the download address of the target log file. For a directory structure with multiple directory levels, the directory names of each level included in the directory structure are spliced ​​in order according to the hierarchical relationship of the directory.

[0046] For example, the IP address of the remote server is 1.1.1.1, the target file name is Z1_1A_TYPE1_XXXX_202011011505_XXXX.LOG, and the directory structure is: first-level directory: area directory, directory name is Z1; second-level directory: base station directory, directory name is 1A; third-level directory: log type directory, directory name is TYPE1.

[0047] Sequentially splice the IP address, directory structure and target file name to obtain: 1.1.1.1 / Z1 / 1A / TYPE1 / Z1_1A_TYPE1_XXXX_202011011505_XXXX.LOG. The FTP domain name at the beginning of the header of the above splicing result is assembled, and the port is not filled in. The default port 21 is used, and the complete URL of a target log file that needs to be downloaded in this download task can be obtained: ftp: / / 1.1.1.1 / Z1 / 1A / TYPE1 / Z1_1A_TYPE1_XXXX_202011011505_XXXX.LOG. After the client obtains the completed URL of each target log file that needs to be downloaded in this download task, the RETR instruction in the FTP protocol is used to download each locally generated target log file from the remote server in turn. The present invention can quickly obtain the complete URL information of the log file in the monitored directory that needs to be collected without regularly traversing all folders and subdirectories of the remote server, and download the log file through this URL in conjunction with the RETR instruction. Usually we can use common tools such as CURL or WGET to download FTP URLs, or we can encapsulate and support the FTP command library within the device.

[0048] When the execution interval of the download task is equal to the log generation interval again, since the file name corresponding to the previous download task is Z1_1A_TYPE1_XXXX_202011011505_XXXX.LOG, the time field content is 202011011505 when parsing the file name through the log file naming format. Combined with the known log generation interval of 5 minutes, the time field content in the target file name of the target log file to be downloaded in this download task is 202011011510, so the target file name corresponding to this download task is Z1_1A_TYPE1_XXXX_202011011510_XXXX.LOG. The complete URL of a target log file to be downloaded in this download task is determined in a similar manner to the above example: ftp: / / 1.1.1.1 / Z1 / 1A / TYPE1 / Z1_1A_TYPE1_XXXX_202011011510_XXXX.LOG, and the target log file is downloaded in combination with the URL and the RETR instruction. Assuming that the log generation time interval is changed to 10 minutes, the time field content in the target file name of the target log file to be downloaded in the next download task is 202011011520, and so on to complete the inference of the URL of the target log file corresponding to the future download task, and perform the log download operation according to the inferred URL.

[0049] The technical solution of this embodiment is to parse the log file name corresponding to the previous download task according to the log file naming format to obtain the time field content when monitoring the triggering of the log download event, predict the target file name of the target file corresponding to this download task according to the time field content and the log generation time interval, generate the download address of the target log file according to the target file name and directory structure, and download the target log file according to the download address. The embodiment of the present invention downloads the directory structure of the monitored directory in advance and saves it locally. When executing the log download event, the target file name of the target log file of this download task is inferred according to the time field content in the log file name corresponding to the previous download task, and the target log file name and directory structure are assembled locally to obtain the download address of the target log file, so as to avoid requesting the file directory list from the server every time the log download task is executed, so as to obtain the download address of each log file by parsing the file directory list, which can reduce the time consumption and bandwidth occupation of the log collection operation and improve the log collection efficiency.

[0050] Figure 3 A flowchart of another method for collecting system monitoring logs provided by an embodiment of the present invention is shown in FIG. Figure 3 As shown, the method includes:

[0051] Step 301: The client starts and establishes a TCP connection to the collected data server.

[0052] Step 302: Implement the user name authentication operation through the USER instruction in the FTP protocol.

[0053] Step 303: Implement the authentication password operation through the PASS instruction in the FTP protocol.

[0054] Step 304: Enter the passive mode through the PASV instruction in the FTP protocol.

[0055] Step 305: Access the monitored directory through the RMD instruction in the FTP protocol.

[0056] Step 306: List the files of the monitored directory and recursively all subdirectories through the LIST instruction in the FTP protocol to obtain the directory structure of the monitored directory and the naming rules of the log files.

[0057] It should be noted that steps 301-306 may be performed only once when the client is initialized. For example, the client is initialized after startup, and during the initialization, the directory structure of the monitored directory of the collected server and the naming format of the log file are obtained.

[0058] Specifically, after the client is started, a TCP connection is established with the collected server, and then the user name authentication operation is implemented through the USER instruction in the FTP protocol; the authentication password operation is implemented through the PASS instruction in the FTP protocol; the passive mode is entered through the PASV instruction in the FTP protocol; the monitored directory is accessed through the RMD instruction in the FTP protocol; the LIST instruction in the FTP protocol is sent to the collected server to instruct the collected server to list the files in the monitored directory and recursively access all subdirectories, obtain the directory structure of the monitored directory and the naming rules of the log files, and return the directory structure of the monitored directory and the naming rules of the log files to the client. The client receives the directory structure and the naming rules of the log files sent by the collected server and caches them locally.

[0059] Optionally, during initialization, the directory structure of the monitored directory of the collected server is obtained, and a locally pre-set naming configuration file of the log file is obtained, wherein the naming configuration file is used to indicate the naming format of the log file. During initialization, the client can only obtain the directory structure of the monitored directory of the collected server, and no longer obtain the naming rules of the log file. A naming configuration file of the log file can be pre-set on the client side, and the naming configuration file defines the naming format of the log file, thereby eliminating the need to obtain the naming format of the log file from the remote server, thereby reducing bandwidth usage.

[0060] It should be noted that for telecommunications systems, there may be a situation where base stations are added. At this time, the directory structure of the monitored directory will change accordingly. In order to be able to perceive the growth or change of the directory structure in a timely manner, the single execution of the LIST instruction can be changed to a periodic execution. For example, the client sends a LIST instruction to the collected server according to a set period to instruct the collected server to list the file list of the monitored directory and recursively all subdirectories, obtain the directory structure of the monitored directory and the naming rules of the log files, and return the directory structure of the monitored directory and the naming rules of the log files to the client. In this way, the growth or change of the directory structure of the monitored directory can be perceived in a timely manner, and the monitoring download of the added directory can be realized, thereby meeting the adjustment needs of different scenarios, and at the same time will not greatly increase the consumption cost brought by the LIST.

[0061] Step 307: predict a list of log file names corresponding to the current download task according to the log file names, the naming format of the log files, and the log generation time interval.

[0062] Exemplarily, the naming format of the locally stored log files is used to describe the location of the log time-related fields in the log file name, and then the pre-specified log generation time interval is used to infer the log file name in the future. With this method, the client can calculate the log file name when the next download task is executed after the first LIST result.

[0063] Step 308: Download the log files in the log file name list corresponding to the current download task in sequence through the RETR instruction in the FTP protocol.

[0064] For example, by calculating the file name of the log file when the download task is executed, the complete FTP URL information of the log file can be assembled by combining the directory structure and server IP information. Therefore, the client can quickly obtain the complete URL information of the log file to be downloaded without having to traverse all folders and subdirectories of the remote server regularly, and download the log file through the URL information in conjunction with the RETR instruction.

[0065] Step 309: Determine the execution interval with the completion time of this download task.

[0066] Step 310 , determine whether the execution interval reaches the log generation interval, if so, execute step 307 , otherwise execute step 309 .

[0067] It should be noted that the system monitoring log collection task is executed regularly, and its execution interval is equal to the log generation time interval of the log files in the monitored directory.

[0068] The method for collecting system monitoring logs provided by the embodiment of the present invention can greatly improve the efficiency of log collection in application scenarios where there are many server directory levels, a large number of subdirectories, and a large number of files in the directory. For log files in a monitored directory in a certain telecommunications system, log collection is performed using the existing technical solution and the solution provided by the present invention, and the collection performance is compared to obtain a collection performance comparison table as shown in Table 1. As shown in Table 1, it is measured that the solution provided by the present invention improves the collection efficiency in a certain telecommunications system by more than 50 times, saving more than 50GB of traffic consumption per day.

[0069] Table 1 is a comparison table of the collection performance of log files in a monitored directory in a telecommunications system.

[0070]

[0071] In addition, as shown in Table 1, logs in the system are usually backed up and retained for a certain period of time. As the number of documents retained increases, the LIST time consumption will increase linearly with the increase in the number of directories. At the same time, the download monitoring log task itself will preempt the hardware resources CPU and disk I / O and will also have different effects on the actual time consumption of the LIST instruction. At this time, the acquisition scheme of the system monitoring log provided by the present invention can reduce the execution times of the LIST instruction, avoid the time-consuming problem caused by repeatedly executing the LIST instruction, and greatly improve the acquisition performance.

[0072] The embodiment of the present invention uses the client to obtain the directory structure of the monitored directory and the naming format of the log file after executing the LIST instruction for the first time, and then calculates the complete URL of the log file that needs to be collected in this collection task based on the log file name, naming format, directory structure and log generation time interval corresponding to the previous download task, and then directly uses the RETR instruction to download the file corresponding to the URL, thereby reducing the time and traffic consumption of periodically executing the LIST instruction and significantly improving the collection efficiency.

[0073] Figure 4 This is a structural block diagram of a system monitoring log collection device provided in an embodiment of the present invention. The device can be implemented by software and / or hardware and integrated into a client, and the client is set in an electronic device. The device improves the collection efficiency of the system monitoring log by executing the system monitoring log collection method provided in any embodiment of the present invention. Figure 4 As shown, the device comprises:

[0074] The time field determination module 410 is used to parse the log file name corresponding to the previous download task according to the naming format of the log file to obtain the time field content when the log download event is detected to be triggered, wherein the naming format is used to indicate the position of the time field in the log file name;

[0075] The file name prediction module 420 is used to predict the target file name of the target log file corresponding to the current download task according to the content of the time field and the log generation time interval;

[0076] The file download module 430 is used to generate a download address of the target log file according to the target file name and directory structure, and download the target log file according to the download address, wherein the directory structure is used to represent the structural relationship of the directories under the monitored directory of the collected server.

[0077] The embodiment of the present invention provides a collection device for system monitoring logs. When a log download event is detected, the name of the log file corresponding to the previous download task is parsed according to the log file naming format to obtain the time field content, the target file name of the target file corresponding to the current download task is predicted according to the time field content and the log generation time interval, the download address of the target log file is generated according to the target file name and the directory structure, and the target log file is downloaded according to the download address. The embodiment of the present invention downloads the directory structure of the monitored directory in advance and saves it locally. When executing the log download event, the target file name of the target log file of the current download task is inferred according to the time field content in the log file name corresponding to the previous download task, and the target log file name and directory structure are assembled locally to obtain the download address of the target log file, so as to avoid requesting the file directory list from the server each time the log download task is executed, so as to obtain the download address of each log file by parsing the file directory list, thereby reducing the time consumption and bandwidth occupation of the log collection operation and improving the log collection efficiency.

[0078] Optionally, the device further comprises:

[0079] The event triggering module is used to trigger a log downloading event when the execution interval of the previous downloading task is equal to the log generation time interval.

[0080] Optionally, the device further comprises:

[0081] The first information acquisition module is used to obtain the directory structure of the monitored directory of the collected server and the naming format of the log file during initialization.

[0082] Optionally, the device further comprises:

[0083] The second information acquisition module is used to obtain the directory structure of the monitored directory of the collected server during initialization, and obtain the locally preset naming configuration file of the log file, wherein the naming configuration file is used to indicate the naming format of the log file.

[0084] Optionally, the time field determination module 410 is specifically configured to:

[0085] According to the position of the time field indicated by the naming format of the log file in the log file name, the field content at the position in the log file name corresponding to the previous download task is extracted to obtain the time field content.

[0086] Optionally, the file name prediction module 420 is specifically used for:

[0087] Calculate the addition result of the time field content and the log generation time interval, and use the addition result as the generation time of the target log file corresponding to the current download task;

[0088] The generation time is used to replace the time field content in the log file name corresponding to the previous download task, and the target file name of the target log file corresponding to the current download task is obtained.

[0089] Optionally, the file download module 430 is specifically used for:

[0090] Get the access address of the collected server;

[0091] The domain name of the communication protocol, the access address, the directory structure and the target file name are combined in a preset field combination order to obtain a download address for the target log file.

[0092] The system monitoring log collection device provided in the embodiment of the present invention can execute the system monitoring log collection method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.

[0093] Figure 5 The structure diagram of an electronic device provided by an embodiment of the present invention is shown in FIG. The electronic device may be an intelligent terminal having an operating system and a communication module, and the client is arranged in the electronic device. Figure 5 As shown, the electronic device includes a processor 50, a memory 51, an input device 52 and an output device 53; the number of processors 50 in the electronic device can be one or more. Figure 5 A processor 50 is taken as an example; the processor 50, the memory 51, the input device 52 and the output device 53 in the electronic device can be connected by a bus or other means. Figure 5 The example of connecting through bus is taken in the following.

[0094] The memory 51, as a computer-readable storage medium, can be used to store software programs, computer executable programs and modules, such as program instructions / modules corresponding to the method for collecting system monitoring logs in the embodiment of the present invention (for example, the time field determination module 410, the file name prediction module 420 and the file download module 430). The processor 50 executes various functional applications and data processing of the electronic device by running the software programs, instructions and modules stored in the memory 51, that is, implements the above-mentioned method for collecting system monitoring logs.

[0095] The memory 51 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system and at least one application required for a function; the data storage area may store data created according to the use of the terminal, etc. In addition, the memory 51 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other non-volatile solid-state storage device. In some instances, the memory 51 may further include a memory remotely arranged relative to the processor 50, and these remote memories may be connected to the electronic device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0096] The input device 52 may be used to receive input digital or character information and generate key signal input related to user settings and function control of the electronic device. The output device 73 may include a display device such as a display screen for displaying log files.

[0097] An embodiment of the present invention further provides a storage medium including computer executable instructions, wherein the computer executable instructions are used to execute a method for collecting system monitoring logs when executed by a computer processor, the method comprising:

[0098] When a log download event is detected, the log file name corresponding to the previous download task is parsed according to the naming format of the log file to obtain the time field content, wherein the naming format is used to indicate the position of the time field in the log file name;

[0099] Predicting the target file name of the target log file corresponding to the download task according to the time field content and the log generation time interval;

[0100] A download address of the target log file is generated according to the target file name and directory structure, and the target log file is downloaded according to the download address, wherein the directory structure is used to represent the structural relationship of the directories under the monitored directory of the collected server.

[0101] Of course, the storage medium containing computer executable instructions provided by an embodiment of the present invention is not limited to the method operations described above, and can also execute related operations in the system monitoring log collection method provided by any embodiment of the present invention.

[0102] Through the above description of the implementation methods, the technicians in the relevant field can clearly understand that the present invention can be implemented by means of software and necessary general hardware, and of course it can also be implemented by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as a computer floppy disk, read-only memory (ROM), random access memory (RAM), flash memory (FLASH), hard disk or optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, server, or network device, etc.) to execute the methods described in each embodiment of the present invention.

[0103] It is worth noting that in the embodiment of the above-mentioned system monitoring log collection device, the various units and modules included are only divided according to functional logic, but are not limited to the above-mentioned division, as long as the corresponding functions can be achieved; in addition, the specific names of the functional units are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of the present invention.

[0104] Note that the above are only preferred embodiments of the present invention and the technical principles used. Those skilled in the art will understand that the present invention is not limited to the specific embodiments described herein, and that various obvious changes, readjustments and substitutions can be made by those skilled in the art without departing from the scope of protection of the present invention. Therefore, although the present invention has been described in more detail through the above embodiments, the present invention is not limited to the above embodiments, and may include more other equivalent embodiments without departing from the concept of the present invention, and the scope of the present invention is determined by the scope of the appended claims.

Claims

1. A method for collecting system monitoring logs, characterized in that: include: When a log download event is detected, the log file name corresponding to the previous download task is parsed according to the naming format of the log file to obtain the time field content, wherein the naming format is used to indicate the position of the time field in the log file name; Predicting the target file name of the target log file corresponding to the download task according to the time field content and the log generation time interval; The download address of the target log file is generated by assembling locally according to the target file name and directory structure, and the target log file is downloaded according to the download address, wherein the directory structure is used to represent the structural relationship of the directories under the monitored directory of the collected server, and the download address is used to represent the location information of the log file in a certain level directory under the monitored directory in the server; Wherein, the locally assembling and generating the download address of the target log file according to the target file name and directory structure includes: Get the access address of the collected server; The domain name of the communication protocol, the access address, the directory structure and the target file name are combined in a preset field combination order to obtain a download address of the target log file, wherein the directory structure is pre-downloaded and saved locally.

2. The method according to claim 1, characterized in that Also includes: When the execution interval of the previous download task is equal to the log generation interval, the log download event is triggered.

3. The method according to claim 1, characterized in that Also includes: During initialization, the directory structure of the monitored directory of the collected server and the naming format of the log file are obtained.

4. The method according to claim 1, characterized in that: Also includes: During initialization, the directory structure of the monitored directory of the collected server is obtained, and a locally preset naming configuration file of the log file is obtained, wherein the naming configuration file is used to indicate the naming format of the log file.

5. The method according to claim 1, characterized in that The process of parsing the log file name corresponding to the previous download task according to the naming format of the log file to obtain the time field content includes: According to the position of the time field indicated by the naming format of the log file in the log file name, the field content at the position in the log file name corresponding to the previous download task is extracted to obtain the time field content.

6. The method according to claim 1, characterized in that The predicting the target file name of the target log file corresponding to the current download task according to the time field content and the log generation time interval includes: Calculate the addition result of the time field content and the log generation time interval, and use the addition result as the generation time of the target log file corresponding to the current download task; The generation time is used to replace the time field content in the log file name corresponding to the previous download task, and the target file name of the target log file corresponding to the current download task is obtained.

7. A system monitoring log collection device, characterized in that: include: A time field determination module is used to parse the log file name corresponding to the previous download task according to the naming format of the log file to obtain the time field content when a log download event is detected to be triggered, wherein the naming format is used to indicate the position of the time field in the log file name; A file name prediction module, used to predict the target file name of the target log file corresponding to the current download task according to the content of the time field and the log generation time interval; A file download module, used to assemble and generate a download address of the target log file locally according to the target file name and directory structure, and download the target log file according to the download address, wherein the directory structure is used to represent the structural relationship of the directories under the monitored directory of the collected server, and the download address is used to represent the location information of the log file in a certain level directory under the monitored directory in the server; Wherein, the file download module is configured to: Get the access address of the collected server; The domain name of the communication protocol, the access address, the directory structure and the target file name are combined in a preset field combination order to obtain a download address of the target log file, wherein the directory structure is pre-downloaded and saved locally.

8. An electronic device, characterized in that: The electronic device comprises: one or more processors; A memory for storing one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement the method for collecting system monitoring logs as described in any one of claims 1-6.

9. A storage medium containing computer executable instructions, characterized in that: The computer executable instructions are used to execute the system monitoring log collection method as described in any one of claims 1-6 when executed by a computer processor.