Server log automatic storage method and device, equipment, storage medium and product

By initializing the automatic saving program and process on the server, collecting and saving the server log data with the target serial port, and automatic archiving, solving the problem of manual preservation of log data in the existing technology, and realizing the stability and integrity of log data. It is easy to timely locate server problems and improve system reliability.

CN119356996AActive Publication Date: 2025-01-24SHANDONG YUNHAI GUOCHUANG CLOUD COMPUTING EQUIP IND INNOVATION CENT CO LTD
View PDF 6 Cites 0 Cited by

Patent Information

Application Number
CN202411191563.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-28
Publication Date
2025-01-24
Estimated Expiration
2044-08-28

AI Technical Summary

Technical Problem

In the prior art, server log data needs to be saved manually, resulting in the inability to automatically save, which may lead to partial loss of log information, failures cannot be located in time, and the system reliability is low.

Method used

By running the first shell script for initialization, initialize the automatic preservation program, start the log in automatic preservation process, and obtain the process of the process to occupy resources and configuration information. Then collect the server log data through the target serial port, record the data as a text file, temporarily store it under the target folder, and save it to the memory, and finally release the process of the process to occupy resources.

Benefits of technology

The automatic saving and automatic archiving of server log data is realized to ensure the stability and integrity of log data, facilitate timely positioning server problems, and improve the reliability of the system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119356996A_ABST
    Figure CN119356996A_ABST
Patent Text Reader

Abstract

The invention provides a server log automatic saving method and device, equipment, a storage medium and a product, and the method comprises the steps: running a first shell script, initializing an automatic saving program, starting a log automatic saving process, and obtaining process occupied resources and configuration information of the log automatic saving process; collecting server log data through the target serial port; recording the server log data as a text file, and temporarily storing the text file in a target folder; archiving and storing the text file into a memory; the release log automatically stores process occupation resources of the process. According to the scheme, the log data of the server can be automatically stored, the server problem can be conveniently and timely positioned, and the reliability of the system is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a method, device, equipment, storage medium and product for automatically saving server logs. Background Art

[0002] Servers are products that require extremely high reliability. Accurately locating server failures is a very important part of server use and maintenance. Server problem locating is usually done by reading log information and determining the error information in the log records.

[0003] In the prior art, after the baseboard management controller (BMC) collects the log information of the server, the log data can be sent to the terminal through the serial port. When the log information needs to be saved, the collected log information needs to be saved on the terminal by manual saving or other methods, and the log information is stored on the terminal device, thereby realizing the recording and saving of the server log.

[0004] Therefore, after the server log information is collected in the prior art, it cannot be automatically saved, resulting in that the server log obtained by the BMC end cannot be stably saved, which may cause partial loss of the server log information, and server failures cannot be discovered and checked in time, and the reliability of the system is low. Summary of the invention

[0005] The present invention provides a server log automatic saving method, device, equipment, storage medium and product, which are used to solve the defect that server log data needs to be manually saved in the prior art, realize the automatic saving of server log data, facilitate timely positioning of server problems, and improve the reliability of the system.

[0006] The present invention provides a server log automatic saving method, comprising: running a first shell script to perform initialization processing, wherein the initialization processing comprises: initializing an automatic saving program and starting a log automatic saving process; obtaining process occupied resources and configuration information of the log automatic saving process; collecting server log data through a target serial port, wherein the target serial port is obtained by opening a local area network serial port function of an intelligent platform management interface protocol and redirecting the serial port information of the system to the serial port of a baseboard management controller; recording the server log data as a text file, and temporarily saving the text file in a target folder; archiving and saving the text file in a memory; and releasing the process occupied resources of the log automatic saving process.

[0007] According to a server log automatic saving method provided by the present invention, after the automatic saving program is initialized and the log automatic saving process is started, the method also includes: creating a log collection thread, a log saving thread and a log archiving thread under the log automatic saving process; initializing the log collection thread, the log saving thread and the log archiving thread; obtaining the thread resources required by the log collection thread, the log saving thread and the log archiving thread, and establishing a mutex lock.

[0008] According to a method for automatically saving server logs provided by the present invention, the server log data is collected through the target serial port, including: starting the log collection thread, obtaining the encoding of the target serial port; reading the data in the serial port device corresponding to the encoding of the target serial port, obtaining the server log data, and temporarily saving the server log data in a string array; calculating the string length of the string array. The server log data is recorded as a text file, and the text file is temporarily saved in the target folder, including: starting the log saving thread, creating a text file in the target folder, and determining the maximum string length that can be saved in the text file; judging whether the string length of the string array exceeds the maximum string length that can be saved in the text file; if it exceeds, creating a new supplementary text file in the target folder; locking the file in the target folder; writing the string array into the file in the target folder, and unlocking the file under the target file after writing is completed. The archiving and saving of the text file into the memory includes: starting the log archiving thread, locking the files under the target file that need to be stored; generating an archive file name according to the number of archive files stored in the memory and the current time; using the archive file name to create an archive file in the memory, and storing the files under the target file into the archive file.

[0009] According to a server log automatic saving method provided by the present invention, after storing the files under the target file into the archive file, the method further includes: recording the address of the archive file and the configuration information.

[0010] According to a method for automatically saving server logs provided by the present invention, before running the first shell script for initialization processing, the method also includes: if remote synchronization of server logs is not required, running the second shell script to create the target folder under the Linux system; otherwise, running the third shell script to create the target folder and the synchronization folder under the Linux system, and mounting the target folder and the synchronization folder; when remote synchronization of server logs is required, archiving and saving the text file in a memory specifically includes: the remote device obtains the text file in the synchronization folder, and archiving and saving the text file in the memory.

[0011] According to a server log automatic saving method provided by the present invention, after the automatic saving program is initialized and the log automatic saving process is started, the method further includes: saving the process identifier of the log automatic saving process and registering the log automatic saving process in the process monitoring of the Linux system.

