CN116185978A - Log processing method and device, electronic equipment and storage medium - Google Patents

Log processing method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN116185978A
CN116185978A CN202310101062.0A CN202310101062A CN116185978A CN 116185978 A CN116185978 A CN 116185978A CN 202310101062 A CN202310101062 A CN 202310101062A CN 116185978 A CN116185978 A CN 116185978A
Authority
CN
China
Prior art keywords
log
file
storage space
target storage
bmc
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202310101062.0A
Other languages
Chinese (zh)
Inventor
王殿卫
刘宝阳
赵凤鸣
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Suzhou Inspur Intelligent Technology Co Ltd
Original Assignee
Suzhou Inspur Intelligent Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Suzhou Inspur Intelligent Technology Co Ltd filed Critical Suzhou Inspur Intelligent Technology Co Ltd
Priority to CN202310101062.0A priority Critical patent/CN116185978A/en
Publication of CN116185978A publication Critical patent/CN116185978A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/18File system types
    • G06F16/1805Append-only file systems, e.g. using logs or journals to store data
    • G06F16/1815Journaling file systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F13/00Interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
    • G06F13/38Information transfer, e.g. on bus
    • G06F13/42Bus transfer protocol, e.g. handshake; Synchronisation
    • G06F13/4204Bus transfer protocol, e.g. handshake; Synchronisation on a parallel bus
    • G06F13/4221Bus transfer protocol, e.g. handshake; Synchronisation on a parallel bus being an input/output bus, e.g. ISA bus, EISA bus, PCI bus, SCSI bus
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/544Buffers; Shared memory; Pipes
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Software Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The invention provides a log processing method, a log processing device, electronic equipment and a storage medium, wherein the method comprises the following steps: receiving a first interrupt instruction sent by a server host; receiving a log file sent by the server host through 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 the target file; the target storage space is a shared memory obtained by mapping the storage space of the BMC to a memory of a server host. The system log obtained by the server host is sent to the BMC side through the target storage space of the shared memory, other equipment is not required to be occupied, the cost is reduced, and compared with the software implementation of transmitting the log by using a datagram protocol, the system log transmission method and the system log transmission device are simpler in implementation and higher in reliability.

Description

