A method and system for remotely controlling T-BOX system log
By using the cloud server to control the log output level and storage mechanism in the T-BOX system, the problem of traditional system logs occupying excessive resources is solved, efficient storage and processing of log information is achieved, and system stability and utilization are improved.
Patent Information
- Application Number
- CN202210126369.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-02-10
- Publication Date
- 2024-09-24
- Estimated Expiration
- 2042-02-10
AI Technical Summary
The traditional T-BOX system log contains too much information, takes up a lot of system resources, has low utilization rate, and lacks alarm and processing mechanisms, which may cause the system to crash.
Send control commands through the cloud server to parse and output the T-BOX system logs into multiple levels, store them in multiple folders, calculate and analyze the memory usage, save abnormal folders and alarm when the threshold is exceeded, compress backups and delete old logs , uploaded to the cloud server regularly.
It improves the utilization and storage efficiency of log information, enhances system stability, and facilitates centralized inspection and processing of abnormal logs.
Smart Images

Figure CN114546764B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of control, and in particular to a method and system for remotely controlling a T-BOX system log. Background Art
[0002] As the core device of the Internet of Vehicles, T-BOX (intelligent vehicle terminal equipment) carries many functions, including remote control of vehicles, big data reporting, high-precision positioning, etc. Therefore, the software complexity of T-BOX is very high. It takes 2-3 years for a T-BOX product to go from R&D to mass production, and during this period, continuous software iteration is required to make its functions stable.
[0003] Although most of the problems with T-BOX can be found in the R&D stage or bench test stage, some problems cannot be found in the R&D stage or bench test stage. These problems will only be exposed in the real vehicle environment and after the vehicle has been running for a long time. During the use of the vehicle, once a problem occurs with T-BOX, the T-BOX system log is usually exported on-site to the T-BOX R&D team for location analysis, to determine the solution, and finally to fix the problem with T-BOX through software upgrades. At this time, the log information is crucial for the problem analysis and repair of T-BOX software.
[0004] Traditional T-BOX system logs are divided into SOC logs and MCU logs by module. The log information of these two modules is usually output in a fixed format and the storage path and capacity of the log information are relatively fixed. The disadvantage of this method is that the amount of log information is too much, which occupies the operating resources of the T-BOX system, the utilization rate of information is low, and it is difficult to control the log output. When the log information occupies a large capacity of the T-BOX system, there is no alarm and processing mechanism, which may cause the risk of the entire T-BOX system crashing. Summary of the invention
[0005] The technical problem to be solved by the present invention is to overcome the defects of the prior art. The present invention proposes a method and system for remotely controlling a T-BOX system log.
[0006] In order to solve the above technical problems, the technical solution adopted by the present invention is: a method for remotely controlling TBOX system logs, comprising:
[0007] S1: The cloud server parses the system log generated by the T-BOX system by sending a set control command and outputs it into multiple levels of system logs, and stores them in multiple parent folders of the T-BOX system storage unit respectively, wherein the multiple levels of system logs at least include LOG_ERROR logs;
[0008] S2: Calculate and analyze by a preset recognition method whether the total memory usage value of the system logs of the same level output within a set time exceeds a set threshold value. If it exceeds the threshold value, the system logs of the same level output within the set time are saved in a sub-abnormal folder of the same parent folder, and the T-BOX system sends an alarm to the cloud server;
[0009] S3: When the memory of a single parent folder reaches a preset memory value, the system logs and child abnormal folders in the parent folder are compressed into a log compression package and backed up to the parent folder, and all system logs and child abnormal folders in the parent folder are deleted;
[0010] S4: When the file occupancy value in the T-BOX system storage unit reaches a preset upper limit, all the multiple parent files in the T-BOX system storage unit are compressed and uploaded to the cloud server, and the cloud server alarms to remind personnel. When the upload to the cloud server is successful, the system logs, sub-abnormal folders and log compression packages in the parent files in the T-BOX system storage unit are all deleted.
[0011] Furthermore, it also includes setting a scheduled time, compressing and uploading all the multiple parent folders of the T-BOX system storage unit to the cloud server at every scheduled time, and deleting all the system logs and log compression packages of the parent folders in the T-BOX system storage unit.
[0012] Furthermore, the preset identification method includes using a stat function of a Linux system to perform real-time identification and output each memory occupancy value of the system logs of the multiple levels.
[0013] Furthermore, the set control command includes the T-BOX system and the server based on the MQTT communication protocol, and issuing a data protocol command in JSON format, and the data protocol command in JSON format includes {"TBOXSN":"XXX","CtlType":"LogGrade","TypeNum":"X","TYPE1":"LOG_ERROR"......}, wherein "TBOXSN":"XXX" represents the product serial number of T-BOX, "CtlType":"LogGrade" represents the control log level output, "TypeNum":"X" represents the number of control log level outputs, X ranges from 1 to 4, and "TYPE1":"LOG_ERROR" represents the type of level.
[0014] Furthermore, the multiple levels of system logs also include LOG_WARNING log, LOG_TRACE log, and LOG_DEBUG log.
[0015] Furthermore, when the T-BOX system does not receive the set control command, all system logs are output as system logs of the same level, and all system logs are stored in the same parent folder, wherein the system logs of the same level are LOG_ERROR logs.
[0016] A system for remotely controlling a T-BOX system log, comprising:
[0017] Network communication unit, used to establish network connection with the server side and maintain communication between the T-BOX system and the cloud server;
[0018] The status feedback unit is used to feedback the results of the T-BOX system executing the remote log control command;
[0019] A command receiving unit, used to receive the remote control system log command issued by the cloud server;
[0020] The command parsing unit calls the JSON-C library to parse the corresponding remote control log command;
[0021] The inter-process communication unit is used for communication between network communication processes and log processing processes based on message queues;
[0022] Log control output unit, used to output log information in level format;
[0023] A log file storage unit, used to manage the storage of log information;
[0024] Log file compression unit, used for compressed backup of log files to reduce memory usage;
[0025] Log file upload unit, based on FTP protocol, used to remotely export corresponding log information;
[0026] The log file clearing unit is used to clear invalid log information in the T-BOX system.
[0027] Compared with the prior art, the beneficial effects of the present invention include: remote control of log information output according to log level, remote control of log information storage path, backup, cleaning and remote uploading of log information; the method and system can improve the utilization rate of T-BOX system log information, improve the efficiency of T-BOX system log information storage and extraction, improve the stability of the T-BOX system, and save abnormal logs to a new folder in real time, which is convenient for personnel to centrally check and process. BRIEF DESCRIPTION OF THE DRAWINGS
[0028] The disclosure of the present invention is described with reference to the accompanying drawings. It should be understood that the drawings are for illustrative purposes only and are not intended to limit the scope of protection of the present invention. In the accompanying drawings, the same reference numerals are used to refer to the same components. Among them:
[0029] Figure 1 A schematic diagram of an overall architecture proposed according to an embodiment of the present invention is shown;
[0030] Figure 2 A schematic diagram of a process flow of controlling the log level of a system according to an embodiment of the present invention is shown;
[0031] Figure 3 A schematic diagram of a process flow of remote control log storage proposed according to an embodiment of the present invention is shown;
[0032] Figure 4 The flowchart of the remote transmission and uploading of system logs proposed in accordance with an embodiment of the present invention is schematically shown. DETAILED DESCRIPTION
[0033] It is easy to understand that according to the technical solution of the present invention, without changing the essential spirit of the present invention, a person skilled in the art can propose a variety of interchangeable structural modes and implementation modes. Therefore, the following specific implementation modes and drawings are only exemplary descriptions of the technical solution of the present invention, and should not be regarded as the whole of the present invention or as a limitation or restriction to the technical solution of the present invention.
[0034] According to the embodiment of the present invention, Figure 1 A method for remotely controlling a T-BOX system log includes:
[0035] S1: The cloud server parses the system log generated by the T-BOX system by sending a set control command and outputs it into multiple levels of system logs, and stores them in multiple parent folders of the T-BOX system storage unit respectively, wherein the multiple levels of system logs at least include LOG_ERROR logs;
[0036] S2: Calculate and analyze by a preset recognition method whether the total memory usage value of the system logs of the same level output within a set time exceeds a set threshold value. If it exceeds the threshold value, the system logs of the same level output within the set time are saved in a sub-abnormal folder of the same parent folder, and the T-BOX system sends an alarm to the cloud server;
[0037] S3: When the memory of a single parent folder reaches a preset memory value, the system logs and child abnormal folders in the parent folder are compressed into a log compression package and backed up to the parent folder, and all system logs and child abnormal folders in the parent folder are deleted;
[0038] S4: When the file occupancy value in the T-BOX system storage unit reaches a preset upper limit, all the multiple parent files in the T-BOX system storage unit are compressed and uploaded to the cloud server, and the cloud server alarms to remind personnel. When the upload to the cloud server is successful, the system logs, sub-abnormal folders and log compression packages in the parent files in the T-BOX system storage unit are all deleted.
[0039] A method for remotely controlling a T-BOX system log, the method is applied to a T-BOX, the T-BOX as a client having a network communication module and a log information processing module, the method comprising:
[0040] The T-BOX system log information output levels are mainly divided into four levels: LOG_ERROR, LOG_WARNING, LOG_TRACE, and LOG_DEBUG. By default, the TBOX system only outputs LOG_ERROR level information.
[0041] The T-BOX system and the cloud server are based on the MQTT communication protocol. The MQTT cloud server sends commands to control the T-BOX system to output log level information.
[0042] After the network communication module in the T-BOX system receives the control log command issued by the cloud server, it sends it to the log processing module through inter-process communication.
[0043] After receiving the control command of the log information output level, the log processing module in the T-BOX system outputs the corresponding log information according to the command.
[0044] After the log processing module in the T-BOX system receives the control command of the log information storage path and size, it saves the log information to the set path according to the command. For example, if the total memory of the output LOG_ERROR log exceeds 20M within ten minutes, it proves that there is a big problem with the T-BOX system. At this time, the T-BOX system will alarm, so that the personnel on the remote cloud server will know that there is a problem with the T-BOX system. At this time, the LOG_ERROR log of the previous ten minutes is saved in a separate sub-abnormal folder. It is convenient to handle problems in a centralized manner. When a single parent folder occupies a certain amount of memory, the files in the parent folder are compressed into a log compression package and stored in the parent folder. Then the sub-abnormal folder and system log in the parent folder are deleted, leaving only the log compression package.
[0045] When the storage unit memory of the T-BOX system is relatively full, for example, when the real-time files occupy more than 70% of the total storage unit, all files are compressed and uploaded to the cloud server, and the cloud server alarms to remind personnel. When the upload to the cloud server is successful, the system logs, sub-abnormal files, and daily compressed packages in the storage unit of the T-BOX system are all deleted.
[0046] Specifically, Figure 4 As shown, it also includes setting a predetermined time, compressing and uploading all the multiple parent folders of the T-BOX system storage unit to the cloud server at the predetermined time, and deleting all the system logs, child abnormal folders and log compression packages of the parent folders in the T-BOX system storage unit. Uploading logs regularly is convenient for personnel to check logs regularly, and it also ensures the security of logs. Some programs may have fewer logs during operation. If they are not uploaded regularly, in the event of an accident, key messages may be missed, resulting in greater threats.
[0047] Specifically, Figure 3 As shown, the preset identification method includes using the stat function of the Linux system to perform real-time identification and output the memory usage values of the system logs of the multiple levels. The stat function prior art can identify the memory usage value of the system log, and a specific implementation method is provided.
[0048] Specifically, Figure 2 As shown, the control command set includes the T-BOX system and the server based on the MQTT communication protocol, and sends a data protocol command in JSON format, and the data protocol command in JSON format includes {"TBOXSN":"XXX","CtlType":"LogGrade","TypeNum":"X","TYPE1":"LOG_ERROR"......}, where "TBOXSN":"XXX" represents the product serial number of T-BOX, "CtlType":"LogGrade" represents the control log level output, "TypeNum":"X" represents the number of control log level outputs, X ranges from 1 to 4, and "TYPE1":"LOG_ERROR" represents the type of level. Set a specific control command, and this embodiment is preferred here.
[0049] Specifically, Figure 2 As shown, the system logs of the multiple levels also include LOG_WARNING log, LOG_TRACE log, and LOG_DEBUG log. Generally, they are divided into four types, which is convenient for people to find real-time records more accurately.
[0050] Specifically, Figure 2As shown, when the T-BOX system does not receive the set control command, all system logs are output according to the system logs of the same level, and all system logs are stored in the same parent folder, wherein the system logs of the same level are LOG_ERROR logs. When no remote control is received, all log information is output according to the same level, and then according to the above classification, it is also convenient to automatically manage logs. A new implementation method is provided.
[0051] A system for remotely controlling a T-BOX system log, comprising:
[0052] Network communication unit, used to establish network connection with the server side and maintain communication between the T-BOX system and the cloud server;
[0053] The status feedback unit is used to feedback the results of the T-BOX system executing the remote log control command;
[0054] A command receiving unit, used to receive the remote control system log command issued by the cloud server;
[0055] The command parsing unit calls the JSON-C library to parse the corresponding remote control log command;
[0056] The inter-process communication unit is used for communication between network communication processes and log processing processes based on message queues;
[0057] Log control output unit, used to output log information in level format;
[0058] A log file storage unit, used to manage the storage of log information;
[0059] Log file compression unit, used for compressed backup of log files to reduce memory usage;
[0060] Log file upload unit, based on FTP protocol, used to remotely export corresponding log information;
[0061] The log file clearing unit is used to clear invalid log information in the T-BOX system. The MQTT server sends a command to remotely control the T-BOX log information, and the network communication module of the T-BOX system receives and parses the remote control command, and then transmits the log control parameters to the log processing module through inter-process communication, and finally the log processing module performs corresponding processing according to the corresponding control parameters. The MQTT server sends a command to remotely control the output level of the T-BOX log information, and the T-BOX system log outputs according to the corresponding log level; the MQTT cloud server sends a command to remotely control the storage path and size of the T-BOX log information, and the T-BOX system log stores and backs up the corresponding path data; the MQTT cloud server sends a command to remotely control the upload of the T-BOX log information, and the T-BOX system log uploads the log information to the specified ftp server according to the time period. Therefore, the present invention realizes the remote control of the T-BOX system log, which is not only simple to operate, but also greatly improves the utilization rate of the log information, which is conducive to the T-BOX developers to quickly analyze and locate the problem.
[0062] In the present embodiment, a method for remotely controlling a T-BOX system log is applied to T-BOX. T-BOX as a client has a network communication module and a log information processing module. The method includes: through the {"TBOXSN":"XXX","CtlType":"LogGrade","TypeNum":"X","TYPE1":"LOG_ERROR"......} data protocol, the T-BOX system log information output level is mainly divided into four levels: LOG_ERROR, LOG_WARNING, LOG_TRACE, and LOG_DEBUG. The TBOX system only outputs LOG_ERROR level information by default.
[0063] T-BOX and the server communicate based on the MQTT protocol. The MQTT cloud server sends commands to control the T-BOX system to output log level information.
[0064] After the network communication module in the T-BOX system receives the control log command issued by the cloud server, it sends it to the log processing module through inter-process communication.
[0065] After receiving the control command of the log information output level, the log processing module in the T-BOX system outputs the corresponding log information according to the command.
[0066] After the log processing module in the T-BOX system receives the control command of the log information storage path and size, it saves the log information to the set path according to the command. For example, if the total memory of the output LOG_ERROR log exceeds 20M within ten minutes, it proves that there is a big problem with the T-BOX system. At this time, the T-BOX system will alarm, so that the personnel on the remote cloud server will know that there is a problem with the T-BOX system. At this time, the LOG_ERROR log of the previous ten minutes is saved in a separate sub-abnormal folder. It is convenient to handle problems in a centralized manner. When a single parent folder occupies a certain amount of memory, the files in the parent folder are compressed into a log compression package and stored in the parent folder. Then the sub-abnormal folder and system log in the parent folder are deleted, leaving only the log compression package.
[0067] When the storage unit memory of the T-BOX system is relatively full, for example, when the real-time files occupy more than 70% of the total storage unit, all files are compressed and uploaded to the cloud server, and the cloud server alarms to remind personnel. When the upload to the cloud server is successful, the system logs, sub-abnormal files, and daily compressed packages in the storage unit of the T-BOX system are all deleted.
[0068] A second embodiment is also provided. When no external remote control is received, the system log is no longer graded, but abnormal logs are still automatically identified, so that the logs are stably saved and uploaded, and very little memory is occupied.
[0069] The technical scope of the present invention is not limited to the contents in the above description. Those skilled in the art can make various deformations and modifications to the above embodiments without departing from the technical idea of the present invention, and these deformations and modifications should all fall within the protection scope of the present invention.
Claims
1. A method for remotely controlling T-BOX system logs, characterized in that: include: S1: The cloud server parses the system log generated by the T-BOX system by sending a set control command and outputs it into multiple levels of system logs, and stores them in multiple parent folders of the T-BOX system storage unit respectively, wherein the multiple levels of system logs at least include LOG_ERROR logs; The set control command includes that the T-BOX system and the server are based on the MQTT communication protocol, and issue a data protocol command in JSON format, and the data protocol command in JSON format includes {"TBOXSN":"XXX","CtlType":"LogGrade","TypeNum":"X","TYPE1":"LOG_ERROR"......}, wherein "TBOXSN":"XXX" represents the product serial number of T-BOX, "CtlType":"LogGrade" represents the control log level output, "TypeNum":"X" represents the number of control log level outputs, X ranges from 1 to 4, and "TYPE1":"LOG_ERROR" represents the type of level; S2: Calculate and analyze by a preset recognition method whether the total memory usage value of the system logs of the same level output within a set time exceeds a set threshold value. If it exceeds the threshold value, the system logs of the same level output within the set time are saved in a sub-abnormal folder of the same parent folder, and the T-BOX system sends an alarm to the cloud server; S3: When the memory of a single parent folder reaches a preset memory value, the system logs and child abnormal folders in the parent folder are compressed into a log compression package and backed up to the parent folder, and all system logs and child abnormal folders in the parent folder are deleted; S4: When the file occupancy value in the T-BOX system storage unit reaches a preset upper limit, all the multiple parent files in the T-BOX system storage unit are compressed and uploaded to the cloud server, and the cloud server alarms to remind personnel. When the upload to the cloud server is successful, the system logs, sub-abnormal folders and log compression packages in the parent files in the T-BOX system storage unit are all deleted.
2. A method for remotely controlling a T-BOX system log according to claim 1, characterized in that: It also includes setting a scheduled time, compressing and uploading all the multiple parent folders of the T-BOX system storage unit to the cloud server at every scheduled time, and deleting all the system logs, sub-abnormal folders, and log compression packages of the parent folders in the T-BOX system storage unit.
3. A method for remotely controlling a T-BOX system log according to claim 1, characterized in that: The preset identification method includes using the stat function of the Linux system to perform real-time identification and output each memory occupancy value of the system logs of the multiple levels.
4. A method for remotely controlling a T-BOX system log according to claim 1, characterized in that: The multiple levels of system logs also include LOG_WARNING log, LOG_TRACE log, and LOG_DEBUG log.
5. A method for remotely controlling a T-BOX system log according to claim 1, characterized in that: When the T-BOX system does not receive the set control command, all system logs are output as system logs of the same level and stored in the same parent folder, wherein the system logs of the same level are LOG_ERROR logs.
6. A system for remotely controlling a T-BOX system log, using a method for remotely controlling a T-BOX system log as claimed in any one of claims 1 to 5, characterized in that: include: Network communication unit, used to establish network connection with the server side and maintain communication between the T-BOX system and the cloud server; The status feedback unit is used to feedback the results of the T-BOX system executing the remote log control command; A command receiving unit, used to receive the remote control system log command issued by the cloud server; The command parsing unit calls the JSON-C library to parse the corresponding remote control log command; The inter-process communication unit is used for communication between network communication processes and log processing processes based on message queues; Log control output unit, used to output log information in level format; A log file storage unit, used to manage the storage of log information; Log file compression unit, used for compressed backup of log files to reduce memory usage; Log file upload unit, based on FTP protocol, used to remotely export corresponding log information; The log file clearing unit is used to clear invalid log information in the T-BOX system.