[0012] The present invention also provides a server log automatic saving device, comprising: an initialization module, used for running a first shell script to perform initialization processing, wherein the initialization processing comprises: initializing an automatic saving program and starting a log automatic saving process; obtaining process occupied resources and configuration information of the log automatic saving process; a log collection module, used for collecting server log data through a target serial port, wherein the target serial port is obtained by opening a local area network serial port function of an intelligent platform management interface protocol and redirecting the system's serial port information to the serial port of a baseboard management controller; a log saving module, used for recording the server log data as a text file and temporarily saving the text file to a target folder; a log archiving module, used for archiving and saving the text file in a memory; and a resource management module, used for releasing the process occupied resources of the log automatic saving process.

[0013] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, any of the above-mentioned server log automatic saving methods is implemented.

[0014] The present invention also provides a non-transitory computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the server log automatic saving method described in any one of the above methods is implemented.

[0015] The present invention also provides a computer program product, including a computer program, wherein when the computer program is executed by a processor, the method for automatically saving a server log as described above is implemented.

[0016] The server log automatic saving method, device, equipment, storage medium and product provided by the present invention are initialized by running a first shell script, and the initialization process includes: initializing the automatic saving program and starting the log automatic saving process; obtaining the process occupied resources and configuration information of the log automatic saving process; collecting server log data through the target serial port, wherein the target serial port is obtained by opening the local area network serial port function of the intelligent platform management interface protocol and redirecting the serial port information of the system to the serial port of the baseboard management controller; recording the server log data as a text file, and temporarily saving the text file to a target folder; archiving and saving the text file in a memory; releasing the process occupied resources of the log automatic saving process. In the scheme of the present invention, the server log data is automatically saved by the BMC, and the saved server log data is automatically archived, so that comprehensive and complete server log data can be obtained and saved, which is convenient for timely positioning of server problems and improves the reliability of the system. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0018] Figure 1 This is one of the flow charts of the server log automatic saving method provided by the present invention.

[0019] Figure 2 This is the second flow chart of the server log automatic saving method provided by the present invention.

[0020] Figure 3 It is a structural schematic diagram of the server log automatic storage device provided by the present invention.

[0021] Figure 4 It is a structural schematic diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION

[0022] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0023] It should be noted that the brief description of terms in this application is only for the convenience of understanding the embodiments described below, and is not intended to limit the embodiments of this application. Unless otherwise specified, these terms should be understood according to their common and usual meanings.

[0024] The terms "first", "second", etc. in the specification and claims of this application and the above drawings are used to distinguish similar or similar objects or entities, and do not necessarily mean to limit a specific order or sequence, unless otherwise indicated. It should be understood that the terms used in this way can be interchangeable under appropriate circumstances, for example, they can be implemented in an order other than those given in the diagrams or descriptions of the embodiments of this application.

[0025] In addition, the terms "including" and "having" and any variations thereof are intended to cover but not exclude inclusion, for example, a product or device comprising a series of components is not necessarily limited to those components explicitly listed, but may include other components not explicitly listed or inherent to these products or devices. The term "module" as used in this application refers to any known or later developed hardware, software, firmware, artificial intelligence, fuzzy logic or combination of hardware and / or software code that can perform the functions associated with the element.

[0026] The term "baseboard management controller (BMC)" used in each embodiment of the present application is a dedicated microcontroller independent of the server operating system and the main processor, which is built into the motherboard of the server, network equipment and other complex electronic systems. BMC is mainly responsible for monitoring and managing the status of the system hardware and providing remote management and control functions. The main functions of BMC include: hardware monitoring, remote management, fault alarm, remote control and intelligent platform management interface (Intelligent platform management interface, IPMI) compatibility. Specifically, the hardware monitoring function refers to monitoring key parameters such as system temperature, voltage, fan speed, power supply status, etc. The remote management function refers to allowing administrators to access and manage devices at any time and any place through the network interface. The fault alarm function means that when a system abnormality is detected, the BMC can send a warning notification to the administrator. The remote control function refers to supporting remote power on and off, restart, operating system reinstallation, firmware update and other operations. The IPMI compatibility function means that the BMC supports the IPMI protocol, which is used to achieve remote monitoring and management of the health status of the system hardware.

[0027] In practice, servers are products that have extremely high reliability requirements. Accurately locating server failures is a very important part of server use and maintenance. Server problem locating is usually done by reading log information and determining the error information in the log records.

[0028] In the prior art, after the BMC collects the log information of the server, the log data can be sent to the terminal through the serial port. When the log information needs to be saved, the collected log information needs to be saved on the terminal through manual saving and other methods, and the log information is stored on the terminal device, thereby realizing the recording and preservation of the server log. This server log preservation method has the following defects: on the one hand, the terminal can only collect real-time logs, and the logs generated when it is not opened cannot be obtained; on the other hand, the files saved by the terminal are easily lost due to reasons such as terminal migration; on the other hand, manual operation is generally required, and the efficiency and accuracy of server log preservation are poor.

[0029] It is understandable that after the server log information is collected in the prior art, it cannot be automatically saved, resulting in the server log obtained by the BMC end cannot be stably saved, which may cause partial loss of the server log information, server failures cannot be discovered and checked in time, and the system reliability is low.

[0030] In response to the above technical problems, the present invention proposes the following technical concept: through an automatic saving program, the collection, preservation and archiving of server log data are realized, thereby ensuring that the server log data can be saved stably and completely. When a server fails, the server problem can be located in time according to the saved server log data, thereby improving the reliability of the system.

[0031] The following specific embodiments are used to describe in detail the technical solution of the present application and how the technical solution of the present application solves the above technical problems. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. Figure 1 and Figure 2 The server log automatic storage method of the present invention is described.

[0032] In practical applications, the execution subject of the server log automatic saving method can be a server log automatic saving device, and there are many ways to implement the server log automatic saving device, for example, it can be implemented by a computer program, such as application software, etc.; or, for example, a chip, etc. It can also be implemented as a medium storing relevant computer programs, such as a USB disk, a cloud disk, etc.; or, it can also be implemented by a physical device integrated or installed with relevant computer programs, such as a server, etc.

[0033] Figure 1 This is one of the flow charts of the method for automatically saving server logs provided by the present invention. Figure 1 As shown, the method includes the following: step 101 to step 105.

[0034] Step 101, run the first shell script to perform initialization processing, the initialization processing includes: initializing the automatic saving program, starting the log automatic saving process; obtaining the process occupied resources and configuration information of the log automatic saving process.

[0035] The automatic log saving process is the process corresponding to the initialization saving program. The process resources occupied by the automatic log saving process refer to various system resources required to run the automatic log saving process, including but not limited to address space, global variables, semaphores, CPU resources, input / output (IO) devices, memory, network resources, etc.

[0036] Among them, the configuration information of the log automatic saving process refers to the limiting information of the operation of the log automatic saving process. As an example, the configuration information of the log automatic saving process includes the execution environment, the identification of the target folder, the number of the target serial port, etc. Among them, the target folder is a folder pre-created under the Linux system for saving server log data to ensure that the collected server log data is correctly saved in the corresponding memory. Among them, the target serial port refers to the serial port from which the server log data needs to be collected. In practice, during the initialization phase, for different BMC platforms, the number of the target serial port is specified or generated. It can be understood that the target serial port can be determined based on the number of the target serial port to ensure that the server log data can be collected through the target serial port later.

[0037] In practice, shell script is a scripting language used to write batch tasks, mainly used to execute command and control system operations in Linux operating systems. Shell scripts can call and execute Linux commands to implement specific functions, such as batch renaming files. In addition, conditional judgment and loop control can also be used in Shell scripts. If statements are used to judge conditions and execute specific Linux commands, and loop control structures are used to repeatedly execute certain Linux commands. Shell scripts can also define variables and functions to expand their functions, simplifying and optimizing the script writing and maintenance process.

[0038] In the present invention, based on the Linux operating system used by the BMC, the server log saving and archiving functions are realized by writing and executing the automatic saving program under the Linux system. Specifically, the program designed by the present invention includes two types: shell script programs and application programs. In this embodiment, the automatic saving program is initialized as an application program, which is used to collect, save and archive server log data. The first shell script is used to initialize the automatic saving program and start the log automatic saving process; by interacting with the Linux system, the process occupied resources and configuration information of the log automatic saving process are obtained.

[0039] Optionally, in one example, after initializing the automatic save program and starting the automatic log save process, it is determined whether the automatic log save process is started normally. If it is not started normally, the first shell script is run again to perform initialization processing until the automatic log save process is started normally, thereby improving the accuracy and reliability of automatic saving of server logs.

[0040] Step 102 : Collect server log data through a target serial port, wherein the target serial port is obtained by opening the LAN serial port function of the intelligent platform management interface protocol and redirecting the serial port information of the system to the serial port of the baseboard management controller.

[0041] In actual applications, BMC is generally equipped with Serial Over Lan (SOL) function. The remote host can open the SOL function through the Intelligent Platform Management Interface (IPMI) protocol to send the server's log information to the BMC. Among them, the IPMI protocol is a complete hardware management specification for servers and other systems (such as storage devices, networks, and communication devices). Through this specification, users use the IPMI protocol to monitor the physical health characteristics of the server, such as temperature, voltage, fan working status, power supply status, etc. SOL is a function in the IPMI protocol that provides remote access to a machine serial port on a local area network. The main goal of SOL is to redirect the data of the local asynchronous serial controller interface to the remote end.

[0042] Specifically, by opening the SOL function of the IPMI protocol, the serial port information of the system is redirected to the serial port of the BMC to obtain the target serial port. Further, after the server log is generated, the server log data is collected through the target serial port.

[0043] Step 103: Record the server log data as a text file, and temporarily save the text file to a target folder.

[0044] Step 104: Archive the text file and save it in the memory.

[0045] Further, after the server log data is collected, the server log data is temporarily saved in the target folder. In this embodiment, the server log data is recorded as a text file and temporarily saved in the target file, so that the server log data can be archived after processing and permanently saved in the memory, which is convenient for subsequent management. It is understandable that the text file in the target folder will be erased after the system is restarted. In order to permanently save the server log data, it is necessary to archive the text file and permanently save the text file in the memory.

[0046] In this embodiment, the memory is not specifically limited. As an example, the memory may be a SPI flash memory of the system. This storage location can realize long-term storage of server log data.

[0047] In actual applications, text files can be archived and saved in batches to the memory. As an example, an archiving period can be set to merge multiple files collected by the target serial port within the archiving period into a log file, and the log file can be archived and saved to the memory. As an example, when the server log data is large, the target folder may include multiple text files. The multiple files in the target folder are merged into a log file, and the log file is archived and saved to the memory.

[0048] Step 105: Release the resources occupied by the process of the automatic log saving process.

[0049] It is understandable that after the text file is archived and saved in the memory, in order to improve the efficiency of the system, the resources occupied by the log automatic saving process can be released.

[0050] In the solution of this embodiment, the server log data is automatically saved by the BMC, and the saved server log data is automatically archived, so that comprehensive and complete server log data can be obtained and saved, which is convenient for timely locating server problems and improving the reliability of the system.

[0051] Combined with the above description, the log automatic saving process needs to realize the functions of collecting, saving and archiving server log data. Therefore, in order to further improve the efficiency of automatic saving of server logs, multiple threads can be created to realize the functions of collecting, saving and archiving server log data. Specifically, in a possible implementation, after the above-mentioned initialization of the automatic saving program and the start of the log automatic saving process, the server log automatic saving method also includes: under the log automatic saving process, creating a log collection thread, a log saving thread and a log archiving thread; initializing the log collection thread, the log saving thread and the log archiving thread; obtaining the thread resources required by the log collection thread, the log saving thread and the log archiving thread, and establishing a mutex lock.

[0052] It is understandable that the log collection thread, log preservation thread and log archiving thread respectively realize the functions of collecting, preserving and archiving server log data. In this embodiment, under the log automatic preservation process, a log collection thread, a log preservation thread and a log archiving thread are created to respectively realize the functions of collecting, preserving and archiving server log data, thereby improving the efficiency of automatic preservation of server logs.

[0053] Specifically, threads within the same process share the address space and resources of the process, such as memory, I / O, CPU, etc. This means that threads can directly access the resources of the process without additional data copying, thereby improving the efficiency of communication and resource sharing. For example, shared memory allows two or more processes to share a given storage area, which can be mapped to the address space of multiple processes. Information written to the shared memory by a process can be read by other processes using the shared memory through simple memory read operations, thus achieving communication between processes.

[0054] In actual applications, in a multi-threaded environment, multiple threads may try to access or modify the same resource (such as variables, files, databases, etc. in memory) at the same time, which may lead to problems such as data inconsistency, dirty reads, data loss, or race conditions. To avoid these problems, mutex locks allow only one thread to access or modify a specific resource at the same time. Specifically, mutex locks are used to protect shared resources, ensuring that only one thread can access the resource at any time. When a thread tries to acquire a mutex lock that is already held by another thread, it will be blocked until the lock is released.

[0055] In this implementation, thread resources required by the log collection thread, log storage thread and log archiving thread are obtained, and a mutex is established to prevent multiple threads from trying to access or modify the same resource at the same time, thereby improving the reliability of automatic storage of server logs.

[0056] Specifically, for the collection, storage and archiving process of server log data, as an example, in one possible implementation, the above step 102 includes: starting a log collection thread to obtain the encoding of the target serial port; reading the data in the serial port device corresponding to the encoding of the target serial port to obtain the server log data, and temporarily saving the server log data in a string array; calculating the string length of the string array.

[0057] The above step 103 includes: starting a log saving thread, creating a text file in a target folder, and determining the maximum string length that can be saved in the text file; judging whether the string length of the string array exceeds the maximum string length that can be saved in the text file; if it exceeds, creating a new supplementary text file in the target folder; locking the file in the target folder; writing the string array into the file in the target folder, and unlocking the file in the target folder after writing is completed.

[0058] The above step 104 includes: starting the log archiving thread, locking the files under the target file; generating an archive file name according to the number of archive files saved in the memory and the current time; creating an archive file in the memory using the archive file name, and storing the files under the target file in the archive file.

[0059] The target serial port encoding uniquely represents the target serial port, and may refer to the file identifier of the serial port device file registered under the Linux system. In practice, the target serial port can be determined based on the encoding of the target serial port, and the data in the serial port device corresponding to the encoding of the target serial port can be read, that is, the data in the target serial port can be read to obtain the server log data. Furthermore, the server log data is temporarily saved in a string array, and the string length of the string data is calculated to facilitate the subsequent storage and archiving of the server log data.

[0060] In actual applications, the maximum string length that can be saved in a text file can be preset, and after starting the log saving thread, the maximum string length that can be saved in a text file can be obtained. Further, according to the string length of the string array and the maximum string length that can be saved in a text file, it is determined whether the string length of the string array exceeds the maximum string length that can be saved in a text file.

[0061] Specifically, if the string length of the string array exceeds the maximum string length that can be saved in the text file, a supplementary text file is added under the target file to ensure the complete preservation of the server log data; the file operation function is used to open the file in the target folder, obtain the file identifiers of the text file and the supplementary text file, and lock the text file and the supplementary text file to prevent other processes from tampering with the text file and the supplementary text file. Write the string array into the text file and the supplementary text file, and unlock the text file and the supplementary text file after writing is completed.

[0062] Correspondingly, if the string length of the string array does not exceed the maximum string length that can be saved in the text file, use the file operation function to open the file in the target folder, obtain the file identifier of the text file, and lock the text file to prevent other processes from tampering with the text file. Write the string array into the text file and unlock the text file after writing is completed.

[0063] Specifically, start the log archiving thread, lock the files under the target file, that is, lock the files to be archived, and prevent the archived files from being tampered with. Further, determine the number of archived files that have been archived in the memory and the number of files to be archived, generate a new archive file name of the same format in order, and supplement the timestamp information according to the current time to generate an archive file name. For example, if the number of archived files that have been archived in the memory is 2, named archive file 1+timestamp 1 and archive file 2+timestamp 2, and the number of files to be archived is 1, then the file to be archived is named archive file 3+timestamp 3 to ensure that the archive file path is unique and will not tamper with other archive files. Further, use the archive file name to create an archive file in the memory, and store the files under the target file in the archive file.

[0064] In this implementation, the server log data is automatically saved by the BMC and the saved server log data is automatically archived, so that comprehensive and complete server log data can be obtained and saved, which is convenient for timely locating server problems and improving system reliability.

[0065] In addition, in a possible implementation manner, after storing the files under the target file into the archive file, the server log automatic saving method further includes: recording the address and configuration information of the archive file.

[0066] In this implementation, after the files under the target file are stored in the archive file, the address and configuration information of the archive file are recorded, so that when a subsequent server failure occurs, the server log information can be obtained in time, the server problem can be located in time, and the reliability of the system is improved.

[0067] In combination with the above description, the target folder is used to temporarily store the server log data collected through the target serial port. Therefore, before running the first shell script for initialization processing, it is necessary to pre-create the target folder under the Linux system to ensure that the collected server log data can be correctly and stably stored in the memory. In addition, the present invention supports the automatic preservation of server log data by the remote terminal. For the scenario where remote synchronization of server logs is not required, as an example, in a possible implementation, before the above step 101, the above server log automatic preservation method also includes: if remote synchronization of server logs is not required, run the second shell script to create a target folder under the Linux system.

[0068] In this implementation, before running the first shell script for initialization processing, running the second shell script to create a target folder can ensure that the server log data can be correctly and stably stored in the memory, thereby improving the reliability of automatic storage of the server log.

[0069] Correspondingly, for a scenario where remote synchronization of server logs is required, as an example, in a possible implementation, Figure 2 This is a second flow chart of the method for automatically saving server logs provided by the present invention. Figure 2 As shown, before the above step 101, the above method for automatically saving server logs further includes step 201.

[0070] Step 201: If remote synchronization of server logs is required, a third shell script is run to create a target folder and a synchronization folder under the Linux system, and mount the target folder and the synchronization folder.

[0071] The above step 104 includes: step 202, the remote device obtains the text file in the synchronization folder, and archives the text file and saves it in the memory.

[0072] In actual applications, the contents stored in the mounted target folder and the synchronization folder are consistent, that is, by storing the text file in the target folder, the text file can be synchronously stored in the synchronization folder.