Log processing method and device, electronic equipment and storage medium
Technical Field
The present invention relates to the field of server technologies, and in particular, to a log processing method, a log processing device, an electronic device, and a storage medium.
Background
The service system log will play a significant role in troubleshooting codes. Using centralized logging, a relevant view of all log data can be obtained. In contrast, viewing each log file individually can become very time consuming. Thus, forwarding of local log messages to remote logging servers has become the standard for logging solutions.
User datagram protocol (User Datagram Protocol, UDP) is now commonly used today to send to the log server, UDP based implementations mean that reliability problems may exist. As systems become more complex, it becomes more and more important to collect and monitor all relevant data generated by applications, and the loss of logs means that later system error analysis may be made difficult.
Disclosure of Invention
The invention provides a log processing method, a log processing device, electronic equipment and a storage medium, which are used for solving the defects existing in the prior art, realizing that a system log is sent to a BMC side through a target storage space of a shared memory, and reducing cost without occupying other equipment.
The invention provides a log processing method, which is applied to a Baseboard Management Controller (BMC), and comprises the following steps:
receiving a first interrupt instruction sent by a server host;
receiving a log file sent by the server host through 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 the target file;
the target storage space is a shared memory obtained by mapping the storage space of the BMC to a memory of a server host.
According to the log processing method provided by the invention, the log file sent by the server host through the target storage space is received, and the log processing method comprises the following steps:
determining a space state of the target storage space;
and receiving the log file sent by the server host through the target storage space based on the target communication standard under the condition that the space state is a busy state.
According to the log processing method provided by the invention, after the read file is stored in the target file, the log processing method further comprises the following steps:
and emptying the target storage space and setting the space state to be a ready state.
According to the log processing method provided by the invention, when the space state is a busy state, the log file sent by the server host through the target storage space is received based on the target communication standard, and the log processing method comprises the following steps:
under the condition that the space state is a busy state, determining that the packet header data and the check value are both correct values, and obtaining a correct checking result;
in conjunction with checking for correct results, log files sent by the server host via the target storage space are received based on the target communication standard.
The log processing method provided by the invention further comprises the following steps:
And determining the packet head data or the check value as an error value, obtaining an error checking result, starting log alarm based on the error checking result, and setting the space state as a corresponding error code.
According to the log processing method provided by the invention, before receiving the log file sent by the server host through the target storage space, the log processing method further comprises the following steps:
creating a shared memory between the BMC and the server host, and determining a shared target storage space;
the target storage space is emptied, and the space state of the target storage space is set to be an open state;
and under the condition that an interrupt is generated in the sleep state of the server, determining that the space state is converted into the working state, and setting the working state into the ready state.
The invention also provides a log processing method, which is applied to the 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;
the log file is sent to a baseboard management controller BMC through the target storage space;
sending a first interrupt instruction to the BMC, wherein the first interrupt instruction is used for reading the target storage space to determine a read file;
The target storage space is a shared memory obtained by mapping the storage space of the BMC to a memory of a server host.
According to the log processing method provided by the invention, after the log file is stored in the target storage space, the log processing method further comprises the following steps:
setting the space state of the target storage space to be a busy state;
the sending the log file to the baseboard management controller BMC via the target storage space includes:
and when the space state is a busy state, sending the log file to a Baseboard Management Controller (BMC) through the target storage space.
According to the log processing method provided by the invention, the log data of the collection system is written into a log file, and the log processing method comprises the following steps:
determining a value of the log data;
under the condition that the numerical value is larger than a preset threshold value, determining first data and second data, wherein the first data are log data with the numerical value smaller than the preset threshold value, and the second data are log data with the numerical value larger than the preset threshold value;
and modifying the file name of the log file, creating a standby file, writing the first data into the log file, and writing the second data into the standby file.
The log processing method provided by the invention further comprises the following steps:
monitoring the log file based on a target execution tool, and determining modification information of the log file;
when the modification information is that the file name is modified, waking up a first log publishing thread; and under the condition that the modification information is that the log file is deleted, waking up a second log publishing thread.
According to the log processing method provided by the invention, before the log data of the collection system is written into the log file, the log processing method further comprises the following steps:
and initializing a basic input and output system stage and an output system BIOS stage of the server host.
The invention also provides a log processing device, which comprises:
the first module is used for receiving a first interrupt instruction sent by the server host;
the second module is used for receiving the log file sent by the server host through the 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 the target file;
the target storage space is a shared memory obtained by mapping the storage space of the BMC to a memory of a server host.
The invention also provides a log processing device, which comprises:
the third module is used for collecting log data of the system, writing the log data into a log file and storing the log file in a target storage space;
a fourth module, configured to send the log file to a baseboard management controller BMC via a target storage space;
a fifth module, configured to send a first interrupt instruction to the BMC, where the first interrupt instruction is used to read the target storage space to determine a read file;
the target storage space is a shared memory obtained by mapping the storage space of the BMC to a memory of a server host.
The invention also provides an electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, the processor implementing any of the log processing methods described above when executing the program.
The present invention also provides a non-transitory computer readable storage medium having stored thereon a computer program which, when executed by a processor, implements a log processing method as described in any of the above.
The invention also provides a computer program product comprising a computer program which when executed by a processor implements a log processing method as described in any one of the above.
According to the log processing method, the log processing device, the electronic equipment and the storage medium, the BMC receives the first interrupt instruction sent by the server host, then receives the log file sent by the server host through the target storage space, reads the log file from the target storage space based on the first interrupt instruction, determines the read file and writes the read file into the target file. The system log obtained by the server host is sent to the BMC side through the target storage space of the shared memory, other equipment is not required to be occupied, the cost is reduced, and compared with the software implementation of transmitting the log by using a datagram protocol, the system log transmission method and the system log transmission device are simpler in implementation and higher in reliability.
Drawings
In order to more clearly illustrate the invention or the technical solutions of the prior art, the following description will briefly explain the drawings used in the embodiments or the description of the prior art, and it is obvious that the drawings in the following description are some embodiments of the invention, and other drawings can be obtained according to the drawings without inventive effort for a person skilled in the art.
FIG. 1 is a schematic flow chart of a log processing method according to the present invention;
FIG. 2 is a second flow chart of the log processing method according to the present invention;
FIG. 3 is a third flow chart of the log processing method according to the present invention;
FIG. 4 is a flow chart of a log processing method according to the present invention;
FIG. 5 is a flowchart of a log processing method according to the present invention;
FIG. 6 is a flowchart of a log processing method according to the present invention;
FIG. 7 is a flow chart of a log processing method according to the present invention;
FIG. 8 is a flowchart illustrating a log processing method according to the present invention;
FIG. 9 is a flowchart illustrating a log processing method according to the present invention;
FIG. 10 is a schematic flow chart of a log processing method according to the present invention;
FIG. 11 is a flowchart illustrating a log processing method according to an embodiment of the present invention;
FIG. 12 is a double-ended interaction schematic diagram of a log processing method provided by the present invention;
FIG. 13 is a schematic diagram of a log processing device according to the present invention;
FIG. 14 is a second schematic diagram of a log processing device according to the present invention;
fig. 15 is a schematic structural diagram of an electronic device provided by the present invention.
Detailed Description
For the purpose of making the objects, technical solutions and advantages of the present invention more apparent, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings, and it is apparent that the described embodiments are some embodiments of the present invention, not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
The steps of the present invention will be described in detail below by executing the log processing method provided by the present invention with a computer.
Referring to fig. 1, the log processing method provided by the present invention is applied to a baseboard management controller BMC, and includes, but is not limited to, the following steps:
step 110, receiving a first interrupt instruction sent by a server host;
step 120, receiving a log file sent by a server host through 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 the target file;
the target storage space is a shared memory obtained by mapping the storage space of the BMC to a memory of a server host.
It should be noted that, in the embodiment of the present invention, the baseboard management controller BMC (Baseboard Management Controller) may perform some operations such as firmware upgrade, checking machine equipment, etc. on the machine in a state that the machine is not powered on. A PCIe path exists between the BMC and the server host, and PCIe (Peripheral Component Interconnect Express) in this embodiment is a high-speed serial computer expansion bus standard.
In the above step 110, a first interrupt instruction sent by the server host is received.
In step 120, after receiving the first interrupt instruction, the log file sent by the server HOST via the target storage space is received. The target memory space may be a BAR (Base Address Register) base address register. The BAR space refers to a space on the PCIe bus where a portion of the memory of the BMC is mapped to the memory of the HOST, where data in the space is written to the PCIe port, and the data is visible to the other PCIe port. The BAR space is a shared memory obtained by mapping the memory space of the BMC to the server host memory.
It will be appreciated that the log data generated by the system may be collected into a log file by a log collection process, and may be recorded as a first file, and then the log file is placed in the BAR space in a packet, that is, the log file is sent to the BMC end through the PCIe bus.
It should be noted that, data transmission between HOST and BMC is based on PCIe, i.e., log files are transmitted from HOST to BMC through PCIe.
It should be noted that, in this embodiment, the first interrupt instruction, that is, the instruction for receiving the interrupt log file sent by the server host to the BMC, the BMC reads the log file from the BAR according to the first interrupt instruction, writes the log file into another file, and may be recorded as the second file.
According to the log processing method provided by the invention, the BMC receives the first interrupt instruction sent by the server host, then receives the log file sent by the server host through the target storage space, reads the log file from the target storage space based on the first interrupt instruction, determines the read file and writes the read file into the target file. The system log obtained by the server host is sent to the BMC side through the target storage space of the shared memory, other equipment is not required to be occupied, the cost is reduced, and compared with the software implementation of transmitting the log by using a datagram protocol, the system log transmission method and the system log transmission device are simpler in implementation and higher in reliability.
In some embodiments, the receiving the log file sent by the server host via the target storage space includes:
determining a space state of the target storage space;
and receiving the log file sent by the server host through the target storage space based on the target communication standard under the condition that the space state is a busy state.
It will be appreciated that this embodiment is a specific process of receiving log files sent by a server host via the BAR space.
The spatial state of the BAR is first determined. The spatial states of the BAR include OFF, ON, WORK, BUSY, READY, and the corresponding states are an off state, an on state, a working state, a busy state and a ready state.
When the space state is a busy state, the log file transmitted by the server host via the target storage space is received based on the PCIe, which is a target communication standard.
In some embodiments, after storing the read file in the target file, the method further includes:
and emptying the target storage space and setting the space state to be a ready state.
It can be understood that after the log file in the BAR is sent completely, and the BMC can empty the storage space of the BAR after the BMC finishes reading, so as to facilitate the subsequent continuous storage of the log file, and set the space state to be a ready state so as to facilitate the continuous sending of the log file.
In some embodiments, receiving a log file sent by a server host via a target storage space based on a target communication standard, where the space state is a busy state, comprises:
under the condition that the space state is a busy state, determining that the packet header data and the check value are both correct values, and obtaining a correct checking result;
in conjunction with checking for correct results, log files sent by the server host via the target storage space are received based on the target communication standard.
In some embodiments, further comprising:
And determining the packet head data or the check value as an error value, obtaining an error checking result, starting log alarm based on the error checking result, and setting the space state as a corresponding error code.
It can be appreciated that the above embodiment is a specific process of processing the log command by the BMC side.
After receiving the interrupt of the server host, the BMC wakes up the log handle thread, i.e., the log processing thread, and the rest of the log handle threads.
On the one hand, when the space state is the busy state, the header data mac and checksum check values are both determined to be correct values, and a correct checking result is obtained. And then receiving the log file sent by the BAR according to the correct result, putting the log content into the file, emptying the BAR space, and setting the space state as READY.
On the other hand, when the space state is busy, determining the header data mac or checksum check value as an error value, and obtaining an error checking result. At this time, the sel log alarm function is started, the spatial state of the BAR is set to be the corresponding error code, and then the sleep state is entered.
Referring to fig. 2, after the thread starts, it is determined that the BAR space state is busy, if yes, it is checked whether the header data magic, checksum are correct, and if not, it goes to sleep.
Checking whether header data magic and checksum are correct, if yes, putting the log content into a file, emptying BAR space (except for a state flag), setting the BAR space state as READY, if no, alarming sel log, setting the BAR state as a corresponding error code, and then entering sleep.
The thread is a resident thread that will wake up after HOST sends an interrupt to BMC during normal sleep.
Referring to fig. 3, the bmc interrupt flow is as follows: after the flow starts, judging whether the interrupt state is 1, if yes, cleaning the interrupt, and waking up the thread. If not, the process is ended.
In some embodiments, before receiving the log file sent by the server host via the target storage space, the method further includes:
creating a shared memory between the BMC and the server host, and determining a shared target storage space;
the target storage space is emptied, and the space state of the target storage space is set to be an open state;
and under the condition that an interrupt is generated in the sleep state of the server, determining that the space state is converted into the working state, and setting the working state into the ready state.
It will be appreciated that this embodiment is a process for BMC thread initialization.
Referring to fig. 4, the flow of the log processing thread includes: after the process starts, a shared memory is created, a BAR space register is mapped into the shared memory, the BAR space is cleared, the BAR space is applied for and can be interrupted, the BAR space state is set to be ON, the generation of interruption is waited in sleeping, and whether the BAR space state is WORK is judged. If yes, the space state is set as READY, and then log commands issued by HOST are circularly processed. If not, the process is ended,
it should be noted that, the BMC end is composed of two parts: bootLoader and OS output system, configuration of PCIe bus mainly done in BootLoader, OS terminal mainly handshakes with HOST terminal, application of shared memory and other operations
Before the BMC is powered up, the PCIe configuration is already burned in the EEPROM, and the initialization of the BootLoader is performed first after the BMC is powered up. The BootLoader end is simpler to initialize, and the basic flow is as follows: the PCIe configuration is read out from the EEPROM through the I2C and written once into the configuration space register, which contains the configuration of the BAR space and VendorId, deviceId etc. of the BMC: BAR space size, type, etc. After the registers are set, in the process of starting the BIOS, the BMC device is enumerated, and PCIe domain space is allocated. This flow needs to be done at the beginning of BootLoader. This is because if the BMC starts up at the same time as HOST, it will miss the BIOS PCIe enumeration process if the process starts up too late, resulting in a module start failure.
Referring to fig. 5, the present invention further provides a log processing method applied to a server host, including but not limited to the following steps:
step 510, collecting log data of a system, writing the log data into a log file, and storing the log file in a target storage space;
step 520, sending the log file to a baseboard management controller BMC via the target storage space;
step 530, sending a first interrupt instruction to the BMC, where the first interrupt instruction is used to read the target storage space to determine a read file;
the target storage space is a shared memory obtained by mapping the storage space of the BMC to a memory of a server host.
In this embodiment, first, log data of the system is collected, the log data is written into a log file, and the log file is stored in a target storage space. The target memory space may be a BAR (Base Address Register) base address register. The BAR space refers to a space on the PCIe bus where a portion of the memory of the BMC is mapped to the memory of the HOST, where data in the space is written to the PCIe port, and the data is visible to the other PCIe port. The BAR space is a shared memory obtained by mapping the memory space of the BMC to the server host memory.
The log file is then sent to the baseboard management controller BMC.
Finally, a first interrupt instruction is sent to the BMC to read the target storage space based on the first interrupt instruction to determine to read the file.
The log processing method provided by the invention is characterized in that log data of a system is collected at a server host, the log data is written into a log file, and the log file is stored in a target storage space; the log file is sent to a baseboard management controller BMC through a target storage space; and sending a first interrupt instruction to the BMC, and reading the target storage space to determine a read file. The system log obtained by the server host is sent to the BMC side through the target storage space of the shared memory, other equipment is not required to be occupied, the cost is reduced, and compared with the software implementation of transmitting the log by using a datagram protocol, the system log transmission method and the system log transmission device are simpler in implementation and higher in reliability.
In some embodiments, after storing the log file in the target storage space, the method further includes:
setting the space state of the target storage space to be a busy state;
the sending the log file to the baseboard management controller BMC via the target storage space includes:
And when the space state is a busy state, sending the log file to a Baseboard Management Controller (BMC) through the target storage space.
Specifically, in this embodiment, the spatial state of the BAR is first determined to be a busy state. The log file sent by the server host via the target storage space is then received based on the target communication standard, PCIe.
In some embodiments, the collecting log data of the system, writing the log data into a log file, includes:
determining a value of the log data;
under the condition that the numerical value is larger than a preset threshold value, determining first data and second data, wherein the first data are log data with the numerical value smaller than the preset threshold value, and the second data are log data with the numerical value larger than the preset threshold value;
and modifying the file name of the log file, creating a standby file, writing the first data into the log file, and writing the second data into the standby file.
It should be noted that, the main thread of the server host monitors whether the log file log2BMC is modified for the resident cyclic usage inotify, and wakes up the logPost thread if the log file log2BMC is modified. The inotify interface monitors whether the file is modified or deleted.
The log collecting process writes the log into the log file, the size of the log file, namely the numerical value of the log data is required to be determined, when the log file is overlarge, the log2BMC is changed into log2BMC.1, a log file is newly established, namely the file name of the log file is modified, and a standby file is newly established. And then writing the log data which does not exceed the capacity of the log file into the log file after the renaming, and writing the log data which exceeds the capacity of the log file into the newly-built backup log file.
In some embodiments, further comprising:
monitoring the log file based on a target execution tool, and determining modification information of the log file;
when the modification information is that the file name is modified, waking up a first log publishing thread; and under the condition that the modification information is that the log file is deleted, waking up a second log publishing thread.
It will be appreciated that this embodiment is for two cases of a logPost thread, one is that the inotify detects that the log2BMC is modified and the other is that the inotify detects that the log2BMC is renamed.
Referring to fig. 6, the flow of the log publishing thread on the server host side is as follows:
after the flow starts, the log file log2BMC is opened, the log collection process modifies the log file, and the log file is monitored by using the inotify, and then the log post thread is awakened.
Referring to fig. 7, the flow of the inotify detecting that the file is modified is the first log publishing thread: inotify returns IN-modification; and judging whether the BMC shared memory is in a ready state, if so, calculating the length from the file pointer to the end of the file, and recording the length as len. If not, wait for BAR space READY.
Judging whether len is larger than 996, if yes, organizing the packet header data, setting the BAR space as BUSY, copying the packet header data and 996B log as BMC BAR space, then sending a terminal to BMC, wherein the file pointer is + =996, len- =996, and waiting for the BAR space READY.
If not, organizing the packet header data, setting the BAR space as BUSY, copying the packet header data and the len byte log after the file pointer as BMC BAR space, and sending interrupt to BMC by the file pointer + =len, and then going to sleep.
Referring to fig. 8, the first log publishing thread is a flow in which inotify detects that a file is deleted (renamed):
the inotify returns to IN-DELETE, opens log2BMC.1, calculates the end-of-file length using the log file pointer, and marks as len;
judging whether len is equal to 0, if yes, closing log2BMC.1, and then entering a sleep state. If not, judging whether the BMC shared memory is READY, if so, calculating the length from the file pointer to the end of the file, and marking the length as len. If not, wait for BAR space READY.
Judging whether len is larger than 996, if yes, organizing the packet header data, setting the BAR space as BUSY, copying the packet header data and 996B log as BMC BAR space, then sending a terminal to BMC, wherein the file pointer is + =996, len- =996, and waiting for the BAR space READY.
If not, organizing the packet header data, setting the BAR space as BUSY, copying the packet header data and the len byte log after the file pointer as BMC BAR space, closing log2BMC.1, opening log2BMC, and carrying out the following steps.
The data structure of the header data is as follows:
Figure BDA0004075683030000141
it should be noted that, when the BMC is registered as a PCIe EP device at the HOST end at the time of initialization, the BMC applies for the corresponding BAR space. After writing into the BAR space, the PCIe bus sends the data to the BMC.
The size of the BAR space for log collection is 1024B, and a judgment statement len >996 and 996 in the flow are the size of the BAR space minus the size of the data head and minus the BAR space state mark.
The BAR space status flag is located at the first byte in BAR space, and the remainder, except for the normal state (OFF, ON, WORK, BUSY, READY), is ERROR, whose value indicates a different ERROR.
In some embodiments, the collecting log data of the system, before writing the log data into the log file, further comprises:
And initializing a basic input and output system stage and an output system BIOS stage of the server host.
It will be appreciated that this embodiment is a process of initializing a server host.
The initialization flow of the HOST end of the server can also be divided into a BIOS stage and an OS stage, wherein the BIOS stage mainly enumerates devices and allocates PCIe domain space. The specific flow refers to PCIe protocol.
Referring to fig. 9, the os phase may be divided into a main initialization flow and an initialization flow in the logPost thread, the main initialization flow is as follows:
after the flow starts, the drive device object data structure is allocated, the BAR space is mapped, the cdev device is created, and the logpost thread is created until the flow ends.
Referring to fig. 10, the log post thread initialization flow under host OS is:
after the flow starts, judging whether the BAR space state is ON, if so, changing the BAR space state into WORK, and then circularly processing and sending the log. If not, judging whether the waiting time is overtime, if so, setting an error code by the BAR space state, ending the flow, if not, waiting for sleeping, and returning to judge whether the BAR space state is ON.
Referring to FIG. 11, after initialization of the BMC side and the server host side, a schematic diagram of the BAR space status flags is shown as follows:
In the OFF state, BMC initialization is completed, the state is switched to the ON state, HOST initialization is completed, the state is switched to the WORK state, ERROR is confirmed if overtime, READY is switched to if the BMC receives an interrupt, the change of a HOST-end log file is set to BUSY, READY is set after recording is completed, and ERROR is set if overtime.
Referring to fig. 12, fig. 12 is a schematic diagram of double-ended interaction of a log processing method according to the present invention:
at the HOST end, after the flow is started, a log collecting process places a log into a designated file, and removes the log from the designated file and places the log into a BAR space corresponding to the BMC;
the HOST end sends an interrupt to the BMC;
at the BMC end, after the process is started, taking out the log from the log, and writing the log into a file;
the BMC sends an interrupt to the HOST side.
The log processing device provided by the invention is described below, and the log processing device described below and the log processing method described above can be referred to correspondingly.
Referring to fig. 13, the log processing device provided by the present invention includes, but is not limited to, the following modules:
a first module 1310, configured to receive a first interrupt instruction sent by a server host;
a second module 1320, 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 the target file;
The target storage space is a shared memory obtained by mapping the storage space of the BMC to a memory of a server host.
It should be noted that, in the embodiment of the present invention, the baseboard management controller BMC (Baseboard Management Controller) may perform some operations such as firmware upgrade, checking machine equipment, etc. on the machine in a state that the machine is not powered on. A PCIe path exists between the BMC and the server host, and PCIe (Peripheral Component Interconnect Express) in this embodiment is a high-speed serial computer expansion bus standard.
In the first module 1310, a log file sent by the server HOST via the target storage space is received. The target memory space may be a BAR (Base Address Register) base address register. The BAR space refers to a space on the PCIe bus where a portion of the memory of the BMC is mapped to the memory of the HOST, where data in the space is written to the PCIe port, and the data is visible to the other PCIe port. The BAR space is a shared memory obtained by mapping the memory space of the BMC to the server host memory.
It can be appreciated that the log data generated by the system can be collected into a log file through a log collection process, and can be recorded as a first file, then the log file is sub-packaged into a BAR space, and then the log file is sent to the BMC end through the BAR.
It should be noted that, data transmission between HOST and BMC is based on PCIe, i.e., log files are transmitted from HOST to BMC through PCIe.
In the second module 1320, the log file sent by the server host via the target storage space is received, the log file is read from the target storage space based on the first interrupt instruction, the read file is determined, and the read file is written into the target file.
It should be noted that, in this embodiment, the first interrupt instruction, that is, the instruction for receiving the interrupt log file sent by the server host to the BMC, the BMC reads the log file from the BAR according to the first interrupt instruction, writes the log file into another file, and may be recorded as the second file.
According to the log processing device provided by the invention, the BMC receives the first interrupt instruction sent by the server host, then receives the log file sent by the server host through the target storage space, reads the log file from the target storage space based on the first interrupt instruction, determines the read file and writes the read file into the target file. The system log obtained by the server host is sent to the BMC side through the target storage space of the shared memory, other equipment is not required to be occupied, the cost is reduced, and compared with the software implementation of transmitting the log by using a datagram protocol, the system log transmission method and the system log transmission device are simpler in implementation and higher in reliability.
In some embodiments, the receiving the log file sent by the server host via the target storage space includes:
determining a space state of the target storage space;
and receiving the log file sent by the server host through the target storage space based on the target communication standard under the condition that the space state is a busy state.
It will be appreciated that this embodiment is a specific process of receiving log files sent by a server host via the BAR space.
The spatial state of the BAR is first determined. The spatial states of the BAR include OFF, ON, WORK, BUSY, READY, and the corresponding states are an off state, an on state, a working state, a busy state and a ready state.
When the space state is a busy state, the log file transmitted by the server host via the target storage space is received based on the PCIe, which is a target communication standard.
In some embodiments, after storing the read file in the target file, the method further includes:
and emptying the target storage space and setting the space state to be a ready state.
It can be understood that after the log file in the BAR is sent completely, and the BMC can empty the storage space of the BAR after the BMC finishes reading, so as to facilitate the subsequent continuous storage of the log file, and set the space state to be a ready state so as to facilitate the continuous sending of the log file.
In some embodiments, receiving a log file sent by a server host via a target storage space based on a target communication standard, where the space state is a busy state, comprises:
under the condition that the space state is a busy state, determining that the packet header data and the check value are both correct values, and obtaining a correct checking result;
in conjunction with checking for correct results, log files sent by the server host via the target storage space are received based on the target communication standard.
In some embodiments, further comprising:
and determining the packet head data or the check value as an error value, obtaining an error checking result, starting log alarm based on the error checking result, and setting the space state as a corresponding error code.
It can be appreciated that the above embodiment is a specific process of processing the log command by the BMC side.
After receiving the interrupt of the server host, the BMC wakes up the log handle thread, i.e., the log processing thread, and the rest of the log handle threads.
On the one hand, when the space state is the busy state, the header data mac and checksum check values are both determined to be correct values, and a correct checking result is obtained. And then receiving the log file sent by the BAR according to the correct result, putting the log content into the file, emptying the BAR space, and setting the space state as READY.
On the other hand, when the space state is busy, determining the header data mac or checksum check value as an error value, and obtaining an error checking result. At this time, the sel log alarm function is started, the spatial state of the BAR is set to be the corresponding error code, and then the sleep state is entered.
In some embodiments, before receiving the log file sent by the server host via the target storage space, the method further includes:
creating a shared memory between the BMC and the server host, and determining a shared target storage space;
the target storage space is emptied, and the space state of the target storage space is set to be an open state;
and under the condition that an interrupt is generated in the sleep state of the server, determining that the space state is converted into the working state, and setting the working state into the ready state.
Referring to fig. 14, the log processing device provided by the present invention includes, but is not limited to, the following modules:
a third module 1410, 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 1420, configured to send the log file to a baseboard management controller BMC via the target storage space;
A fifth module 1430 configured to send a first interrupt instruction to the BMC, where the first interrupt instruction is configured to read the target storage space to determine a read file;
the target storage space is a shared memory obtained by mapping the storage space of the BMC to a memory of a server host.
In this embodiment, first, log data of the system is collected, the log data is written into a log file, and the log file is stored in a target storage space. The target memory space may be a BAR (Base Address Register) base address register. The BAR space refers to a space on the PCIe bus where a portion of the memory of the BMC is mapped to the memory of the HOST, where data in the space is written to the PCIe port, and the data is visible to the other PCIe port. The BAR space is a shared memory obtained by mapping the memory space of the BMC to the server host memory.
The log file is then sent to the baseboard management controller BMC.
Finally, a first interrupt instruction is sent to the BMC to read the target storage space based on the first interrupt instruction to determine to read the file.
The log processing device provided by the invention collects the log data of the system at the server host, writes the log data into a log file, and stores the log file in a target storage space; the log file is sent to a baseboard management controller BMC through a target storage space; and sending a first interrupt instruction to the BMC, and reading the target storage space to determine a read file. The system log obtained by the server host is sent to the BMC side through the target storage space of the shared memory, other equipment is not required to be occupied, the cost is reduced, and compared with the software implementation of transmitting the log by using a datagram protocol, the system log transmission method and the system log transmission device are simpler in implementation and higher in reliability.
In some embodiments, after storing the log file in the target storage space, the method further includes:
setting the space state of the target storage space to be a busy state;
the sending the log file to the baseboard management controller BMC via the target storage space includes:
and when the space state is a busy state, sending the log file to a Baseboard Management Controller (BMC) through the target storage space.
Specifically, in this embodiment, the spatial state of the BAR is first determined to be a busy state. The log file sent by the server host via the target storage space is then received based on the target communication standard, PCIe.
In some embodiments, the collecting log data of the system, writing the log data into a log file, includes:
determining a value of the log data;
under the condition that the numerical value is larger than a preset threshold value, determining first data and second data, wherein the first data are log data with the numerical value smaller than the preset threshold value, and the second data are log data with the numerical value larger than the preset threshold value;
and modifying the file name of the log file, creating a standby file, writing the first data into the log file, and writing the second data into the standby file.
It should be noted that, the main thread of the server host monitors whether the log file log2BMC is modified for the resident cyclic usage inotify, and wakes up the logPost thread if the log file log2BMC is modified. The inotify interface monitors whether the file is modified or deleted.
The log collecting process writes the log into the log file, the size of the log file, namely the numerical value of the log data is required to be determined, when the log file is overlarge, the log2BMC is changed into log2BMC.1, a log file is newly established, namely the file name of the log file is modified, and a standby file is newly established. And then writing the log data which does not exceed the capacity of the log file into the log file after the renaming, and writing the log data which exceeds the capacity of the log file into the newly-built backup log file.
In some embodiments, further comprising:
monitoring the log file based on a target execution tool, and determining modification information of the log file;
when the modification information is that the file name is modified, waking up a first log publishing thread; and under the condition that the modification information is that the log file is deleted, waking up a second log publishing thread.
It will be appreciated that this embodiment is for two cases of a logPost thread, one is that the inotify detects that the log2BMC is modified and the other is that the inotify detects that the log2BMC is renamed.
In some embodiments, the collecting log data of the system, before writing the log data into the log file, further comprises:
and initializing a basic input and output system stage and an output system BIOS stage of the server host.
Fig. 15 illustrates a physical structure diagram of an electronic device, as shown in fig. 15, which may include: a processor 1510, a communication interface (Communications Interface) 1520, a memory 1530, and a communication bus 1540, wherein the processor 1510, the communication interface 1520, and the memory 1530 communicate with each other via the communication bus 1540. The processor 1510 may invoke logic instructions in the memory 1530 to perform log processing methods comprising:
receiving a first interrupt instruction sent by a server host;
receiving a log file sent by the server host through 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 the target file;
the target storage space is a shared memory obtained by mapping the storage space of the BMC to a memory of a server host;
Or alternatively, the first and second heat exchangers may be,
collecting log data of a system, writing the log data into a log file, and storing the log file in a target storage space;
the log file is sent to a baseboard management controller BMC through a target storage space;
sending a first interrupt instruction to the BMC, wherein the first interrupt instruction is used for reading the target storage space to determine a read file;
the target storage space is a shared memory obtained by mapping the storage space of the BMC to a memory of a server host.
Further, the logic instructions in the memory 1530 described above may be implemented in the form of software functional units and may be stored on a computer readable storage medium when sold or used as a stand alone product. Based on this understanding, the technical solution of the present invention may be embodied essentially or in a part contributing to the prior art or in a part of the technical solution, in the form of a software product stored in a storage medium, comprising several instructions for causing a computer device (which may be a personal computer, a server, a network device, etc.) to perform all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a random access Memory (RAM, random Access Memory), a magnetic disk, or an optical disk, or other various media capable of storing program codes.
In another aspect, the present invention also provides a computer program product, the computer program product comprising a computer program, the computer program being storable on a non-transitory computer readable storage medium, the computer program, when executed by a processor, being capable of performing the log processing method provided by the above methods, the method comprising:
receiving a first interrupt instruction sent by a server host;
receiving a log file sent by the server host through 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 the target file;
the target storage space is a shared memory obtained by mapping the storage space of the BMC to a memory of a server host;
or alternatively, the first and second heat exchangers may be,
collecting log data of a system, writing the log data into a log file, and storing the log file in a target storage space;
the log file is sent to a baseboard management controller BMC through a target storage space;
sending a first interrupt instruction to the BMC, wherein the first interrupt instruction is used for reading the target storage space to determine a read file;
The target storage space is a shared memory obtained by mapping the storage space of the BMC to a memory of a server host.
In yet another aspect, the present invention also provides a non-transitory computer readable storage medium having stored thereon a computer program which, when executed by a processor, is implemented to perform the log processing method provided by the above methods, the method comprising:
receiving a first interrupt instruction sent by a server host;
receiving a log file sent by the server host through 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 the target file;
the target storage space is a shared memory obtained by mapping the storage space of the BMC to a memory of a server host;
or alternatively, the first and second heat exchangers may be,
collecting log data of a system, writing the log data into a log file, and storing the log file in a target storage space;
the log file is sent to a baseboard management controller BMC through a target storage space;
sending a first interrupt instruction to the BMC, wherein the first interrupt instruction is used for reading the target storage space to determine a read file;
The target storage space is a shared memory obtained by mapping the storage space of the BMC to a memory of a server host.
The apparatus embodiments described above are merely illustrative, wherein the elements illustrated as separate elements may or may not be physically separate, and the elements shown as elements may or may not be physical elements, may be located in one place, or may be distributed over a plurality of network elements. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment. Those of ordinary skill in the art will understand and implement the present invention without undue burden.
From the above description of the embodiments, it will be apparent to those skilled in the art that the embodiments may be implemented by means of software plus necessary general hardware platforms, or of course may be implemented by means of hardware. Based on this understanding, the foregoing technical solution may be embodied essentially or in a part contributing to the prior art in the form of a software product, which may be stored in a computer readable storage medium, such as ROM/RAM, a magnetic disk, an optical disk, etc., including several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute the method described in the respective embodiments or some parts of the embodiments.
Finally, it should be noted that: the above embodiments are only for illustrating the technical solution of the present invention, and are not limiting; although the invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical scheme described in the foregoing embodiments can be modified or some technical features thereof can be replaced by equivalents; such modifications and substitutions do not depart from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims (15)

