Log data transmission method, system and device and electronic equipment
By using the log collection tool and TFTP protocol on the host computer to transmit log data to the target terminal, the problem of insufficient memory of the host computer cannot store log data is solved, which improves system stability and reduces the risk of crashes.
Patent Information
- Application Number
- CN202411355164.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-26
- Publication Date
- 2025-02-18
AI Technical Summary
When the host computer crawls Log data in a Linux environment, insufficient memory cannot meet the storage needs of long-term hang-up tests and high-frequency data acquisition, resulting in system instability or crash.
The log collection tool collects log data based on the target instructions and uses the TFTP protocol to transmit the log data to the target terminal's database in real time, relieving the storage pressure of the host computer.
It realizes long-term storage and management of log data, improves system stability, and reduces the risk of system crash caused by insufficient memory.
Smart Images

Figure CN119484500A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computers, and in particular to a method, system, device and electronic device for transmitting log data. Background Art
[0002] At present, when the host computer captures logs (log data) in the Linux environment, it needs to rely on the log tool. However, this tool has some limitations and can only store a few types of logs on the customer's host computer. In addition, the log tool runs under the Linux system, and the captured logs can only be stored under the Linux system and cannot be transmitted in real time. Through statistical analysis, it was found that the maximum memory of the customer's host computer is only 400MB, which cannot meet the log storage requirements during long-term testing and module transfer. In this case, the host computer can easily crash due to insufficient memory, thus affecting the entire test and debugging process. This problem is particularly prominent in long-term monitoring and high-frequency data collection, because the increase in data volume will quickly consume limited storage space, causing system instability or even crash. Summary of the invention
[0003] The present application provides a log data transmission method, system, device and electronic device to solve the technical problem that insufficient memory of a host computer cannot meet the log data storage requirements.
[0004] In the first aspect, the present application provides a method for transmitting log data, which is applied to a host computer, including: collecting log data based on target instructions through a log collection tool; wherein the above-mentioned log collection tool is a tool generated by a target terminal under the development environment of the above-mentioned target terminal; sending the above-mentioned log data to the target terminal based on preset transmission information, so that the above-mentioned target terminal saves the above-mentioned log data to a target database; wherein the above-mentioned host computer and the above-mentioned target terminal establish a transmission link based on a preset protocol.
[0005] In the second aspect, the present application provides a method for transmitting log data, which is applied to a target terminal, including: receiving log data sent by a host computer based on preset transmission information; wherein the above-mentioned log data is collected by the above-mentioned host computer through a log collection tool based on target instructions; saving the above-mentioned log data to a target database; wherein the above-mentioned host computer and the above-mentioned target terminal establish a transmission link based on a preset protocol.
[0006] In a third aspect, the present application provides a log data transmission system, comprising: a host computer, used to run target instructions through a log collection tool to collect log data, and send the above-mentioned log data to a target terminal based on preset transmission information; wherein the above-mentioned log collection tool is a tool generated by the above-mentioned target terminal under the development environment of the above-mentioned target terminal, and the above-mentioned host computer and the above-mentioned target terminal establish a transmission link based on a preset protocol; the above-mentioned target terminal is used to receive the above-mentioned log data based on the above-mentioned preset transmission information, and save the above-mentioned log data to a target database.
[0007] In a fourth aspect, the present application provides a log data transmission device, which is applied to a host computer, including: a collection module, which is used to collect log data based on target instructions through a log collection tool; wherein the above-mentioned log collection tool is a tool generated by the target terminal under the development environment of the above-mentioned target terminal; a sending module, which is used to send the above-mentioned log data to the target terminal based on preset transmission information, so that the above-mentioned target terminal saves the above-mentioned log data to the target database; wherein the above-mentioned host computer and the above-mentioned target terminal establish a transmission link based on a preset protocol.
[0008] As an optional example, the above-mentioned preset transmission information includes a pointing parameter and a designated address, and the above-mentioned device also includes: a determination module, which is used to determine that the above-mentioned designated address is the address of the file transfer server of the above-mentioned target terminal based on the above-mentioned pointing parameter before sending the above-mentioned log data to the target terminal based on the preset transmission information.
[0009] As an optional example, the above-mentioned device also includes: a connection module, which is used to connect to a target network before collecting log data based on target instructions through the log collection tool; wherein the above-mentioned target network is the same as the network connected to the above-mentioned target terminal.
[0010] As an optional example, the above-mentioned device also includes: an establishment module, which is used to establish a protocol first end based on the above-mentioned preset protocol before sending the above-mentioned log data to the target terminal based on the preset transmission information, so as to perform data transmission with the protocol second end of the above-mentioned target terminal.
[0011] In the fifth aspect, the present application provides a log data transmission device, which is applied to a target terminal, including: a receiving module, used to receive log data sent by a host computer based on preset transmission information; wherein the above-mentioned log data is collected by the above-mentioned host computer through a log collection tool based on target instructions; a saving module, used to save the above-mentioned log data to a target database; wherein the above-mentioned host computer and the above-mentioned target terminal establish a transmission link based on a preset protocol.
[0012] As an optional example, the above-mentioned device also includes: a connection module, which is used to connect to a target network before receiving the log data sent by the host computer based on the preset transmission information; wherein the above-mentioned target network is the same as the network connected to the above-mentioned host computer.
[0013] As an optional example, the above-mentioned device also includes: an installation module, which is used to install a file transfer tool and establish a file transfer server based on the above-mentioned file transfer tool before receiving the log data sent by the upper computer based on the preset transmission information; an establishment module, which is used to establish a second end of the protocol based on the preset protocol of the above-mentioned file transfer server to transmit data with the first end of the protocol of the above-mentioned upper computer.
[0014] In a sixth aspect, the present application provides a storage medium storing a computer program, wherein the computer program executes the above-mentioned log data transmission method when executed by a processor.
[0015] In a seventh aspect, the present application further provides an electronic device, comprising a memory and a processor, wherein the memory stores a computer program, and the processor is configured to execute the log data transmission method through the computer program.
[0016] In an embodiment of the present application, it is applied to a host computer, and log data is collected based on target instructions through a log collection tool; wherein the log collection tool is a tool generated by the target terminal under the development environment of the target terminal; the log data is sent to the target terminal based on preset transmission information, so that the target terminal saves the log data to a target database; wherein the host computer and the target terminal establish a transmission link based on a preset protocol. Since in the above method, the host computer transmits the log data to the target terminal in real time through the log collection tool, so that the target terminal saves the received log data to the target database, ensuring long-term storage and management of the data, and utilizing the remote transmission capability of the preset protocol to realize the real-time transfer of the log data of the host computer to a target terminal with a large space, significantly improving the stability of the system, and reducing the risk of system crashes caused by insufficient memory, thereby solving the technical problem that the host computer is unable to meet the log data storage requirements due to insufficient memory. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0018] In order to more clearly illustrate the embodiments of the present application 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, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0019] One or more embodiments are exemplarily described by pictures in the corresponding drawings, and these exemplified descriptions do not constitute limitations on the embodiments. Elements with the same reference numerals in the drawings represent similar elements, and unless otherwise stated, the figures in the drawings do not constitute proportional limitations.
[0020] Figure 1 is a flowchart of an implementation of an optional log data transmission method according to an embodiment of the present application;
[0021] Figure 2 is a flowchart of an implementation of an optional log data transmission method according to an embodiment of the present application;
[0022] Figure 3 is a schematic diagram of the structure of an optional log data transmission system according to an embodiment of the present application;
[0023] Figure 4 This is a specific implementation flow chart of an optional log data transmission system according to an embodiment of the present application;
[0024] Figure 5 is a schematic structural diagram of an optional log data transmission device according to an embodiment of the present application;
[0025] Figure 6 is a schematic structural diagram of an optional log data transmission device according to an embodiment of the present application;
[0026] Figure 7 is a schematic diagram of an optional electronic device according to an embodiment of the present application. DETAILED DESCRIPTION
[0027] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.
[0028] The disclosure below provides many different embodiments or examples to realize the different structures of the present application. In order to simplify the disclosure of the present application, the parts and settings of specific examples are described below. Of course, they are only examples, and the purpose is not to limit the present application. In addition, the present application can repeat reference numbers and / or letters in different examples. This repetition is for the purpose of simplification and clarity, and does not itself indicate the relationship between the various embodiments and / or settings discussed.
[0029] According to a first aspect of an embodiment of the present application, a method for transmitting log data is provided, which is applied to a host computer, and optionally, Figure 1 As shown, the above method includes:
[0030] S102, collecting log data based on target instructions through a log collection tool; wherein the log collection tool is a tool generated by the target terminal in a development environment of the target terminal;
[0031] S104, sending the log data to the target terminal based on the preset transmission information, so that the target terminal saves the log data to the target database; wherein the host computer and the target terminal establish a transmission link based on the preset protocol.
[0032] Alternatively, in order to solve the problem of insufficient memory of host computer, utilize TFTP protocol (preset protocol) to realize that the daily record data of host computer is transferred in real time and stored in target terminal, TFTP (Trivial File Transfer Protocol, simple file transfer protocol) is a protocol for carrying out simple file transfer between client and server in TCP / IP protocol family.Therefore, in the present embodiment, host computer (usually running Linux) installs Logtool tool (log collection tool), for grabbing and processing daily record data, and builds TFTP client, prepares to transfer daily record data to target terminal.Target terminal (possessing large capacity storage) installs TFTP tool (file transfer tool), configures TFTP server (file transfer server), to receive the daily record data from host computer. The host computer runs the Logtool tool and executes the target command ". / logtool-i tftp" to start capturing Log data (log data). The Logtool tool transmits the collected log data to the TFTP client in real time. The TFTP client sends the log data to the TFTP server of the target terminal. After receiving the log data, the TFTP server saves it to the target database of the target terminal. By transferring the log data to the target terminal in real time, the memory pressure of the host computer is effectively reduced, the system stability is guaranteed, and the lightweight and easy-to-implement characteristics of the TFTP protocol improve the efficiency of data transmission.
[0033] Optionally, in the present embodiment, the Logtool tool is generated by the target terminal under its development environment, and the host computer only needs to have execution authority. The target terminal is responsible for generating the Logtool tool under its development environment and transmitting it to the host computer. The host computer only needs to have execution authority to run the tool, ensure that the tool can run correctly and transmit the log data to the TFTP server, and finally be processed by the target terminal and saved to the target database. Before installing the Logtool tool, the host computer downloads the corresponding binary file from the target terminal, and compiles and generates an executable file on the host computer according to the provided source code and compilation instructions. This process ensures that the Logtool tool can run normally under a specific operating system and hardware environment. After the compilation is completed, the Logtool tool needs to be installed, configured and tested to ensure that its function meets the requirements. Before installing the TFTP tool, the target terminal needs to obtain and compile the binary file of the TFTP tool. Specifically, download the binary file of the TFTP tool, install the necessary compilation tool and environment on the target terminal, compile using the compilation tool, and after the compilation is completed, test the generated binary file to ensure that it can work normally and perform the expected function. Install the compiled TFTP tool to the appropriate location of the target terminal, configure the settings of the TFTP tool as needed, start the TFTP tool, and ensure that the TFTP tool saves the received log data to the predetermined storage location. After the installation and configuration are completed, establish a TFTP server based on the TFTP tool to receive the log data transmitted from the host computer and perform further data processing and storage.
[0034] Optionally, in this embodiment, the host computer transmits log data to the target terminal in real time through the log collection tool, so that the target terminal saves the received log data into the target database, ensuring the long-term storage and management of the data, and utilizing the remote transmission capability of the preset protocol to realize the real-time transfer of the log data of the host computer to the target terminal in a large space, thereby significantly improving the stability of the system and reducing the risk of system crashes due to insufficient memory, thereby solving the technical problem that the host computer is unable to meet the log data storage requirements due to insufficient memory.
[0035] As an optional example, the preset transmission information includes a pointing parameter and a specified address. Before sending the log data to the target terminal based on the preset transmission information, the method further includes:
[0036] The address of the file transfer server designated as the target terminal is determined based on the pointing parameter.
[0037] Optionally, in the present embodiment, the target instruction can be ". / logtoo li tftp:IP", which is used to transfer log data from the host computer to the TFTP server. This instruction includes two main parts: the pointing parameter "-i" and the specified address "tftp:IP". The pointing parameter is a setting item in the target instruction, which is used to specify the source, type, format and transmission mode of the log data. These parameters ensure that the log data is processed and transmitted according to the expected format and content. The specified address is the network address used to point to the TFTP server in the target instruction, that is, the destination to which the log data will be sent. The target instruction plays a key role in the log data transmission process, ensuring that the log data is transmitted to the TFTP server according to the specified parameters and address. By correctly configuring the target instruction, running the log collection tool, verifying the integrity of the data transmission and resolving possible faults, efficient and accurate log data transmission can be achieved.
[0038] As an optional example, before collecting log data based on the target instruction by using the log collection tool, the method further includes:
[0039] Connect to a target network; wherein the target network is the same as the network to which the target terminal is connected.
[0040] Optionally, in this embodiment, before collecting and transmitting log data, it is necessary to connect the host computer and the target terminal to the same network, or directly connect the two devices through a network cable. After the two devices are connected to the same network, run test instructions on the two devices to confirm that they can communicate with each other. If the test instruction runs successfully, it means that the network connection is normal. This ensures the smooth transmission of log data and lays the foundation for the subsequent establishment of the protocol.
[0041] As an optional example, before sending the log data to the target terminal based on the preset transmission information, the method further includes:
[0042] A protocol first end is established based on a preset protocol to perform data transmission with a protocol second end of a target terminal.
[0043] Optionally, in this embodiment, the TFTP protocol acts as a bridge, connecting a host computer with limited memory and a target terminal with large storage space. By building a TFTP client on the host computer and connecting to the TFTP server on the target terminal, it is ensured that the log data can be transmitted and stored soon after generation, avoiding the situation of insufficient memory of the host computer. This real-time transmission design can significantly improve the stability of the system and reduce the risk of system crash caused by insufficient memory.
[0044] It should be noted that, for the aforementioned method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the described order of actions, because according to the present application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present application.
[0045] According to a second aspect of an embodiment of the present application, a method for transmitting log data is provided, which is applied to a target terminal, and optionally, Figure 2 As shown, the above method includes:
[0046] S202, receiving log data sent by the host computer based on preset transmission information; wherein the log data is collected by the host computer through a log collection tool based on a target instruction;
[0047] S204, saving the log data to the target database; wherein the host computer and the target terminal establish a transmission link based on a preset protocol.
[0048] Alternatively, in order to solve the problem of insufficient memory of host computer, utilize TFTP protocol (preset protocol) to realize that the daily record data of host computer is transferred in real time and stored in target terminal, TFTP (Trivial File Transfer Protocol, simple file transfer protocol) is a protocol for carrying out simple file transfer between client and server in TCP / IP protocol family.Therefore, in the present embodiment, host computer (usually running Linux) installs Logtool tool (log collection tool), for grabbing and processing daily record data, and builds TFTP client, prepares to transfer daily record data to target terminal.Target terminal (possessing large capacity storage) installs TFTP tool (file transfer tool), configures TFTP server (file transfer server), to receive the daily record data from host computer. The host computer runs the Logtool tool and executes the target command ". / logtool-i tftp" to start capturing Log data (log data). The Logtool tool transmits the collected log data to the TFTP client in real time. The TFTP client sends the log data to the TFTP server of the target terminal. After receiving the log data, the TFTP server saves it to the target database of the target terminal. By transferring the log data to the target terminal in real time, the memory pressure of the host computer is effectively reduced, the system stability is guaranteed, and the lightweight and easy-to-implement characteristics of the TFTP protocol improve the efficiency of data transmission.
[0049] Optionally, in the present embodiment, the Logtool tool is generated by the target terminal under its development environment, and the host computer only needs to have execution authority. The target terminal is responsible for generating the Logtool tool under its development environment and transmitting it to the host computer. The host computer only needs to have execution authority to run the tool, ensure that the tool can run correctly and transmit the log data to the TFTP server, and finally be processed by the target terminal and saved to the target database. Before installing the Logtool tool, the host computer downloads the corresponding binary file from the target terminal, and compiles and generates an executable file on the host computer according to the provided source code and compilation instructions. This process ensures that the Logtool tool can run normally under a specific operating system and hardware environment. After the compilation is completed, the Logtool tool needs to be installed, configured and tested to ensure that its function meets the requirements. Before installing the TFTP tool, the target terminal needs to obtain and compile the binary file of the TFTP tool. Specifically, download the binary file of the TFTP tool, install the necessary compilation tool and environment on the target terminal, compile using the compilation tool, and after the compilation is completed, test the generated binary file to ensure that it can work normally and perform the expected function. Install the compiled TFTP tool to the appropriate location of the target terminal, configure the settings of the TFTP tool as needed, start the TFTP tool, and ensure that the TFTP tool saves the received log data to the predetermined storage location. After the installation and configuration are completed, establish a TFTP server based on the TFTP tool to receive the log data transmitted from the host computer and perform further data processing and storage.
[0050] Optionally, in this embodiment, the host computer transmits log data to the target terminal in real time through the log collection tool, so that the target terminal saves the received log data into the target database, ensuring the long-term storage and management of the data, and utilizing the remote transmission capability of the preset protocol to realize the real-time transfer of the log data of the host computer to the target terminal in a large space, thereby significantly improving the stability of the system and reducing the risk of system crashes due to insufficient memory, thereby solving the technical problem that the host computer is unable to meet the log data storage requirements due to insufficient memory.
[0051] As an optional example, before receiving the log data sent by the host computer based on the preset transmission information, the method further includes:
[0052] Connect to the target network; the target network is the same as the network connected to the host computer.
[0053] Optionally, in this embodiment, before collecting and transmitting log data, it is necessary to connect the host computer and the target terminal to the same network, or directly connect the two devices through a network cable. After the two devices are connected to the same network, run test instructions on the two devices to confirm that they can communicate with each other. If the test instruction runs successfully, it means that the network connection is normal. This ensures the smooth transmission of log data and lays the foundation for the subsequent establishment of the protocol.
[0054] As an optional example, before receiving the log data sent by the host computer based on the preset transmission information, the method further includes:
[0055] Install the file transfer tool and establish a file transfer server based on the file transfer tool;
[0056] A second protocol end is established based on a preset protocol of the file transfer server to perform data transmission with a first protocol end of the host computer.
[0057] Optionally, in the present embodiment, before the target terminal receives the log data sent by the host computer based on the TFTP transmission protocol, it is necessary to first obtain and compile the binary file of the TFTP tool. Specifically, download the binary file of the TFTP tool, install necessary compilation tools and environment on the target terminal, compile using the compilation tool, and after the compilation is completed, test the generated binary file to ensure that it can work normally and perform the expected function. The compiled TFTP tool is installed to the appropriate position of the target terminal, the setting of the TFTP tool is configured as required, and the TFTP tool is started to ensure that the TFTP tool saves the received log data to a predetermined storage location. After installation and configuration are completed, a TFTP server is established based on the TFTP tool to receive the log data transmitted from the host computer, and further data processing and storage are performed. TFTP serves as a bridge, connecting the host computer with limited memory and the target terminal with large storage space. TFTP client is built on the host computer, and connected with the TFTP server on the target terminal, ensuring that the log can be transmitted and stored to the target terminal soon after generation.
[0058] For other examples of this embodiment, please refer to the above examples and will not be repeated here.
[0059] According to a third aspect of an embodiment of the present application, a system for transmitting log data is provided. Optionally, as Figure 3 As shown, the above system includes:
[0060] The host computer 302 is used to run the target instruction through the log collection tool to collect log data, and send the log data to the target terminal based on the preset transmission information; wherein the log collection tool is a tool generated by the target terminal in the development environment of the target terminal, and the host computer and the target terminal establish a transmission link based on the preset protocol;
[0061] The target terminal 304 is used to receive the log data based on the preset transmission information and save the log data to the target database.
[0062] Alternatively, in order to solve the problem of insufficient memory of host computer, utilize TFTP protocol (preset protocol) to realize that the daily record data of host computer is transferred in real time and stored in target terminal, TFTP (Trivial File Transfer Protocol, simple file transfer protocol) is a protocol for carrying out simple file transfer between client and server in TCP / IP protocol family.Therefore, in the present embodiment, host computer (usually running Linux) installs Logtool tool (log collection tool), for grabbing and processing daily record data, and builds TFTP client, prepares to transfer daily record data to target terminal.Target terminal (possessing large capacity storage) installs TFTP tool (file transfer tool), configures TFTP server (file transfer server), to receive the daily record data from host computer. The host computer runs the Logtool tool and executes the target command ". / logtool-i tftp" to start capturing Log data (log data). The Logtool tool transmits the collected log data to the TFTP client in real time. The TFTP client sends the log data to the TFTP server of the target terminal. After receiving the log data, the TFTP server saves it to the target database of the target terminal. By transferring the log data to the target terminal in real time, the memory pressure of the host computer is effectively reduced, the system stability is guaranteed, and the lightweight and easy-to-implement characteristics of the TFTP protocol improve the efficiency of data transmission.
[0063] Optionally, in the present embodiment, the Logtool tool is generated by the target terminal under its development environment, and the host computer only needs to have execution authority. The target terminal is responsible for generating the Logtool tool under its development environment and transmitting it to the host computer. The host computer only needs to have execution authority to run the tool, ensure that the tool can run correctly and transmit the log data to the TFTP server, and finally be processed by the target terminal and saved to the target database. Before installing the Logtool tool, the host computer downloads the corresponding binary file from the target terminal, and compiles and generates an executable file on the host computer according to the provided source code and compilation instructions. This process ensures that the Logtool tool can run normally under a specific operating system and hardware environment. After the compilation is completed, the Logtool tool needs to be installed, configured and tested to ensure that its function meets the requirements. Before installing the TFTP tool, the target terminal needs to obtain and compile the binary file of the TFTP tool. Specifically, download the binary file of the TFTP tool, install the necessary compilation tool and environment on the target terminal, compile using the compilation tool, and after the compilation is completed, test the generated binary file to ensure that it can work normally and perform the expected function. Install the compiled TFTP tool to the appropriate location of the target terminal, configure the settings of the TFTP tool as needed, start the TFTP tool, and ensure that the TFTP tool saves the received log data to the predetermined storage location. After the installation and configuration are completed, establish a TFTP server based on the TFTP tool to receive the log data transmitted from the host computer and perform further data processing and storage.
[0064] Optionally, in this embodiment, the host computer transmits log data to the target terminal in real time through the log collection tool, so that the target terminal saves the received log data into the target database, ensuring the long-term storage and management of the data, and utilizing the remote transmission capability of the preset protocol to realize the real-time transfer of the log data of the host computer to the target terminal in a large space, thereby significantly improving the stability of the system and reducing the risk of system crashes due to insufficient memory, thereby solving the technical problem that the host computer is unable to meet the log data storage requirements due to insufficient memory.
[0065] Combined with an example, this system includes a host computer and a target terminal. The log data of the host computer is transferred and stored in the target terminal in real time through the TFTP protocol to solve the problem of insufficient memory in the host computer. The specific implementation steps are as follows: Figure 4 As shown in the implementation flow chart;
[0066] 1. The host computer installs the Logtool tool generated by the target terminal in its development environment, and the host computer has the execution permission of the Logtool tool;
[0067] 2. The target terminal downloads and installs the TFTP tool and establishes a TFTP server;
[0068] 3. Connect the target terminal and the host computer to the same network, or directly connect the two devices via a network cable;
[0069] 4. The host computer executes the target command ". / logtoo l-itftp:IP" through the Logtool tool to establish a TFTP client to transmit the collected Log data to the TFTP client in real time. The TFTP client will send the Log data to the TFTP server on the target terminal;
[0070] 5. After receiving the log file, the TFTP server saves the log data to the target database of the target terminal.
[0071] For other examples of this embodiment, please refer to the above examples and will not be repeated here.
[0072] According to a fourth aspect of the embodiments of the present application, a log data transmission device is provided, which is applied to a host computer, and optionally, Figure 5 As shown, the above device comprises:
[0073] A collection module 502, configured to collect log data based on target instructions through a log collection tool; wherein the log collection tool is a tool generated by the target terminal in the development environment of the target terminal;
[0074] The sending module 504 is used to send the log data to the target terminal based on the preset transmission information, so that the target terminal saves the log data to the target database; wherein the host computer and the target terminal establish a transmission link based on the preset protocol.
[0075] Alternatively, in order to solve the problem of insufficient memory of host computer, utilize TFTP protocol (preset protocol) to realize that the daily record data of host computer is transferred in real time and stored in target terminal, TFTP (Trivial File Transfer Protocol, simple file transfer protocol) is a protocol for carrying out simple file transfer between client and server in TCP / IP protocol family.Therefore, in the present embodiment, host computer (usually running Linux) installs Logtool tool (log collection tool), for grabbing and processing daily record data, and builds TFTP client, prepares to transfer daily record data to target terminal.Target terminal (possessing large capacity storage) installs TFTP tool (file transfer tool), configures TFTP server (file transfer server), to receive the daily record data from host computer. The host computer runs the Logtool tool and executes the target command ". / logtool-i tftp" to start capturing Log data (log data). The Logtool tool transmits the collected log data to the TFTP client in real time. The TFTP client sends the log data to the TFTP server of the target terminal. After receiving the log data, the TFTP server saves it to the target database of the target terminal. By transferring the log data to the target terminal in real time, the memory pressure of the host computer is effectively reduced, the system stability is guaranteed, and the lightweight and easy-to-implement characteristics of the TFTP protocol improve the efficiency of data transmission.
[0076] Optionally, in the present embodiment, the Logtool tool is generated by the target terminal under its development environment, and the host computer only needs to have execution authority. The target terminal is responsible for generating the Logtool tool under its development environment and transmitting it to the host computer. The host computer only needs to have execution authority to run the tool, ensure that the tool can run correctly and transmit the log data to the TFTP server, and finally be processed by the target terminal and saved to the target database. Before installing the Logtool tool, the host computer downloads the corresponding binary file from the target terminal, and compiles and generates an executable file on the host computer according to the provided source code and compilation instructions. This process ensures that the Logtool tool can run normally under a specific operating system and hardware environment. After the compilation is completed, the Logtool tool needs to be installed, configured and tested to ensure that its function meets the requirements. Before installing the TFTP tool, the target terminal needs to obtain and compile the binary file of the TFTP tool. Specifically, download the binary file of the TFTP tool, install the necessary compilation tool and environment on the target terminal, compile using the compilation tool, and after the compilation is completed, test the generated binary file to ensure that it can work normally and perform the expected function. Install the compiled TFTP tool to the appropriate location of the target terminal, configure the settings of the TFTP tool as needed, start the TFTP tool, and ensure that the TFTP tool saves the received log data to the predetermined storage location. After the installation and configuration are completed, establish a TFTP server based on the TFTP tool to receive the log data transmitted from the host computer and perform further data processing and storage.
[0077] Optionally, in this embodiment, the host computer transmits log data to the target terminal in real time through the log collection tool, so that the target terminal saves the received log data into the target database, ensuring the long-term storage and management of the data, and utilizing the remote transmission capability of the preset protocol to realize the real-time transfer of the log data of the host computer to the target terminal in a large space, thereby significantly improving the stability of the system and reducing the risk of system crashes due to insufficient memory, thereby solving the technical problem that the host computer is unable to meet the log data storage requirements due to insufficient memory.
[0078] As an optional example, the preset transmission information includes a pointing parameter and a designated address, and the above-mentioned device further includes:
[0079] The determination module is used to determine the address of the file transmission server whose designated address is the target terminal based on the pointing parameter before sending the log data to the target terminal based on the preset transmission information.
[0080] Optionally, in the present embodiment, the target instruction can be ". / logtoo li tftp:IP", which is used to transfer log data from the host computer to the TFTP server. This instruction includes two main parts: the pointing parameter "-i" and the specified address "tftp:IP". The pointing parameter is a setting item in the target instruction, which is used to specify the source, type, format and transmission mode of the log data. These parameters ensure that the log data is processed and transmitted according to the expected format and content. The specified address is the network address used to point to the TFTP server in the target instruction, that is, the destination to which the log data will be sent. The target instruction plays a key role in the log data transmission process, ensuring that the log data is transmitted to the TFTP server according to the specified parameters and address. By correctly configuring the target instruction, running the log collection tool, verifying the integrity of the data transmission and resolving possible faults, efficient and accurate log data transmission can be achieved.
[0081] As an optional example, the above device further includes:
[0082] A connection module is used to connect to a target network before collecting log data based on a target instruction through a log collection tool; wherein the target network is the same as the network to which the target terminal is connected.
[0083] Optionally, in this embodiment, before collecting and transmitting log data, it is necessary to connect the host computer and the target terminal to the same network, or directly connect the two devices through a network cable. After the two devices are connected to the same network, run test instructions on the two devices to confirm that they can communicate with each other. If the test instruction runs successfully, it means that the network connection is normal. This ensures the smooth transmission of log data and lays the foundation for the subsequent establishment of the protocol.
[0084] As an optional example, the above device further includes:
[0085] The establishing module is used to establish a protocol first end based on a preset protocol before sending the log data to the target terminal based on the preset transmission information, so as to perform data transmission with the protocol second end of the target terminal.
[0086] Optionally, in this embodiment, the TFTP protocol acts as a bridge, connecting a host computer with limited memory and a target terminal with large storage space. By building a TFTP client on the host computer and connecting to the TFTP server on the target terminal, it is ensured that the log data can be transmitted and stored soon after generation, avoiding the situation of insufficient memory of the host computer. This real-time transmission design can significantly improve the stability of the system and reduce the risk of system crash caused by insufficient memory.
[0087] For other examples of this embodiment, please refer to the above examples and will not be repeated here.
[0088] According to a fifth aspect of the embodiments of the present application, a log data transmission device is provided, which is applied to a target terminal, and optionally, Figure 6 As shown, the above device comprises:
[0089] The receiving module 602 is used to receive the log data sent by the host computer based on the preset transmission information; wherein the log data is collected by the host computer through the log collection tool based on the target instruction;
[0090] The saving module 604 is used to save the log data to the target database; wherein the host computer and the target terminal establish a transmission link based on a preset protocol.
[0091] Alternatively, in order to solve the problem of insufficient memory of host computer, utilize TFTP protocol (preset protocol) to realize that the daily record data of host computer is transferred in real time and stored in target terminal, TFTP (Trivial File Transfer Protocol, simple file transfer protocol) is a protocol for carrying out simple file transfer between client and server in TCP / IP protocol family.Therefore, in the present embodiment, host computer (usually running Linux) installs Logtool tool (log collection tool), for grabbing and processing daily record data, and builds TFTP client, prepares to transfer daily record data to target terminal.Target terminal (possessing large capacity storage) installs TFTP tool (file transfer tool), configures TFTP server (file transfer server), to receive the daily record data from host computer. The host computer runs the Logtool tool and executes the target command ". / logtool-i tftp" to start capturing Log data (log data). The Logtool tool transmits the collected log data to the TFTP client in real time. The TFTP client sends the log data to the TFTP server of the target terminal. After receiving the log data, the TFTP server saves it to the target database of the target terminal. By transferring the log data to the target terminal in real time, the memory pressure of the host computer is effectively reduced, the system stability is guaranteed, and the lightweight and easy-to-implement characteristics of the TFTP protocol improve the efficiency of data transmission.
[0092] Optionally, in the present embodiment, the Logtool tool is generated by the target terminal under its development environment, and the host computer only needs to have execution authority. The target terminal is responsible for generating the Logtool tool under its development environment and transmitting it to the host computer. The host computer only needs to have execution authority to run the tool, ensure that the tool can run correctly and transmit the log data to the TFTP server, and finally be processed by the target terminal and saved to the target database. Before installing the Logtool tool, the host computer downloads the corresponding binary file from the target terminal, and compiles and generates an executable file on the host computer according to the provided source code and compilation instructions. This process ensures that the Logtool tool can run normally under a specific operating system and hardware environment. After the compilation is completed, the Logtool tool needs to be installed, configured and tested to ensure that its function meets the requirements. Before installing the TFTP tool, the target terminal needs to obtain and compile the binary file of the TFTP tool. Specifically, download the binary file of the TFTP tool, install the necessary compilation tool and environment on the target terminal, compile using the compilation tool, and after the compilation is completed, test the generated binary file to ensure that it can work normally and perform the expected function. Install the compiled TFTP tool to the appropriate location of the target terminal, configure the settings of the TFTP tool as needed, start the TFTP tool, and ensure that the TFTP tool saves the received log data to the predetermined storage location. After the installation and configuration are completed, establish a TFTP server based on the TFTP tool to receive the log data transmitted from the host computer and perform further data processing and storage.
[0093] Optionally, in this embodiment, the host computer transmits log data to the target terminal in real time through the log collection tool, so that the target terminal saves the received log data into the target database, ensuring the long-term storage and management of the data, and utilizing the remote transmission capability of the preset protocol to realize the real-time transfer of the log data of the host computer to the target terminal in a large space, thereby significantly improving the stability of the system and reducing the risk of system crashes due to insufficient memory, thereby solving the technical problem that the host computer is unable to meet the log data storage requirements due to insufficient memory.
[0094] As an optional example, the above device further includes:
[0095] The connection module is used to connect to a target network before receiving log data sent by the host computer based on preset transmission information; wherein the target network is the same as the network connected to the host computer.
[0096] Optionally, in this embodiment, before collecting and transmitting log data, it is necessary to connect the host computer and the target terminal to the same network, or directly connect the two devices through a network cable. After the two devices are connected to the same network, run test instructions on the two devices to confirm that they can communicate with each other. If the test instruction runs successfully, it means that the network connection is normal. This ensures the smooth transmission of log data and lays the foundation for the subsequent establishment of the protocol.
[0097] As an optional example, the above device further includes:
[0098] An installation module, used for installing a file transfer tool before receiving log data sent by a host computer based on preset transmission information, and establishing a file transfer server based on the file transfer tool;
[0099] The establishing module is used to establish a second protocol end based on a preset protocol of the file transfer server to perform data transmission with a first protocol end of the host computer.
[0100] Optionally, in the present embodiment, before the target terminal receives the log data sent by the host computer based on the TFTP transmission protocol, it is necessary to first obtain and compile the binary file of the TFTP tool. Specifically, download the binary file of the TFTP tool, install necessary compilation tools and environment on the target terminal, compile using the compilation tool, and after the compilation is completed, test the generated binary file to ensure that it can work normally and perform the expected function. The compiled TFTP tool is installed to the appropriate position of the target terminal, the setting of the TFTP tool is configured as required, and the TFTP tool is started to ensure that the TFTP tool saves the received log data to a predetermined storage location. After installation and configuration are completed, a TFTP server is established based on the TFTP tool to receive the log data transmitted from the host computer, and further data processing and storage are performed. TFTP serves as a bridge, connecting the host computer with limited memory and the target terminal with large storage space. TFTP client is built on the host computer, and connected with the TFTP server on the target terminal, ensuring that the log can be transmitted and stored to the target terminal soon after generation.
[0101] For other examples of this embodiment, please refer to the above examples and will not be repeated here.
[0102] Figure 7 is a schematic diagram of an optional electronic device according to an embodiment of the present application, such as Figure 7 As shown, it includes a processor 702, a communication interface 704, a memory 706 and a communication bus 708, wherein the processor 702, the communication interface 704 and the memory 706 communicate with each other through the communication bus 708, wherein,
[0103] Memory 706, used to store computer programs;
[0104] The processor 702 is used to implement the following steps when executing the computer program stored in the memory 706:
[0105] Collecting log data based on target instructions through a log collection tool; wherein the log collection tool is a tool generated by the target terminal in a development environment of the target terminal;
[0106] The log data is sent to the target terminal based on the preset transmission information, so that the target terminal saves the log data to the target database; wherein, the host computer and the target terminal establish a transmission link based on the preset protocol.
[0107] Optionally, in this embodiment, the communication bus may be a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industrial Standard Architecture) bus. The communication bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 7 The communication interface is used for communication between the above electronic device and other devices.
[0108] The memory may include RAM, or may include non-volatile memory, such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.
[0109] As an example, the memory 706 may include but is not limited to the collection module 502 and the sending module 504 in the log data transmission device. In addition, it may also include but is not limited to other module units in the log data transmission device, which will not be repeated in this example.
[0110] The above-mentioned processor can be a general-purpose processor, which can include but not be limited to: CPU (Central Processing Unit), NP (Network Processor), etc.; it can also be DSP (Digital Signal Processing), ASIC (Application Specific Integrated Circuit), FPGA (Field-Programmable Gate Array) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
[0111] Optionally, the specific examples in this embodiment may refer to the examples described in the above embodiments, and this embodiment will not be described in detail here.
[0112] It can be understood by those skilled in the art that Figure 7 The structure shown is for illustration only. The device implementing the above-mentioned log data transmission method may be a module capable of realizing communication functions or a terminal device including the module, etc. The terminal device may be a mobile terminal or a smart terminal. The mobile terminal may be at least one of a mobile phone, a tablet computer, a laptop computer, etc.; the smart terminal may be a terminal including a wireless communication module such as a smart car, a smart watch, a shared bicycle, a smart cabinet, etc.; the module may be a wireless communication module, such as any one of a 2G communication module, a 3G communication module, a 4G communication module, a 7G communication module, and a NB-IOT communication module. Figure 7 The structure of the electronic device is not limited. For example, the electronic device may also include Figure 7 More or fewer components (such as network interfaces, display devices, etc.) shown in, or having Figure 7 Different configurations shown.
[0113] A person of ordinary skill in the art can understand that all or part of the steps in the various methods of the above embodiments can be completed by instructing the hardware related to the terminal device through a program, and the program can be stored in a computer-readable storage medium, which can include: a flash drive, ROM, RAM, a magnetic disk or an optical disk, etc.
[0114] According to another aspect of an embodiment of the present application, a computer-readable storage medium is provided, in which a computer program is stored, wherein the computer program executes the steps in the above-mentioned log data transmission method when executed by a processor.
[0115] Optionally, in this embodiment, a person of ordinary skill in the art may understand that all or part of the steps in the various methods of the above embodiments may be completed by instructing hardware related to the terminal device through a program, and the program may be stored in a computer-readable storage medium, and the storage medium may include: a flash drive, a read-only memory (ROM), a random access memory (RAM), a disk or an optical disk, etc.
[0116] The serial numbers of the above-mentioned embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.
[0117] If the integrated units in the above embodiments are implemented in the form of software functional units and sold or used as independent products, they can be stored in the above computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for enabling one or more computer devices (which may be personal computers, servers, or network devices, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present application.
[0118] In the above embodiments of the present application, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, please refer to the relevant description of other embodiments.
[0119] In the several embodiments provided in the present application, it should be understood that the disclosed client can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.
[0120] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0121] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0122] The above is only a preferred implementation of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.
Claims
1. A method for transmitting log data, characterized in that: Applied to the host computer, including: Collecting log data based on target instructions through a log collection tool; wherein the log collection tool is a tool generated by the target terminal in the development environment of the target terminal; The log data is sent to a target terminal based on preset transmission information, so that the target terminal saves the log data to a target database; wherein the host computer and the target terminal establish a transmission link based on a preset protocol.
2. The method according to claim 1, characterized in that The preset transmission information includes a pointing parameter and a designated address. Before sending the log data to the target terminal based on the preset transmission information, the method further includes: The designated address is determined to be the address of the file transfer server of the target terminal based on the pointing parameter.
3. The method according to claim 1, characterized in that Before collecting log data based on the target instruction by the log collection tool, the method further includes: Connect to a target network; wherein the target network is the same as the network to which the target terminal is connected.
4. The method according to claim 1, characterized in that: Before sending the log data to the target terminal based on the preset transmission information, the method further includes: A protocol first end is established based on the preset protocol to perform data transmission with a protocol second end of the target terminal.
5. A method for transmitting log data, characterized in that: Applied to target terminals, including: Receive log data sent by the host computer based on preset transmission information; wherein the log data is collected by the host computer through a log collection tool based on a target instruction; The log data is saved to a target database; wherein the host computer and the target terminal establish a transmission link based on a preset protocol.
6. The method according to claim 5, characterized in that Before receiving the log data sent by the host computer based on the preset transmission information, the method further includes: Connect to a target network; wherein the target network is the same as the network to which the host computer is connected.
7. The method according to claim 5, characterized in that Before receiving the log data sent by the host computer based on the preset transmission information, the method further includes: Installing a file transfer tool and establishing a file transfer server based on the file transfer tool; A second protocol end is established based on the preset protocol of the file transfer server to perform data transmission with the first protocol end of the host computer.
8. A log data transmission system, characterized in that: include: A host computer, used to run a target instruction through a log collection tool to collect log data, and send the log data to a target terminal based on preset transmission information; wherein the log collection tool is a tool generated by the target terminal under the development environment of the target terminal, and the host computer and the target terminal establish a transmission link based on a preset protocol; The target terminal is used to receive the log data based on the preset transmission information and save the log data to a target database.
9. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 4 or claims 5 to 7 is executed.
10. An electronic device comprising a memory and a processor, characterized in that: A computer program is stored in the memory, and the processor is configured to execute the method of any one of claims 1 to 4 or claims 5 to 7 through the computer program.