[0073] Specifically, the remote synchronization function of the Linux system is enabled during the initialization processing phase. On this basis, the server log data is collected through the target serial port; the server log data is recorded as a text file, and the text file is temporarily saved in the target folder, so that the text file is synchronously stored in the synchronization folder; the remote device obtains the text file in the synchronization folder, and archives the text file to the storage device, so that the remote device can save and archive the server log data.

[0074] In this embodiment, when the server log needs to be synchronized remotely, the third shell script is run to create a target folder and a synchronization folder under the Linux system, and the target folder and the synchronization folder are mounted. After recording the server log data as a text file and temporarily saving the text file in the target folder, the remote device obtains the text file in the synchronization folder and archives the text file to the memory. The automatic saving of the server log of the remote device is realized, and the convenience and diversity of the automatic saving of the server log are realized.

[0075] In practical applications, in order to further improve the reliability of automatic log saving of the server, it is possible to monitor in real time whether the automatic log saving process is executed normally. As an example, in a possible implementation, after the automatic log saving process is initialized and started, the automatic log saving method of the server further includes: saving the process identifier of the automatic log saving process and registering the automatic log saving process in the process monitoring of the Linux system.

[0076] In this implementation, after the automatic save program is initialized and the automatic log save process is started, the process identifier of the automatic log save process is saved, and the automatic log save process is registered in the process monitoring of the Linux system to achieve real-time monitoring of the automatic log save process, ensure the normal execution of the automatic log save process, and improve the reliability of automatic log saving of the server.

[0077] In addition, in a possible implementation, before the above step 103, the above method for automatically saving server logs further includes: filtering the server log data according to business needs to obtain the filtered server log data. The above step 103 specifically includes: recording the filtered server log data as a text file, and temporarily saving the text file to a target folder.

[0078] In the server log automatic saving method provided in this embodiment, initialization processing is performed by running the first shell script, and the initialization processing includes: initializing the automatic saving program and starting the log automatic saving process; obtaining the process occupied resources and configuration information of the log automatic saving process; collecting server log data through the target serial port, wherein the target serial port is obtained by opening the LAN serial port function of the intelligent platform management interface protocol and redirecting the system's serial port information to the serial port of the baseboard management controller; recording the server log data as a text file, and temporarily saving the text file to the target folder; archiving and saving the text file in the memory; releasing the process occupied resources of the log automatic saving process. In the scheme of this embodiment, the server log data is automatically saved by BMC, and the saved server log data is automatically archived, so that comprehensive and complete server log data can be obtained and saved, which is convenient for timely positioning of server problems and improves the reliability of the system.

[0079] The server log automatic saving device provided by the present invention is described below. The server log automatic saving device described below and the server log automatic saving method described above can be referred to each other.

[0080] Figure 3 Schematic diagram of the structure of the server log automatic storage device provided by the present invention. Figure 3 As shown, the server log automatic storage device includes: an initialization module 31, a log collection module 32, a log storage module 33, a log archiving module 34 and a resource management module 35.

[0081] The initialization module 31 is used to run the first shell script to perform initialization processing, and the initialization processing includes: initializing the automatic saving program, starting the log automatic saving process; and obtaining the process occupied resources and configuration information of the log automatic saving process.

[0082] The automatic log saving process is the process corresponding to the initialization saving program. The process resources occupied by the automatic log saving process refer to various system resources required to run the automatic log saving process, including but not limited to address space, global variables, semaphores, CPU resources, input / output (IO) devices, memory, network resources, etc.

[0083] Among them, the configuration information of the log automatic saving process refers to the limiting information of the operation of the log automatic saving process. As an example, the configuration information of the log automatic saving process includes the execution environment, the identification of the target folder, the number of the target serial port, etc. Among them, the target folder is a folder pre-created under the Linux system for saving server log data to ensure that the collected server log data is correctly saved in the corresponding memory. Among them, the target serial port refers to the serial port from which the server log data needs to be collected. In practice, during the initialization phase, for different BMC platforms, the number of the target serial port is specified or generated. It can be understood that the target serial port can be determined based on the number of the target serial port to ensure that the server log data can be collected through the target serial port later.

[0084] In practice, shell script is a scripting language used to write batch tasks, mainly used to execute command and control system operations in Linux operating systems. Shell scripts can call and execute Linux commands to implement specific functions, such as batch renaming files. In addition, conditional judgment and loop control can also be used in Shell scripts. If statements are used to judge conditions and execute specific Linux commands, and loop control structures are used to repeatedly execute certain Linux commands. Shell scripts can also define variables and functions to expand their functions, simplifying and optimizing the script writing and maintenance process.

[0085] In the present invention, based on the Linux operating system used by the BMC, the server log saving and archiving functions are realized by writing and executing the automatic saving program under the Linux system. Specifically, the program designed by the present invention includes two types: shell script programs and application programs. In this embodiment, the automatic saving program is initialized as an application program, which is used to collect, save and archive server log data. The first shell script is used to initialize the automatic saving program and start the log automatic saving process; by interacting with the Linux system, the process occupied resources and configuration information of the log automatic saving process are obtained.

[0086] Optionally, in one example, after initializing the automatic save program and starting the automatic log save process, it is determined whether the automatic log save process is started normally. If it is not started normally, the first shell script is run again to perform initialization processing until the automatic log save process is started normally, thereby improving the accuracy and reliability of automatic saving of server logs.

[0087] The log collection module 32 is used to collect server log data through the target serial port, wherein the target serial port is obtained by opening the LAN serial port function of the intelligent platform management interface protocol and redirecting the system serial port information to the serial port of the baseboard management controller.

[0088] In actual applications, BMC is generally equipped with Serial Over Lan (SOL) function. The remote host can open the SOL function through the Intelligent Platform Management Interface (IPMI) protocol to send the server's log information to the BMC. Among them, the IPMI protocol is a complete hardware management specification for servers and other systems (such as storage devices, networks, and communication devices). Through this specification, users use the IPMI protocol to monitor the physical health characteristics of the server, such as temperature, voltage, fan working status, power supply status, etc. SOL is a function in the IPMI protocol that provides remote access to a machine serial port on a local area network. The main goal of SOL is to redirect the data of the local asynchronous serial controller interface to the remote end.

[0089] Specifically, by opening the SOL function of the IPMI protocol, the serial port information of the system is redirected to the serial port of the BMC to obtain the target serial port. Further, after the server log is generated, the log collection module 32 collects the server log data through the target serial port.

[0090] The log saving module 33 is used to record the server log data as a text file and temporarily save the text file to a target folder.

[0091] The log archiving module 34 is used to archive text files and save them in the memory.

[0092] Further, after the server log data is collected, the log storage module 33 temporarily stores the server log data in the target folder. In the present embodiment, the server log data is recorded as a text file and temporarily stored in the target file, so that the server log data can be processed and archived, and permanently stored in the memory, which is convenient for subsequent management. It is understandable that the text file in the target folder will be erased after the system is restarted. In order to permanently store the server log data, the text file needs to be archived, and the log archiving module 34 permanently stores the text file in the memory.

[0093] In this embodiment, the memory is not specifically limited. As an example, the memory may be a SPI flash memory of the system. This storage location can realize long-term storage of server log data.

[0094] In actual applications, text files can be archived and saved in batches to the memory. As an example, an archiving period can be set to merge multiple files collected by the target serial port within the archiving period into a log file, and the log file can be archived and saved to the memory. As an example, when the server log data is large, the target folder may include multiple text files. The multiple files in the target folder are merged into a log file, and the log file is archived and saved to the memory.

[0095] The resource management module 35 is used to release the resources occupied by the log automatic saving process.

[0096] It is understandable that after the text file is archived and saved in the memory, in order to improve the efficiency of the system, the resource management module 35 can release the resources occupied by the process of the automatic log saving process.

[0097] In the solution of this embodiment, the server log data is automatically saved by the BMC, and the saved server log data is automatically archived, so that comprehensive and complete server log data can be obtained and saved, which is convenient for timely locating server problems and improving the reliability of the system.

[0098] Combined with the above description, the log automatic saving process needs to realize the collection, preservation and archiving functions of the server log data. Therefore, in order to further improve the efficiency of the automatic saving of the server log, multiple threads can be created to realize the collection, preservation and archiving functions of the server log data. Specifically, in a possible implementation, the above initialization module 31 is also used to: create a log collection thread, a log preservation thread and a log archiving thread under the log automatic saving process; initialize the log collection thread, the log preservation thread and the log archiving thread; obtain the thread resources required by the log collection thread, the log preservation thread and the log archiving thread, and establish a mutex lock.

[0099] It is understandable that the log collection thread, log preservation thread and log archiving thread respectively realize the collection, preservation and archiving functions of the server log data. In the present embodiment, the initialization module 31 creates the log collection thread, log preservation thread and log archiving thread under the log automatic preservation process, respectively realizing the collection, preservation and archiving functions of the server log data, thereby improving the efficiency of the automatic preservation of the server log.

[0100] Specifically, threads within the same process share the address space and resources of the process, such as memory, I / O, CPU, etc. This means that threads can directly access the resources of the process without additional data copying, thereby improving the efficiency of communication and resource sharing. For example, shared memory allows two or more processes to share a given storage area, which can be mapped to the address space of multiple processes. Information written to the shared memory by a process can be read by other processes using the shared memory through simple memory read operations, thus achieving communication between processes.

[0101] In actual applications, in a multi-threaded environment, multiple threads may try to access or modify the same resource (such as variables, files, databases, etc. in memory) at the same time, which may lead to problems such as data inconsistency, dirty reads, data loss, or race conditions. To avoid these problems, mutex locks allow only one thread to access or modify a specific resource at the same time. Specifically, mutex locks are used to protect shared resources, ensuring that only one thread can access the resource at any time. When a thread tries to acquire a mutex lock that is already held by another thread, it will be blocked until the lock is released.

[0102] In this implementation, thread resources required by the log collection thread, log storage thread and log archiving thread are obtained, and a mutex is established to prevent multiple threads from trying to access or modify the same resource at the same time, thereby improving the reliability of automatic storage of server logs.

[0103] Specifically, for the collection, storage and archiving process of server log data, as an example, in a possible implementation, the above-mentioned log collection module 32 is specifically used to: start the log collection thread, obtain the encoding of the target serial port; read the data in the serial port device corresponding to the encoding of the target serial port, obtain the server log data, and temporarily save the server log data in a string array; calculate the string length of the string array.

[0104] The above-mentioned log saving module 33 is specifically used for: starting the log saving thread, creating a text file in the target folder, and determining the maximum string length that can be saved in the text file; judging whether the string length of the string array exceeds the maximum string length that can be saved in the text file; if it exceeds, creating a new supplementary text file in the target folder; locking the file in the target folder; writing the string array into the file in the target folder, and unlocking the file under the target folder after writing is completed.

[0105] The log archiving module 34 is specifically used to: start the log archiving thread, lock the files under the target file; generate an archive file name according to the number of archive files saved in the memory and the current time; use the archive file name to create an archive file in the memory, and store the files under the target file in the archive file.

[0106] The target serial port encoding uniquely represents the target serial port, and may refer to the file identifier of the serial port device file registered under the Linux system. In practice, the target serial port can be determined based on the encoding of the target serial port, and the data in the serial port device corresponding to the encoding of the target serial port can be read, that is, the data in the target serial port can be read to obtain the server log data. Furthermore, the server log data is temporarily saved in a string array, and the string length of the string data is calculated to facilitate the subsequent storage and archiving of the server log data.

[0107] In actual applications, the maximum string length that can be saved in a text file can be preset, and after starting the log saving thread, the maximum string length that can be saved in a text file can be obtained. Further, according to the string length of the string array and the maximum string length that can be saved in a text file, it is determined whether the string length of the string array exceeds the maximum string length that can be saved in a text file.

[0108] Specifically, if the string length of the string array exceeds the maximum string length that can be saved in the text file, a supplementary text file is added under the target file to ensure the complete preservation of the server log data; the file operation function is used to open the file in the target folder, obtain the file identifiers of the text file and the supplementary text file, and lock the text file and the supplementary text file to prevent other processes from tampering with the text file and the supplementary text file. Write the string array into the text file and the supplementary text file, and unlock the text file and the supplementary text file after writing is completed.

[0109] Correspondingly, if the string length of the string array does not exceed the maximum string length that can be saved in the text file, use the file operation function to open the file in the target folder, obtain the file identifier of the text file, and lock the text file to prevent other processes from tampering with the text file. Write the string array into the text file and unlock the text file after writing is completed.

[0110] Specifically, start the log archiving thread, lock the files under the target file, that is, lock the files to be archived, and prevent the archived files from being tampered with. Further, determine the number of archived files that have been archived in the memory and the number of files to be archived, generate a new archive file name of the same format in order, and supplement the timestamp information according to the current time to generate an archive file name. For example, if the number of archived files that have been archived in the memory is 2, named archive file 1+timestamp 1 and archive file 2+timestamp 2, and the number of files to be archived is 1, then the file to be archived is named archive file 3+timestamp 3 to ensure that the archive file path is unique and will not tamper with other archive files. Further, use the archive file name to create an archive file in the memory, and store the files under the target file in the archive file.

[0111] In this implementation, the server log data is automatically saved by the BMC and the saved server log data is automatically archived, so that comprehensive and complete server log data can be obtained and saved, which is convenient for timely locating server problems and improving system reliability.

[0112] In addition, in a possible implementation manner, the above-mentioned server log automatic storage device further includes: a recording module, which is used to record the address and configuration information of the archived file.

[0113] In this implementation, after the files under the target file are stored in the archive file, the address and configuration information of the archive file are recorded, so that when a subsequent server failure occurs, the server log information can be obtained in time, the server problem can be located in time, and the reliability of the system is improved.

[0114] In combination with the above description, the target folder is used to temporarily store the server log data collected through the target serial port. Therefore, before running the first shell script for initialization processing, it is necessary to pre-create the target folder under the Linux system to ensure that the collected server log data can be correctly and stably stored in the memory. In addition, the present invention supports the automatic preservation of server log data by the remote terminal. For the scenario where remote synchronization of server logs is not required, as an example, in a possible implementation, the above-mentioned server log automatic preservation device also includes: a creation module, which is used to run the second shell script to create a target folder under the Linux system if remote synchronization of server logs is not required.

[0115] In this implementation, before running the first shell script for initialization processing, running the second shell script to create a target folder can ensure that the server log data can be correctly and stably stored in the memory, thereby improving the reliability of automatic storage of the server log.

[0116] Correspondingly, for the scenario where remote synchronization of server logs is required, as an example, in one possible implementation, the above-mentioned creation module is also used for: if remote synchronization of server logs is required, run the third shell script, create a target folder and a synchronization folder under the Linux system, and mount the target folder and the synchronization folder.

[0117] The log archiving module 34 is specifically used for: the remote device obtains the text file in the synchronization folder, and archives the text file and saves it in the memory.

[0118] In actual applications, the contents stored in the mounted target folder and the synchronization folder are consistent, that is, by storing the text file in the target folder, the text file can be synchronously stored in the synchronization folder.

[0119] Specifically, the remote synchronization function of the Linux system is enabled during the initialization processing phase. On this basis, the server log data is collected through the target serial port; the server log data is recorded as a text file, and the text file is temporarily saved in the target folder, so that the text file is synchronously stored in the synchronization folder; the remote device obtains the text file in the synchronization folder, and archives the text file to the storage device, so that the remote device can save and archive the server log data.

[0120] In this embodiment, when the server log needs to be synchronized remotely, the third shell script is run to create a target folder and a synchronization folder under the Linux system, and the target folder and the synchronization folder are mounted. After recording the server log data as a text file and temporarily saving the text file in the target folder, the remote device obtains the text file in the synchronization folder and archives the text file to the memory. The automatic saving of the server log of the remote device is realized, and the convenience and diversity of the automatic saving of the server log are realized.

[0121] In practical applications, in order to further improve the reliability of automatic log saving of the server, it is possible to monitor in real time whether the automatic log saving process is executed normally. As an example, in a possible implementation, the automatic log saving device of the server also includes: a process monitoring module, which is used to save the process identifier of the automatic log saving process and register the automatic log saving process in the process monitoring of the Linux system.

[0122] In this implementation, after the automatic save program is initialized and the automatic log save process is started, the process identifier of the automatic log save process is saved, and the automatic log save process is registered in the process monitoring of the Linux system to achieve real-time monitoring of the automatic log save process, ensure the normal execution of the automatic log save process, and improve the reliability of automatic log saving of the server.

[0123] In addition, in a possible implementation, the server log automatic storage device further includes: a screening module, which is used to screen the server log data according to business needs and obtain the screened server log data. The log storage module 33 is specifically used to record the screened server log data as a text file and temporarily save the text file to a target folder.

[0124] In the server log automatic saving device provided by the present invention, the initialization module performs initialization processing by running the first shell script, and the initialization processing includes: initializing the automatic saving program, starting the log automatic saving process; obtaining the process occupied resources and configuration information of the log automatic saving process. The log collection module collects the server log data through the target serial port, wherein the target serial port is obtained by opening the LAN serial port function of the intelligent platform management interface protocol and redirecting the serial port information of the system to the serial port of the baseboard management controller. The log saving module records the server log data as a text file and temporarily saves the text file to the target folder. The log archiving module archives and saves the text file in the memory; the resource management module releases the process occupied resources of the log automatic saving process. In the scheme of the present invention, the server log data is automatically saved by the BMC, and the saved server log data is automatically archived, so that comprehensive and complete server log data can be obtained and saved, which is convenient for timely positioning of server problems and improves the reliability of the system.

[0125] Figure 4 is a schematic diagram of the structure of the electronic device provided by the present invention, such as Figure 4 As shown, the electronic device may include: a processor 410, a communication interface 420, a memory 430 and a communication bus 440, wherein the processor 410, the communication interface 420 and the memory 430 complete mutual communication through the communication bus 440. The processor 410 may call the logic instructions in the memory 430 to execute the server log automatic saving method, the method comprising: running the first shell script for initialization processing, the initialization processing comprising: initializing the automatic saving program, starting the log automatic saving process; obtaining the process occupied resources and configuration information of the log automatic saving process; collecting the server log data through the target serial port, wherein the target serial port is obtained by opening the LAN serial port function of the intelligent platform management interface protocol and redirecting the system serial port information to the serial port of the baseboard management controller; recording the server log data as a text file, and temporarily saving the text file to the target folder; archiving and saving the text file to the memory; releasing the process occupied resources of the log automatic saving process.

[0126] In addition, the logic instructions in the above-mentioned memory 430 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc. Various media that can store program codes.

[0127] On the other hand, the present invention also provides a computer program product, which includes a computer program. The computer program can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the server log automatic saving method provided by the above methods, and the method includes: running a first shell script to perform initialization processing, and the initialization processing includes: initializing the automatic saving program and starting the log automatic saving process; obtaining the process occupied resources and configuration information of the log automatic saving process; collecting server log data through the target serial port, wherein the target serial port is obtained by opening the local area network serial port function of the intelligent platform management interface protocol and redirecting the system's serial port information to the serial port of the baseboard management controller; recording the server log data as a text file, and temporarily saving the text file to a target folder; archiving the text file and saving it in a memory; releasing the process occupied resources of the log automatic saving process.

[0128] On the other hand, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, is implemented to execute the server log automatic saving method provided by the above-mentioned methods, the method comprising: running a first shell script to perform initialization processing, the initialization processing comprising: initializing the automatic saving program and starting the log automatic saving process; obtaining the process occupied resources and configuration information of the log automatic saving process; collecting server log data through a target serial port, wherein the target serial port is obtained by opening the LAN serial port function of the intelligent platform management interface protocol and redirecting the system's serial port information to the serial port of the baseboard management controller; recording the server log data as a text file, and temporarily saving the text file to a target folder; archiving and saving the text file in a memory; and releasing the process occupied resources of the log automatic saving process.

[0129] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.

[0130] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, can also be implemented by hardware. Based on this understanding, the above technical solution is essentially 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 ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.

[0131] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A method for automatically saving server logs, characterized in that: include: Running the first shell script to perform initialization processing, the initialization processing includes: initializing the automatic saving program, starting the log automatic saving process; obtaining the process occupied resources and configuration information of the log automatic saving process; Collect server log data through the target serial port, wherein the target serial port is obtained by opening the LAN serial port function of the intelligent platform management interface protocol and redirecting the serial port information of the system to the serial port of the baseboard management controller; Record the server log data as a text file, and temporarily save the text file to a target folder; Archiving and saving the text file in a memory; Release the resources occupied by the process of the automatic log saving process.

2. The server log automatic storage method according to claim 1, characterized in that: After the automatic saving program is initialized and the log automatic saving process is started, the method further includes: Under the log automatic saving process, a log collection thread, a log saving thread and a log archiving thread are created; Initialize the log collection thread, the log storage thread and the log archiving thread; The thread resources required by the log collection thread, the log storage thread and the log archiving thread are acquired, and a mutual exclusion lock is established.

3. The server log automatic storage method according to claim 2, characterized in that: The collecting of server log data through the target serial port includes: Start the log collection thread, obtain the encoding of the target serial port; read the data in the serial port device corresponding to the encoding of the target serial port, obtain the server log data, and temporarily save the server log data in a string array; calculate the string length of the string array; The step of recording the server log data as a text file and temporarily saving the text file to a target folder includes: Start the log saving thread, create a text file in the target folder, and determine the maximum string length that can be saved in the text file; determine whether the string length of the string array exceeds the maximum string length that can be saved in the text file; if it exceeds, create a new supplementary text file in the target folder; lock the file in the target folder; write the string array into the file in the target folder, and unlock the file under the target folder after writing is completed; The step of archiving the text file and storing it in a memory comprises: Start the log archiving thread, lock the files under the target file; generate an archive file name according to the number of archive files saved in the memory and the current time; create an archive file in the memory using the archive file name, and store the files under the target file in the archive file.

4. The method for automatically saving server logs according to claim 3, characterized in that: After storing the files under the target file into the archive file, the method further includes: The address of the archive file and the configuration information are recorded.

5. The method for automatically saving server logs according to claim 1, characterized in that: Before running the first shell script to perform initialization processing, the method further includes: If the server log does not need to be synchronized remotely, the second shell script is run to create the target folder in the Linux system; otherwise, the third shell script is run to create the target folder and the synchronization folder in the Linux system, and mount the target folder and the synchronization folder; When the server log needs to be remotely synchronized, archiving the text file to the memory specifically includes: the remote device obtains the text file in the synchronization folder, and archiving the text file to the memory.

6. The method for automatically saving server logs according to any one of claims 1 to 5, characterized in that: After the automatic saving program is initialized and the log automatic saving process is started, the method further includes: The process identifier of the log automatic saving process is saved, and the log automatic saving process is registered in the process monitoring of the Linux system.

7. A server log automatic storage device, characterized in that: include: The initialization module is used to run the first shell script to perform initialization processing, wherein the initialization processing includes: initializing the automatic saving program, starting the log automatic saving process; obtaining the process occupied resources and configuration information of the log automatic saving process; A log collection module, used to collect server log data through a target serial port, wherein the target serial port is obtained by opening the LAN serial port function of the intelligent platform management interface protocol and redirecting the serial port information of the system to the serial port of the baseboard management controller; A log saving module, used to record the server log data as a text file and temporarily save the text file to a target folder; A log archiving module, used for archiving the text file and saving it in a memory; The resource management module is used to release the resources occupied by the process of the automatic log saving process.

8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the server log automatic saving method according to any one of claims 1 to 6 is implemented.

9. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the server log automatic storage method as claimed in any one of claims 1 to 6 is implemented.

10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the server log automatic storage method as claimed in any one of claims 1 to 6 is implemented.

Citation Information

Patent Citations

  • Log collecting method and device

    CN108153654A

  • Multi-process browser process log collection method, device, and mobile terminal

    CN108255674A

  • Serial port information monitoring method and system based on BMC, terminal and storage medium

    CN116204383A

  • Server host log collection method, device and equipment and medium

    CN117331782A

  • Log collection method of vehicle-mounted system and related product

    CN118535442A