1. The log processing method is characterized by being applied to a Baseboard Management Controller (BMC), and comprising the following steps of:
receiving a first interrupt instruction sent by a server host;
receiving a log file sent by the server host through 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 the target file;
the target storage space is a shared memory obtained by mapping the storage space of the BMC to a memory of a server host.
2. The log processing method as set forth in claim 1, wherein the receiving the log file transmitted by the server host via the target storage space comprises:
Determining a space state of the target storage space;
and receiving the log file sent by the server host through the target storage space based on the target communication standard under the condition that the space state is a busy state.
3. The log processing method as defined in claim 2, wherein after storing the read file in the target file, further comprising:
and emptying the target storage space and setting the space state to be a ready state.
4. The log processing method according to claim 2, wherein, in the case where the space state is a busy state, receiving the log file transmitted by the server host via the target storage space based on the target communication standard, comprises:
under the condition that the space state is a busy state, determining that the packet header data and the check value are both correct values, and obtaining a correct checking result;
in conjunction with checking for correct results, log files sent by the server host via the target storage space are received based on the target communication standard.
5. The log processing method as defined in claim 4, further comprising:
and determining the packet head data or the check value as an error value, obtaining an error checking result, starting log alarm based on the error checking result, and setting the space state as a corresponding error code.
6. The log processing method as set forth in claim 2, wherein before receiving the log file transmitted by the server host via the target storage space, further comprising:
creating a shared memory between the BMC and the server host, and determining a shared target storage space;
the target storage space is emptied, and the space state of the target storage space is set to be an open state;
and under the condition that an interrupt is generated in the sleep state of the server, determining that the space state is converted into the working state, and setting the working state into the ready state.
7. A log processing method, applied to a server host, comprising:
collecting log data of a system, writing the log data into a log file, and storing the log file in a target storage space;
the log file is sent to a baseboard management controller BMC through the target storage space;
sending a first interrupt instruction to the BMC, wherein the first interrupt instruction is used for reading the target storage space to determine a read file;
the target storage space is a shared memory obtained by mapping the storage space of the BMC to a memory of a server host.
8. The method of claim 7, wherein after storing the log file in the target storage space, further comprising:
setting the space state of the target storage space to be a busy state;
the sending the log file to the baseboard management controller BMC via the target storage space includes:
and when the space state is a busy state, sending the log file to a Baseboard Management Controller (BMC) through the target storage space.
9. The log processing method as defined in claim 7, wherein the collecting log data of the system, writing the log data into a log file, comprises:
determining a value of the log data;
under the condition that the numerical value is larger than a preset threshold value, determining first data and second data, wherein the first data are log data with the numerical value smaller than the preset threshold value, and the second data are log data with the numerical value larger than the preset threshold value;
and modifying the file name of the log file, creating a standby file, writing the first data into the log file, and writing the second data into the standby file.
10. The log processing method as defined in claim 9, further comprising:
monitoring the log file based on a target execution tool, and determining modification information of the log file;
when the modification information is that the file name is modified, waking up a first log publishing thread; and under the condition that the modification information is that the log file is deleted, waking up a second log publishing thread.
11. The log processing method as defined in claim 7, wherein the collecting log data of the system, before writing the log data into the log file, further comprises:
and initializing a basic input and output system stage and an output system BIOS stage of the server host.
12. A log processing device, applied to a baseboard management controller BMC, comprising:
the first module is used for receiving a first interrupt instruction sent by the server host;
the second module is used for receiving the log file sent by the server host through the 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 the target file;
The target storage space is a shared memory obtained by mapping the storage space of the BMC to a memory of a server host.
13. A log processing apparatus, for use with a server host, comprising:
the third module is used for collecting log data of the system, writing the log data into a log file and storing 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, where the first interrupt instruction is used to read the target storage space to determine a read file;
the target storage space is a shared memory obtained by mapping the storage space of the BMC to a memory of a server host.
14. 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 to 6 or the log processing method according to any one of claims 7 to 11 when executing the program.
15. A non-transitory computer readable storage medium having stored thereon a computer program, wherein the computer program when executed by a processor implements the log processing method of any of claims 1 to 6 or implements the log processing method of any of claims 7 to 11.
CN202310101062.0A 2023-02-10 2023-02-10 Log processing method and device, electronic equipment and storage medium Pending CN116185978A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310101062.0A CN116185978A (en) 2023-02-10 2023-02-10 Log processing method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310101062.0A CN116185978A (en) 2023-02-10 2023-02-10 Log processing method and device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN116185978A true CN116185978A (en) 2023-05-30

