Log processing method and device, electronic equipment and storage medium
By establishing a shared memory target storage space between the BMC and the server host, and using the PCIe bus to transmit log files, the reliability problem of the UDP protocol is solved, achieving efficient and reliable log transmission and reducing costs.
Patent Information
- Application Number
- CN202310101062.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-02-10
- Publication Date
- 2026-03-03
- Estimated Expiration
- 2043-02-10
AI Technical Summary
In existing technologies, using the UDP protocol to transmit logs has reliability issues, leading to log loss, affecting system fault analysis, and is also costly.
By establishing a shared memory target storage space between the baseboard management controller (BMC) and the server host, log files are transmitted using the PCIe bus, interrupt commands from the server host are received, and log files are read, ensuring reliability and cost-effectiveness.
It enables efficient and reliable transmission of log files on the BMC side, reduces reliance on other devices, lowers costs, and improves the reliability of log transmission.
Smart Images

Figure CN116185978B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of server technology, and in particular to a log processing method, apparatus, electronic device, and storage medium. Background Technology
[0002] Business system logs play a crucial role in troubleshooting code. Centralized logging provides a comprehensive view of all log data. In contrast, viewing each log file individually is extremely time-consuming. Therefore, forwarding local log messages to a remote log analysis server has become the standard for logging solutions.
[0003] Currently, the User Datagram Protocol (UDP) is commonly used to send logs to log servers. However, UDP-based implementations can lead to reliability issues. As systems become increasingly complex, collecting and monitoring all relevant data generated by applications becomes crucial, and lost logs can make subsequent system error analysis difficult. Summary of the Invention
[0004] This invention provides a log processing method, apparatus, electronic device, and storage medium to overcome the aforementioned deficiencies in the prior art, enabling the system logs to be sent to the BMC side via the target storage space of shared memory without occupying other devices, reducing costs, and with simple software implementation and high reliability.
[0005] This invention provides a log processing method applied to a baseboard management controller (BMC), comprising:
[0006] Receive the first interrupt command sent by the server host;
[0007] Receive the log file sent by the server host via the target storage space, read the log file from the target storage space based on the first interrupt instruction, determine the file to be read, and write the read file into the target file;
[0008] The target storage space is the shared memory obtained by mapping the storage space of the BMC to the memory of the server host.
[0009] According to a log processing method provided by the present invention, the method of receiving log files sent by the receiving server host via a target storage space includes:
[0010] Determine the spatial state of the target storage space;
[0011] When the space is in a busy state, log files sent by the server host via the target storage space are received based on the target communication standard.
[0012] According to a log processing method provided by the present invention, after storing the read file into the target file, the method further includes:
[0013] Clear the target storage space and set the space status to ready.
[0014] According to a log processing method provided by the present invention, when the space status is busy, receiving log files sent by a server host via a target storage space based on a target communication standard includes:
[0015] When the space is in a busy state, it is determined that both the packet header data and the check value are correct, and a correct check result is obtained;
[0016] Based on the correct results of the inspection, log files sent by the target communication standard server host via the target storage space are received.
[0017] A log processing method provided by the present invention further includes:
[0018] If the header data or checksum is determined to be an error, an error check result is obtained. Based on the error check result, a log alarm is activated and the space status is set to the corresponding error code.
[0019] According to a log processing method provided by the present invention, before receiving the log file sent by the server host via the target storage space, the method further includes:
[0020] Create shared memory between the BMC and the server host, and determine the target storage space for the shared memory.
[0021] Clear the target storage space and set the space status of the target storage space to the open state;
[0022] In the event of an interruption while the server is in sleep mode, the space state is determined to transition to a working state, and the working state is set to a ready state.
[0023] This invention also provides a log processing method applied to a server host, comprising:
[0024] Collect system log data, write the log data into a log file, and store the log file in the target storage space;
[0025] The log file is sent to the Baseboard Management Controller (BMC) via the target storage space;
[0026] Send a first interrupt instruction to the BMC, the first interrupt instruction being used to read the target storage space to determine the file to be read;
[0027] The target storage space is the shared memory obtained by mapping the storage space of the BMC to the memory of the server host.
[0028] According to a log processing method provided by the present invention, after storing the log file in the target storage space, the method further includes:
[0029] Set the target storage space to a busy state;
[0030] Sending the log file to the Baseboard Management Controller (BMC) via the target storage space includes:
[0031] When the space is in a busy state, the log file is sent to the Baseboard Management Controller (BMC) via the target storage space.
[0032] According to a log processing method provided by the present invention, the step of collecting log data from a system and writing the log data into a log file includes:
[0033] Determine the value of the log data;
[0034] If the value is greater than a preset threshold, first data and second data are determined, where the first data is log data whose value is less than the preset threshold and the second data is log data whose value is greater than the preset threshold.
[0035] Modify the filename of the log file and create a new backup file. Write the first data into the log file and the second data into the backup file.
[0036] A log processing method provided by the present invention further includes:
[0037] The modification information of the log files is determined by monitoring the log files using the target execution tool.
[0038] If the modification information indicates that the file name has been changed, the first log publishing thread is activated; if the modification information indicates that the log file has been deleted, the second log publishing thread is activated.
[0039] According to a log processing method provided by the present invention, before collecting the log data of the system and writing the log data into a log file, the method further includes:
[0040] The basic input / output system stage and the output system BIOS stage of the server host are initialized.
[0041] The present invention also provides a log processing apparatus, comprising:
[0042] The first module is used to receive the first interrupt command sent by the server host;
[0043] The second module is used to receive the log file sent by the server host via the target storage space, read the log file from the target storage space based on the first interrupt instruction, determine the file to be read, and write the read file into the target file;
[0044] The target storage space is the shared memory obtained by mapping the storage space of the BMC to the memory of the server host.
[0045] The present invention also provides a log processing apparatus, comprising:
[0046] The third module is used to collect system log data, write the log data into a log file, and store the log file in the target storage space.
[0047] The fourth module is used to send the log file to the baseboard management controller (BMC) via the target storage space;
[0048] The fifth module is used to send a first interrupt command to the BMC, the first interrupt command being used to read the target storage space to determine the file to be read;
[0049] The target storage space is the shared memory obtained by mapping the storage space of the BMC to the memory of the server host.
[0050] The present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the log processing method described above.
[0051] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the log processing method as described above.
[0052] The present invention also provides a computer program product, including a computer program that, when executed by a processor, implements the log processing method described above.
[0053] The log processing method, apparatus, electronic device, and storage medium provided by this invention receive a first interrupt command sent by the server host at the BMC (Browser Control Center), then receive a log file sent by the server host via a target storage space, and read the log file from the target storage space based on the first interrupt command, determine the file to be read, and write the read file into the target file. This invention sends system logs obtained by the server host to the BMC side via a target storage space in shared memory, without occupying other equipment, reducing costs. Furthermore, it is simpler to implement than software-based log transmission using datagram protocols and offers higher reliability. Attached Figure Description
[0054] To more clearly illustrate the technical solutions in this invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0055] Figure 1 This is one of the flowcharts of the log processing method provided by the present invention;
[0056] Figure 2 This is the second flowchart of the log processing method provided by the present invention;
[0057] Figure 3 This is the third flowchart of the log processing method provided by the present invention;
[0058] Figure 4 This is the fourth flowchart of the log processing method provided by the present invention;
[0059] Figure 5 This is the fifth flowchart of the log processing method provided by the present invention;
[0060] Figure 6 This is the sixth flowchart of the log processing method provided by the present invention;
[0061] Figure 7 This is the seventh flowchart of the log processing method provided by the present invention;
[0062] Figure 8 This is the eighth flowchart of the log processing method provided by the present invention;
[0063] Figure 9 This is the ninth flowchart of the log processing method provided by the present invention;
[0064] Figure 10 This is the tenth flowchart of the log processing method provided by the present invention;
[0065] Figure 11 This is the eleventh flowchart of the log processing method provided by the present invention;
[0066] Figure 12 This is a schematic diagram of the two-end interaction of the log processing method provided by the present invention;
[0067] Figure 13 This is one of the structural schematic diagrams of the log processing device provided by the present invention;
[0068] Figure 14 This is the second schematic diagram of the log processing device provided by the present invention;
[0069] Figure 15 This is a schematic diagram of the structure of the electronic device provided by the present invention. Detailed Implementation
[0070] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.
[0071] The following describes in detail each step of the present invention by executing the log processing method provided by the present invention on a computer.
[0072] Reference Figure 1 The log processing method provided by this invention is applied to a baseboard management controller (BMC) and includes, but is not limited to, the following steps:
[0073] Step 110: Receive the first interrupt command sent by the server host;
[0074] Step 120: Receive the log file sent by the server host via the target storage space, read the log file from the target storage space based on the first interrupt instruction, determine the file to be read, and write the read file into the target file;
[0075] The target storage space is the shared memory obtained by mapping the storage space of the BMC to the memory of the server host.
[0076] First, it should be noted that the Baseboard Management Controller (BMC) in this embodiment of the invention can perform firmware upgrades, check the machine's equipment, and perform other operations even when the machine is not powered on. A PCIe path exists between the BMC and the server host. In this embodiment, PCIe (Peripheral Component Interconnect Express) is a high-speed serial computer expansion bus standard.
[0077] In step 110 above, the first interrupt command sent by the server host is received.
[0078] In step 120 above, after receiving the first interrupt instruction, the log file sent by the server host (HOST) via the target storage space is received. The target storage space can be the BAR (Base Address Register). It should be noted that the BAR space refers to the space on the PCIe bus where a portion of the BMC's memory is mapped into the HOST's memory. Data written to this space at both ends of the PCIe network can be seen at the other end. The BAR space is shared memory obtained by mapping the BMC's storage space into the server host's memory.
[0079] Understandably, the log data generated by the system can be collected into a log file through the log collection process, which can be recorded as the first file. Then, the log file is divided into packets and placed into the BAR space, that is, the log file is sent to the BMC end through the PCIe bus.
[0080] It should be noted that data transfer between the HOST and BMC is based on PCIe, that is, log files are transferred from the host to the BMC via PCIe.
[0081] It should be noted that the first interrupt instruction in this embodiment is the instruction sent by the server host to the BMC to interrupt the reception of log files. The BMC reads the log file from the BAR according to the first interrupt instruction and writes the log file to another file, which can be referred to as the second file.
[0082] The log processing method provided by this invention involves receiving a first interrupt command sent by the server host at the BMC (Browser Control Center), then receiving the log file sent by the server host via a target storage space, and reading the log file from the target storage space based on the first interrupt command, determining the file to be read, and writing the read file into the target file. This invention sends the system logs obtained by the server host to the BMC side via the target storage space in shared memory, without occupying other devices, reducing costs. Furthermore, it is simpler to implement than software-based log transmission using datagram protocols and offers higher reliability.
[0083] In some embodiments, the log file received by the receiving server host via the target storage space includes:
[0084] Determine the spatial state of the target storage space;
[0085] When the space is in a busy state, log files sent by the server host via the target storage space are received based on the target communication standard.
[0086] It is understood that this embodiment describes the specific process of receiving log files sent by the server host via the BAR space.
[0087] First, determine the spatial state of the BAR. The spatial state of the BAR includes OFF, ON, WORK, BUSY, and READY, which correspond to the states of being closed, open, working, busy, and ready, respectively.
[0088] When the space is busy, log files sent by the server host through the target storage space are received based on the target communication standard, PCIe.
[0089] In some embodiments, after storing the read file into the target file, the method further includes:
[0090] Clear the target storage space and set the space status to ready.
[0091] Understandably, after the log files in the BAR have been sent and read by the BMC, the storage space of the BAR can be cleared to facilitate the subsequent storage of log files, and the space status can be set to the ready state to continue sending log files.
[0092] In some embodiments, when the space status is busy, receiving log files sent by the server host via the target storage space based on the target communication standard includes:
[0093] When the space is in a busy state, it is determined that both the packet header data and the check value are correct, and a correct check result is obtained;
[0094] Based on the correct results of the inspection, log files sent by the target communication standard server host via the target storage space are received.
[0095] In some embodiments, it also includes:
[0096] If the header data or checksum is determined to be an error, an error check result is obtained. Based on the error check result, a log alarm is activated and the space status is set to the corresponding error code.
[0097] It is understood that the above embodiments describe the specific process of BMC processing log commands.
[0098] It should be noted that after receiving an interrupt from the server host, the BMC side wakes up the logHandle thread, which is the log processing thread, and all other operations are performed in the logHandle thread.
[0099] On one hand, when the space status is busy, it is confirmed that the header data magic and checksum values are both correct, and a correct check result is obtained. Then, based on the correct result, the log file sent by BAR is received, the log content is placed in the file, the BAR space is cleared, and the space status is set to READY.
[0100] On the other hand, when the space status is busy, if the header data magic or checksum verification value is determined to be incorrect, an error result is obtained. At this time, the SEL log alarm function will be activated, the space status of BAR will be set to the corresponding error code, and then it will enter sleep mode.
[0101] For reference Figure 2 After the thread starts, it checks if the BAR space status is busy. If it is, it checks if the packet header data magic and checksum are correct. If not, it enters sleep mode.
[0102] Check if the header data (magic) and checksum are correct. If so, put the log content into a file, clear the BAR space (except for the status flag), and set the BAR space status to READY. If not, the sel log will sound an alarm, the BAR status will be set to the corresponding error code, and then the program will go to sleep.
[0103] This thread is a resident thread and is normally in sleep mode. It will be woken up when the host sends an interrupt to the BMC.
[0104] Reference Figure 3 The BMC interrupt procedure is as follows: After the procedure begins, it checks if the interrupt status is 1. If yes, the interrupt is cleared and the thread is woken up. If no, the procedure ends.
[0105] In some embodiments, before receiving the log file sent by the server host via the target storage space, the method further includes:
[0106] Create shared memory between the BMC and the server host, and determine the target storage space for the shared memory.
[0107] Clear the target storage space and set the space status of the target storage space to the open state;
[0108] In the event of an interruption while the server is in sleep mode, the space state is determined to transition to a working state, and the working state is set to a ready state.
[0109] It is understood that this embodiment describes the process of initializing the BMC thread.
[0110] Reference Figure 4 The log processing thread's workflow includes: after the process begins, creating shared memory, mapping the BAR space registers to the shared memory, clearing the BAR space, allocating and enabling interrupts for the BAR space, setting the BAR space state to ON, waiting for an interrupt to occur while sleeping, and determining whether the BAR space state is WORK. If yes, setting the space state to READY, and then processing log commands issued by the HOST in a loop. If not, the process ends.
[0111] It should be noted that the BMC consists of two parts: the BootLoader and the OS output system. The BootLoader mainly handles PCIe bus configuration, while the OS mainly performs operations such as handshaking with the host and requesting shared memory.
[0112] Before the BMC powers on, the PCIe configuration is already burned into the EEPROM. After power-on, the BootLoader initialization is executed first. BootLoader initialization is relatively simple; the basic process is as follows: the PCIe configuration is read from the EEPROM via I2C and written into the configuration space register. This configuration includes the BMC's VendorId, DeviceId, and BAR space configuration: BAR space size, type, etc. After setting these registers, during the BIOS startup process, the BMC device is enumerated and PCIe domain space is allocated. This process needs to occur at the very beginning of the BootLoader process. This is because if the BMC and HOST start simultaneously, starting this process too late will cause it to miss the BIOS PCIe enumeration process, resulting in module startup failure.
[0113] Reference Figure 5 The present invention also provides a log processing method, applied to a server host, including but not limited to the following steps:
[0114] Step 510: Collect system log data, write the log data into a log file, and store the log file in the target storage space;
[0115] Step 520: Send the log file to the Baseboard Management Controller (BMC) via the target storage space;
[0116] Step 530: Send a first interrupt instruction to the BMC, the first interrupt instruction being used to read the target storage space to determine the file to be read;
[0117] The target storage space is the shared memory obtained by mapping the storage space of the BMC to the memory of the server host.
[0118] In this embodiment, system log data is first collected, written to a log file, and then stored in a target storage space. The target storage space can be a BAR (Base Address Register). It should be noted that the BAR space refers to the space on the PCIe bus where a portion of the BMC's memory is mapped to the host's memory. Data written to this space at both ends of the PCIe network can be seen at the other end. The BAR space is shared memory obtained by mapping the BMC's storage space to the server host's memory.
[0119] Then, the log file is sent to the Baseboard Management Controller (BMC).
[0120] Finally, a first interrupt instruction is sent to the BMC to read the target memory space based on the first interrupt instruction to determine the file to be read.
[0121] The log processing method provided by this invention involves collecting system log data on a server host, writing the log data into a log file, storing the log file in a target storage space, sending the log file to the Baseboard Management Controller (BMC) via the target storage space, and sending a first interrupt command to the BMC to read the target storage space to determine the file to be read. This invention sends system logs obtained from the server host to the BMC via the target storage space in shared memory, eliminating the need for other devices, reducing costs, and offering simpler and more reliable software implementations compared to log transmission using datagram protocols.
[0122] In some embodiments, after storing the log file in the target storage space, the method further includes:
[0123] Set the target storage space to a busy state;
[0124] Sending the log file to the Baseboard Management Controller (BMC) via the target storage space includes:
[0125] When the space is in a busy state, the log file is sent to the Baseboard Management Controller (BMC) via the target storage space.
[0126] Specifically, in this embodiment, the space status of the BAR is first determined to be busy. Then, based on the target communication standard, i.e., PCIe, the log files sent by the server host via the target storage space are received.
[0127] In some embodiments, collecting log data from the system and writing the log data to a log file includes:
[0128] Determine the value of the log data;
[0129] If the value is greater than a preset threshold, first data and second data are determined, where the first data is log data whose value is less than the preset threshold and the second data is log data whose value is greater than the preset threshold.
[0130] Modify the filename of the log file and create a new backup file. Write the first data into the log file and the second data into the backup file.
[0131] It should be noted that the server's main thread continuously uses inotify in a loop to monitor whether the log2BMC log file has been modified. If it has been modified, the logPost thread is woken up. The inotify interface monitors whether the file has been modified or deleted.
[0132] The log collection process writes logs to the log file. It needs to determine the log file size, i.e., the amount of log data. If the log file becomes too large, it will rename log2BMC to log2BMC.1 and create a new log file. This involves changing the filename of the original log file and creating a backup file. Log data not exceeding the original log file's capacity is then written to the renamed log file, while log data exceeding the original log file's capacity is written to the newly created backup log file.
[0133] In some embodiments, it also includes:
[0134] The modification information of the log files is determined by monitoring the log files using the target execution tool.
[0135] If the modification information indicates that the file name has been changed, the first log publishing thread is activated; if the modification information indicates that the log file has been deleted, the second log publishing thread is activated.
[0136] It is understandable that this embodiment represents two scenarios for the logPost thread: one is that inotify detects that log2BMC has been modified, and the other is that inotify detects that log2BMC has been renamed.
[0137] Reference Figure 6The process of the log publishing thread on the server host side is as follows:
[0138] Once the process begins, the log file log2BMC is opened, the log collection process modifies the log file, and inotify is used to monitor the log file before waking up the logpost thread.
[0139] Reference Figure 7 The inotify process for detecting file modification, which is the first log publishing thread, involves inotify returning IN-MODIFY; determining whether the BMC shared memory is ready. If so, it calculates the length from the file pointer to the end of the file, denoted as len. If not, it waits for the BAR space to be READY.
[0140] Determine if len is greater than 996. If so, organize the packet header data, set the BAR space to BUSY, copy the packet header data and 996B logs into the BMC BAR space, and then send a terminal to the BMC, incrementing the file pointer by 996 and decrementing len by 996, and waiting for the BAR space to be READY.
[0141] If not, organize the packet header data, set the BAR space to BUSY, copy the packet header data and the len bytes of log after the file pointer into the BMC BAR space, increment the file pointer by len, send an interrupt to the BMC, and then go to sleep.
[0142] Reference Figure 8 The process by which inotify detects a deleted (or renamed) file is the first log publishing thread:
[0143] inotify returns IN-DELETE, opens log2BMC.1, calculates the length to the end of the file using the log file pointer, and denots it as len;
[0144] Check if len equals 0. If yes, close log2BMC.1 and enter sleep mode. If no, check if the BMC shared memory is READY. If yes, calculate the length from the file pointer to the end of the file and record it as len. If no, wait for the BAR space to be READY.
[0145] Determine if len is greater than 996. If so, organize the packet header data, set the BAR space to BUSY, copy the packet header data and 996B logs into the BMC BAR space, and then send a terminal to the BMC, incrementing the file pointer by 996 and decrementing len by 996, and waiting for the BAR space to be READY.
[0146] If not, organize the packet header data, set the BAR space to BUSY, copy the packet header data and the len bytes of log after the file pointer into the BMC BAR space, close log2BMC.1, open log2BMC, and follow the same steps as above.
[0147] It should be noted that the data structure of the header data is as follows:
[0148]
[0149] It should be noted that during initialization, the BMC is registered as a PCIe EP device on the host side and will request the corresponding BAR space. After the data is written into the BAR space, the PCIe bus will send the data to the BMC.
[0150] The size of the BAR space used for log collection is 1024B. There is a conditional statement in the process: len>996, where 996 is the size of the BAR space minus the size of the data header and then minus the BAR space status flag.
[0151] The status flag in the BAR space is located in the first byte of the BAR space. Except for the normal status (OFF, ON, WORK, BUSY, READY), the rest are all ERROR, and their values represent different errors.
[0152] In some embodiments, before writing the log data of the collection system to a log file, the method further includes:
[0153] The basic input / output system stage and the output system BIOS stage of the server host are initialized.
[0154] It is understood that this embodiment describes the process of initializing the server host.
[0155] The server host initialization process can also be divided into the BIOS stage and the OS stage. The BIOS stage mainly involves enumerating devices and allocating PCIe domain space. For specific procedures, refer to the PCIe protocol.
[0156] Reference Figure 9 The OS phase can be divided into the main initialization process and the initialization process in the logPost thread. The main initialization process is as follows:
[0157] After the process begins, the driver device object data structure is allocated, the BAR space is mapped, the cdev device is created, and the logpost thread is created, until the process ends.
[0158] Reference Figure 10 The initialization process of the logpost thread under the host OS is as follows:
[0159] After the process starts, it checks if the BAR space status is ON. If yes, it changes the BAR space status to WORK, then processes the data in a loop and sends logs. If no, it checks if the wait has timed out. If yes, it sets the BAR space status to an error code and then ends the process. If no, it sleeps and waits, then returns to check if the BAR space status is ON.
[0160] Reference Figure 11 After initialization of the BMC and server host, the diagram of the BAR space status flags is shown below:
[0161] In the OFF state, BMC initialization is completed and switches to the ON state. HOST initialization is completed and switches to the WORK state. If a timeout occurs, an ERROR is confirmed. If BMC receives an interrupt, it switches to READY. If the HOST log file changes, it is set to BUSY. After recording is complete, it is set to READY. If a timeout occurs, it is set to ERROR.
[0162] Reference Figure 12 , Figure 12 A schematic diagram of the two-end interaction of the log processing method provided by the present invention:
[0163] On the HOST side, after the process starts, the log collection process puts the logs into the specified file and removes them from the specified file and puts them into the BAR space corresponding to the BMC;
[0164] The host sends an interrupt to the BMC;
[0165] On the BMC side, after the process starts, the logs are retrieved from the logs and written to a file;
[0166] BMC sends an interrupt to the HOST.
[0167] The log processing apparatus provided by the present invention is described below. The log processing apparatus described below and the log processing method described above can be referred to in correspondence.
[0168] Reference Figure 13 The log processing device provided by the present invention includes, but is not limited to, the following modules:
[0169] The first module 1310 is used to receive the first interrupt command sent by the server host;
[0170] The second module 1320 is used to receive the log file sent by the server host via the target storage space, read the log file from the target storage space based on the first interrupt instruction, determine the file to be read, and write the read file into the target file;
[0171] The target storage space is the shared memory obtained by mapping the storage space of the BMC to the memory of the server host.
[0172] First, it should be noted that the Baseboard Management Controller (BMC) in this embodiment of the invention can perform firmware upgrades, check the machine's equipment, and perform other operations even when the machine is not powered on. A PCIe path exists between the BMC and the server host. In this embodiment, PCIe (Peripheral Component Interconnect Express) is a high-speed serial computer expansion bus standard.
[0173] In the first module 1310 mentioned above, the log file sent by the server host (HOST) via the target storage space is received. The target storage space can be the BAR (Base Address Register). It should be noted that the BAR space refers to the space on the PCIe bus where a portion of the BMC's memory is mapped into the HOST's memory. Data written to this space at both ends of the PCIe network can be seen at the other end. The BAR space is shared memory obtained by mapping the BMC's storage space into the server host's memory.
[0174] Understandably, the log data generated by the system can be collected into a log file through the log collection process, which can be recorded as the first file. Then, the log file is packaged into the BAR space, and then the log file is sent to the BMC end through the BAR.
[0175] It should be noted that data transfer between the HOST and BMC is based on PCIe, that is, log files are transferred from the host to the BMC via PCIe.
[0176] In the second module 1320 mentioned above, it is used to receive log files sent by the server host via the target storage space, read log files from the target storage space based on the first interrupt instruction, determine the file to be read, and write the read file into the target file.
[0177] It should be noted that the first interrupt instruction in this embodiment is the instruction sent by the server host to the BMC to interrupt the reception of log files. The BMC reads the log file from the BAR according to the first interrupt instruction and writes the log file to another file, which can be referred to as the second file.
[0178] The log processing device provided by this invention receives a first interrupt command sent by the server host at the BMC side, then receives the log file sent by the server host via the target storage space, and reads the log file from the target storage space based on the first interrupt command, determines the file to be read, and writes the read file into the target file. This invention sends the system logs obtained by the server host to the BMC side via the target storage space in shared memory, without occupying other equipment, reducing costs. Furthermore, it is simpler to implement than software-based log transmission using datagram protocols and offers higher reliability.
[0179] In some embodiments, the log file received by the receiving server host via the target storage space includes:
[0180] Determine the spatial state of the target storage space;
[0181] When the space is in a busy state, log files sent by the server host via the target storage space are received based on the target communication standard.
[0182] It is understood that this embodiment describes the specific process of receiving log files sent by the server host via the BAR space.
[0183] First, determine the spatial state of the BAR. The spatial state of the BAR includes OFF, ON, WORK, BUSY, and READY, which correspond to the states of being closed, open, working, busy, and ready, respectively.
[0184] When the space is busy, log files sent by the server host through the target storage space are received based on the target communication standard, PCIe.
[0185] In some embodiments, after storing the read file into the target file, the method further includes:
[0186] Clear the target storage space and set the space status to ready.
[0187] Understandably, after the log files in the BAR have been sent and read by the BMC, the storage space of the BAR can be cleared to facilitate the subsequent storage of log files, and the space status can be set to the ready state to continue sending log files.
[0188] In some embodiments, when the space status is busy, receiving log files sent by the server host via the target storage space based on the target communication standard includes:
[0189] When the space is in a busy state, it is determined that both the packet header data and the check value are correct, and a correct check result is obtained;
[0190] Based on the correct results of the inspection, log files sent by the target communication standard server host via the target storage space are received.
[0191] In some embodiments, it also includes:
[0192] If the header data or checksum is determined to be an error, an error check result is obtained. Based on the error check result, a log alarm is activated and the space status is set to the corresponding error code.
[0193] It is understood that the above embodiments describe the specific process of BMC processing log commands.
[0194] It should be noted that after receiving an interrupt from the server host, the BMC side wakes up the logHandle thread, which is the log processing thread, and all other operations are performed in the logHandle thread.
[0195] On one hand, when the space status is busy, it is confirmed that the header data magic and checksum values are both correct, and a correct check result is obtained. Then, based on the correct result, the log file sent by BAR is received, the log content is placed in the file, the BAR space is cleared, and the space status is set to READY.
[0196] On the other hand, when the space status is busy, if the header data magic or checksum verification value is determined to be incorrect, an error result is obtained. At this time, the SEL log alarm function will be activated, the space status of BAR will be set to the corresponding error code, and then it will enter sleep mode.
[0197] In some embodiments, before receiving the log file sent by the server host via the target storage space, the method further includes:
[0198] Create shared memory between the BMC and the server host, and determine the target storage space for the shared memory.
[0199] Clear the target storage space and set the space status of the target storage space to the open state;
[0200] In the event of an interruption while the server is in sleep mode, the space state is determined to transition to a working state, and the working state is set to a ready state.
[0201] Reference Figure 14 The log processing device provided by the present invention includes, but is not limited to, the following modules:
[0202] The third module 1410 is used to collect system log data, write the log data into a log file, and store the log file in a target storage space.
[0203] The fourth module 1420 is used to send the log file to the baseboard management controller (BMC) via the target storage space;
[0204] The fifth module 1430 is used to send a first interrupt instruction to the BMC, the first interrupt instruction being used to read the target storage space to determine the file to be read;
[0205] The target storage space is the shared memory obtained by mapping the storage space of the BMC to the memory of the server host.
[0206] In this embodiment, system log data is first collected, written to a log file, and then stored in a target storage space. The target storage space can be a BAR (Base Address Register). It should be noted that the BAR space refers to the space on the PCIe bus where a portion of the BMC's memory is mapped to the host's memory. Data written to this space at both ends of the PCIe network can be seen at the other end. The BAR space is shared memory obtained by mapping the BMC's storage space to the server host's memory.
[0207] Then, the log file is sent to the Baseboard Management Controller (BMC).
[0208] Finally, a first interrupt instruction is sent to the BMC to read the target memory space based on the first interrupt instruction to determine the file to be read.
[0209] The log processing apparatus provided by this invention collects system log data on a server host, writes the log data into a log file, stores the log file in a target storage space, sends the log file to the Baseboard Management Controller (BMC) via the target storage space, and sends a first interrupt command to the BMC to read the target storage space to determine the file to be read. This invention sends system logs obtained from the server host to the BMC side via the target storage space in shared memory, without requiring additional equipment, reducing costs. Furthermore, it is simpler and more reliable than software implementations that use datagram protocols to transmit logs.
[0210] In some embodiments, after storing the log file in the target storage space, the method further includes:
[0211] Set the target storage space to a busy state;
[0212] Sending the log file to the Baseboard Management Controller (BMC) via the target storage space includes:
[0213] When the space is in a busy state, the log file is sent to the Baseboard Management Controller (BMC) via the target storage space.
[0214] Specifically, in this embodiment, the space status of the BAR is first determined to be busy. Then, based on the target communication standard, i.e., PCIe, the log files sent by the server host via the target storage space are received.
[0215] In some embodiments, collecting log data from the system and writing the log data to a log file includes:
[0216] Determine the value of the log data;
[0217] If the value is greater than a preset threshold, first data and second data are determined, where the first data is log data whose value is less than the preset threshold and the second data is log data whose value is greater than the preset threshold.
[0218] Modify the filename of the log file and create a new backup file. Write the first data into the log file and the second data into the backup file.
[0219] It should be noted that the server's main thread continuously uses inotify in a loop to monitor whether the log2BMC log file has been modified. If it has been modified, the logPost thread is woken up. The inotify interface monitors whether the file has been modified or deleted.
[0220] The log collection process writes logs to the log file. It needs to determine the log file size, i.e., the amount of log data. If the log file becomes too large, it will rename log2BMC to log2BMC.1 and create a new log file. This involves changing the filename of the original log file and creating a backup file. Log data not exceeding the original log file's capacity is then written to the renamed log file, while log data exceeding the original log file's capacity is written to the newly created backup log file.
[0221] In some embodiments, it also includes:
[0222] The modification information of the log files is determined by monitoring the log files using the target execution tool.
[0223] If the modification information indicates that the file name has been changed, the first log publishing thread is activated; if the modification information indicates that the log file has been deleted, the second log publishing thread is activated.
[0224] It is understandable that this embodiment represents two scenarios for the logPost thread: one is that inotify detects that log2BMC has been modified, and the other is that inotify detects that log2BMC has been renamed.
[0225] In some embodiments, before writing the log data of the collection system to a log file, the method further includes:
[0226] The basic input / output system stage and the output system BIOS stage of the server host are initialized.
[0227] Figure 15 An example is a schematic diagram of the physical structure of an electronic device, such as... Figure 15 As shown, the electronic device may include: a processor 1510, a communications interface 1520, a memory 1530, and a communication bus 1540, wherein the processor 1510, the communications interface 1520, and the memory 1530 communicate with each other via the communication bus 1540. The processor 1510 can call logical instructions in the memory 1530 to execute a log processing method, which includes:
[0228] Receive the first interrupt command sent by the server host;
[0229] Receive the log file sent by the server host via the target storage space, read the log file from the target storage space based on the first interrupt instruction, determine the file to be read, and write the read file into the target file;
[0230] The target storage space is the shared memory obtained by mapping the storage space of the BMC to the memory of the server host.
[0231] or,
[0232] Collect system log data, write the log data into a log file, and store the log file in the target storage space;
[0233] The log file is sent to the Baseboard Management Controller (BMC) via the target storage space;
[0234] Send a first interrupt instruction to the BMC, the first interrupt instruction being used to read the target storage space to determine the file to be read;
[0235] The target storage space is the shared memory obtained by mapping the storage space of the BMC to the memory of the server host.
[0236] Furthermore, the logical instructions in the aforementioned memory 1530 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0237] On the other hand, the present invention also provides a computer program product, the computer program product comprising a computer program that can be stored on a non-transitory computer-readable storage medium, wherein when the computer program is executed by a processor, the computer is able to execute the log processing method provided by the above methods, the method comprising:
[0238] Receive the first interrupt command sent by the server host;
[0239] Receive the log file sent by the server host via the target storage space, read the log file from the target storage space based on the first interrupt instruction, determine the file to be read, and write the read file into the target file;
[0240] The target storage space is the shared memory obtained by mapping the storage space of the BMC to the memory of the server host.
[0241] or,
[0242] Collect system log data, write the log data into a log file, and store the log file in the target storage space;
[0243] The log file is sent to the Baseboard Management Controller (BMC) via the target storage space;
[0244] Send a first interrupt instruction to the BMC, the first interrupt instruction being used to read the target storage space to determine the file to be read;
[0245] The target storage space is the shared memory obtained by mapping the storage space of the BMC to the memory of the server host.
[0246] In another aspect, 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 perform the log processing methods provided by the methods described above, the method comprising:
[0247] Receive the first interrupt command sent by the server host;
[0248] Receive the log file sent by the server host via the target storage space, read the log file from the target storage space based on the first interrupt instruction, determine the file to be read, and write the read file into the target file;
[0249] The target storage space is the shared memory obtained by mapping the storage space of the BMC to the memory of the server host.
[0250] or,
[0251] Collect system log data, write the log data into a log file, and store the log file in the target storage space;
[0252] The log file is sent to the Baseboard Management Controller (BMC) via the target storage space;
[0253] Send a first interrupt instruction to the BMC, the first interrupt instruction being used to read the target storage space to determine the file to be read;
[0254] The target storage space is the shared memory obtained by mapping the storage space of the BMC to the memory of the server host.
[0255] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.
[0256] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.
[0257] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A log processing method characterized by, The application is applied to a baseboard management controller (BMC) and comprises the following steps: receiving a first interrupt instruction sent by a server host; the first interrupt instruction is an instruction sent by the server host to the BMC for interrupting log file receiving; receiving a log file sent by the server host via a target storage space, reading the log file from the target storage space based on the first interrupt instruction, determining a read file, and writing the read file into a target file; wherein the target storage space is shared memory obtained by mapping a storage space of the BMC into a memory of the server host; the receiving of the log file sent by the server host via the target storage space comprises the following steps: determining a space state of the target storage space; in a case where the space state is a busy state, receiving the log file sent by the server host via the target storage space based on a target communication standard.
2. The log processing method of claim 1, wherein, after the read file is stored into the target file, the method further comprises the following steps: emptying the target storage space and setting the space state to a ready state.
3. The log processing method of claim 1, wherein, in a case where the space state is a busy state, the receiving of the log file sent by the server host via the target storage space based on a target communication standard comprises the following steps: in a case where the space state is a busy state, determining that both the header data and the check value are correct values to obtain a correct checking result; based on the correct checking result, receiving the log file sent by the server host via the target storage space based on a target communication standard.
4. The log processing method of claim 3, wherein, the method further comprises the following steps: determining that the header data or the check value is an error value to obtain an error checking result, starting a log alarm based on the error checking result, and setting the space state to a corresponding error code.
5. The log processing method of claim 1, wherein, before the receiving of the log file sent by the server host via the target storage space, the method further comprises the following steps: creating shared memory between the BMC and the server host to determine a shared target storage space; emptying the target storage space and setting a space state of the target storage space to an open state; in a case where an interrupt is generated in a server sleep state, determining that the space state is converted to a working state and setting the working state to a ready state.
6. A log processing method characterized by, The application is applied to a server host and comprises the following steps: collecting log data of a system, writing the log data into a log file, and storing the log file in a target storage space; sending the log file to a baseboard management controller (BMC) via the target storage space; sending a first interrupt instruction to the BMC; the first interrupt instruction is used for reading the target storage space to determine a read file; the first interrupt instruction is an instruction sent by the server host to the BMC for interrupting log file receiving; wherein the target storage space is shared memory obtained by mapping a storage space of the BMC into a memory of the server host; after the log file is stored in the target storage space, the method further comprises the following steps: setting a space state of the target storage space to a busy state; the sending of the log file to the BMC via the target storage space comprises the following steps: In the busy state, the log file is sent to a baseboard management controller (BMC) via the target storage space.
7. The log processing method of claim 6, wherein, The log data of the collection system, before the log data is written into a log file, further comprises: determining a value of the log data; in the case that the value is greater than a preset threshold, determining first data and second data, the first data being log data whose value is less than the preset threshold, and the second data being log data whose value is greater than the preset threshold; modifying a file name of the log file, creating a backup file, writing the first data into the log file, and writing the second data into the backup file.
8. The log processing method of claim 7, wherein, Further comprising: monitoring the log file based on a target execution tool to determine modification information of the log file; in the case that the modification information is that the file name is modified, waking up a first log publishing thread; and in the case that the modification information is that the log file is deleted, waking up a second log publishing thread.
9. The log processing method of claim 6, wherein, The log data of the collection system, before the log data is written into a log file, further comprises: initializing a basic input / output system (BIOS) stage and an output system (OS) stage of the server host.
10. A log processing apparatus characterized by comprising: Applied to a baseboard management controller (BMC), comprising: a first module configured to receive a first interrupt instruction sent by a server host; the first interrupt instruction being an instruction sent by the server host to the BMC for interrupting log file receiving; a second module configured to receive a log file sent by the server host via a target storage space, read the log file from the target storage space based on the first interrupt instruction, determine a read file, and write the read file into a target file; wherein the target storage space is shared memory obtained by mapping a storage space of the BMC to a memory of the server host; the receiving of the log file sent by the server host via the target storage space comprises: determining a space state of the target storage space; in the case that the space state is a busy state, receiving the log file sent by the server host via the target storage space based on a target communication standard.
11. A log processing apparatus characterized by comprising: Applied to a server host, comprising: a third module configured to collect log data of a system, write the log data into a log file, and store the log file in a target storage space; a fourth module configured to send the log file to a baseboard management controller (BMC) via the target storage space; a fifth module configured to send a first interrupt instruction to the BMC, the first interrupt instruction being used to read the target storage space to determine a read file; the first interrupt instruction being an instruction sent by the server host to the BMC for interrupting log file receiving; wherein the target storage space is shared memory obtained by mapping a storage space of the BMC to a memory of the server host; after the log file is stored in the target storage space, further comprising: setting a space state of the target storage space to a busy state; the sending of the log file to the BMC via the target storage space comprises: When the space state is a busy state, the log file is sent to a baseboard management controller (BMC) via the target storage space.
12. An electronic device comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that, The processor implements the log processing method according to any one of claims 1-5 or the log processing method according to any one of claims 6-9 when executing the program.
13. A non-transitory computer-readable storage medium having stored thereon a computer program, characterized in that, The computer program implements the log processing method according to any one of claims 1-5 or the log processing method according to any one of claims 6-9 when executed by the processor.
Citation Information
Patent Citations
Log management method and device, electronic equipment and storage medium
CN112632019A
Abnormal information acquisition method, system and device and storage medium
CN113434324A