Family

ID=86436050

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310101062.0A Pending CN116185978A (en) 2023-02-10 2023-02-10 Log processing method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN116185978A (en)

Similar Documents

Publication Publication Date Title
JP4199322B2 (en) Information processing apparatus and error collection method for information processing apparatus
JP2013134518A (en) External output device, log collecting method for external output device, and program
WO2016127600A1 (en) Exception handling method and apparatus
CN105264511A (en) Systems and methods for host detection of usb asynchronous notification capability
CN111240879B (en) SAS card firmware log collection method, system, device and storage medium
US20140115112A1 (en) Server system and message processing method thereof
EP3072049B1 (en) Indicating rebuild state of storage devices
JP2002259065A (en) Storage system provided with trace information collecting mechanism
JP2010160660A (en) Network interface, computer system, operation method therefor, and program
CN117971752A (en) Bus equipment hot plug control method and device and readable storage medium
CN116185978A (en) Log processing method and device, electronic equipment and storage medium
CN110609762B (en) Method and device for preventing advanced high performance bus (AHB) from deadlock
CN116974818A (en) System, method, equipment and medium with module state recovery function
JP2004102395A (en) Method for acquiring memory dump data and information processor and its program
CN115934616A (en) Serial port information storage method and device, server, electronic equipment and storage medium
US9348704B2 (en) Electronic storage system utilizing a predetermined flag for subsequent processing of each predetermined portion of data requested to be stored in the storage system
JPH10271113A (en) Fault tracing method and fault tracing device for realizing the method
JP5287938B2 (en) Device control system and program
CN113900890B (en) Method, device, equipment and medium for collecting server component information
CN111061597B (en) Method for testing KCS communication stability
CN113722142B (en) Method and device for analyzing reasons of insufficient memory, electronic equipment and storage medium
JP4140750B2 (en) IC card memory access control method and apparatus, and program storage medium
CN102110062A (en) Memory data storage method and device
CN109120422B (en) Remote server system capable of obtaining hardware information and management method thereof
CN113824651B (en) Market data caching method and device, storage medium and electronic equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination