Database state monitoring method and device, electronic equipment and storage medium

By receiving database status monitoring requests, determining whether the application uses the Sqlite database and hooking the log information of the database interface function, the problem that the existing technology cannot monitor the status of the Sqlite database is solved, and the stability and robustness of the application are improved.

CN119415355APending Publication Date: 2025-02-11厦门天锐科技股份有限公司
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411451941.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-17
Publication Date
2025-02-11

AI Technical Summary

Technical Problem

The existing technology cannot accurately obtain the status of the Sqlite database, which causes the application to be unable to effectively monitor database performance and troubleshoot errors during the development process, affecting the continuous and stable development of the application.

Method used

By receiving a database status monitoring request, we determine whether the target application uses the target database, determine the target database interface function based on the fuzzy matching rules, and hook its log information to analyze the database status.

Benefits of technology

When the database interface is not open, it can monitor the database status of the unopened interface in the application to improve the robustness and stability of the application.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119415355A_ABST
    Figure CN119415355A_ABST
Patent Text Reader

Abstract

The invention provides a database state monitoring method and device, electronic equipment and a storage medium, and relates to the technical field of computers. The method comprises the following steps: receiving a monitoring request of a database state, wherein the monitoring request carries a target application program and a target database; obtaining a link library calling relation and a read-only data section of the target application program, and judging whether the target database is used by the target application program or not according to the link library calling relation and the read-only data section of the target application program; according to the fact that the target application program uses the target database and does not open a database interface of the target database, determining a target database interface function based on a fuzzy matching rule corresponding to the target database; the log information of the target database interface function is hooked, and the database state of the target database is obtained through analysis according to the log information. According to the method, the database state of the unopened interface in the application program can be monitored, the application program is improved in time, and the robustness and stability of the application program can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a database status monitoring method, device, electronic device and storage medium. Background Art

[0002] With the development of information technology, many applications use various databases to store information. Sqlite database is widely used as an open source database. In the development and use of databases, it is essential to analyze database performance and troubleshoot database errors.

[0003] With the widespread use of Sqlite database, if users need to analyze and monitor the status of Sqlite database in the application during the development of program business, or if users want to call and analyze the unopened database interface in the application, they are powerless. Therefore, users cannot accurately obtain the status of the database based on the existing technology, which is not conducive to the continuous and stable development of the application. Summary of the invention

[0004] The purpose of the present application is to provide a database status monitoring method, device, electronic device and storage medium, which can monitor the status of a database whose interface is not open in an application.

[0005] In a first aspect, an embodiment of the present application provides a database status monitoring method, including:

[0006] receiving a monitoring request for a database status, wherein the monitoring request carries a target application and a target database;

[0007] Obtaining and judging whether the target application uses the target database according to the link library call relationship and the read-only data section of the target application;

[0008] According to the target application using the target database and not opening the database interface of the target database, determining the target database interface function based on the fuzzy matching rule corresponding to the target database;

[0009] The log information of the target database interface function is hooked, and the database status of the target database is obtained according to the analysis of the log information.

[0010] In a possible implementation, judging whether the target application uses the target database according to the link library call relationship and the read-only data section of the target application includes:

[0011] Determining whether the target application has loaded the link library associated with the target database according to the link library calling relationship of the target application;

[0012] If the target application has loaded a link library related to the target database and a preset number of string features that are fixed and existent in the target database are matched in the read-only data section of the target application, it is determined that the target application uses the target database; otherwise, it is determined that the target application does not use the target database.

[0013] In a possible implementation, the preset number is greater than or equal to 2.

[0014] In a possible implementation, the fuzzy matching rule includes:

[0015] Based on the fact that the number of function parameters is within the preset range and the parameter type is a pointer, the suspected database interface functions are preliminarily screened out;

[0016] According to the syntax features of the database execution statement contained in the pointer parameter and the return value of the suspected database interface function, the suspected database interface function is determined to be the target database interface function.

[0017] In a second aspect, an embodiment of the present application provides a database status monitoring device, including:

[0018] A receiving module, configured to receive a monitoring request for a database status, wherein the monitoring request carries a target application and a target database;

[0019] A determination module, used for obtaining and determining whether the target application uses the target database according to the link library call relationship and the read-only data section of the target application;

[0020] A matching module, used to determine the target database interface function based on the fuzzy matching rule corresponding to the target database according to the fact that the target application uses the target database and the database interface of the target database is not open;

[0021] The hooking module is used to hook the log information of the target database interface function and obtain the database status of the target database according to the log information analysis.

[0022] In a possible implementation, the judgment module is specifically used to:

[0023] Determining whether the target application has loaded the link library associated with the target database according to the link library calling relationship of the target application;

[0024] If the target application has loaded a link library related to the target database and a preset number of string features that are fixed and existent in the target database are matched in the read-only data section of the target application, it is determined that the target application uses the target database; otherwise, it is determined that the target application does not use the target database.

[0025] In a possible implementation, the preset number is greater than or equal to 2.

[0026] In a possible implementation, the fuzzy matching rule includes:

[0027] Based on the fact that the number of function parameters is within the preset range and the parameter type is a pointer, the suspected database interface functions are preliminarily screened out;

[0028] According to the syntax features of the database execution statement contained in the pointer parameter and the return value of the suspected database interface function, the suspected database interface function is determined to be the target database interface function.

[0029] In a third aspect, the present application provides an electronic device, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the method described in the first aspect.

[0030] In a fourth aspect, the present application provides a computer-readable storage medium having computer-readable instructions stored thereon, wherein the computer-readable instructions can be executed by a processor to implement the method as described in the first aspect.

[0031] Compared with the prior art, the database status monitoring method provided by the present application receives a monitoring request for the database status, wherein the monitoring request carries a target application and a target database; obtains and determines whether the target application uses the target database based on the link library call relationship and the read-only data segment of the target application; determines the target database interface function based on the fuzzy matching rule corresponding to the target database according to the fact that the target application uses the target database and the database interface of the target database is not open; hooks the log information of the target database interface function, and obtains the database status of the target database based on the analysis of the log information. Compared with the prior art, the present application can hook the log information of the database interface function based on the hook library when the database interface is not open, so that the database status of the unopened interface in the application can be monitored based on the log information, and the application can be improved in time, which can improve the robustness and stability of the application. BRIEF DESCRIPTION OF THE DRAWINGS

[0032] Various other advantages and benefits will become apparent to those of ordinary skill in the art by reading the detailed description of the preferred embodiments below. The accompanying drawings are only for the purpose of illustrating the preferred embodiments and are not to be considered as limiting the present application. Also, the same reference symbols are used throughout the accompanying drawings to represent the same components. In the accompanying drawings:

[0033] Figure 1 A flowchart of a database status monitoring method provided by an embodiment of the present application is shown;

[0034] Figure 2 A flowchart of a specific database status monitoring method provided by an embodiment of the present application is shown;

[0035] Figure 3 A schematic diagram of a database status monitoring device provided in an embodiment of the present application is shown;

[0036] Figure 4 A schematic diagram of an electronic device provided in an embodiment of the present application is shown. DETAILED DESCRIPTION

[0037] The exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments described herein. On the contrary, these embodiments are provided in order to enable a more thorough understanding of the present disclosure and to fully convey the scope of the present disclosure to those skilled in the art.

[0038] It should be noted that, unless otherwise specified, the technical terms or scientific terms used in this application should have the common meanings understood by technicians in the field to which this application belongs.

[0039] In addition, the terms "first" and "second" etc. are used to distinguish different objects, rather than to describe a specific order. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units that are not listed, or may optionally include other steps or units that are inherent to these processes, methods, products or devices.

[0040] Please refer to Figure 1 , Figure 1 1 is a flowchart of a database status monitoring method provided in an embodiment of the present application, comprising the following steps S101 to S104:

[0041] S101, receiving a monitoring request for a database status, wherein the monitoring request carries a target application and a target database;

[0042] The execution subject of the embodiment of the present application may be a database status monitoring device, such as a personal computer or a server.

[0043] The target database may or may not be used in the target application. Whether the target database is used or not needs to be determined in subsequent steps. The target database can be a Sqlite database or other databases. If the target database is used in the target application, the database interface may not be open, resulting in the inability to monitor the status of the target database used in the target application through existing technologies, thereby failing to optimize the target application.

[0044] S102, obtaining and judging whether the target application uses the target database according to the link library call relationship and the read-only data segment of the target application;

[0045] After receiving a request to monitor the database status, first determine whether the target application uses the target database based on the link library call relationship and read-only data segment of the target application. If the target application uses the target database, monitor the status of the target database.

[0046] Specifically, the step of determining whether the target application uses the target database according to the link library call relationship and the read-only data section of the target application in the above step S102 may be implemented as follows:

[0047] Determining whether the target application has loaded the link library associated with the target database according to the link library calling relationship of the target application;

[0048] If the target application has loaded a link library related to the target database and a preset number of string features that are fixed and existent in the target database are matched in the read-only data section of the target application, it is determined that the target application uses the target database; otherwise, it is determined that the target application does not use the target database.

[0049] The link library may be a dynamic link library DLL or a static link library Lib.

[0050] Specifically, it can be determined based on the hook library whether the target database is used in the target application. For example, first, the hook library determines whether to load the Sqlite-related DLL library by finding the dynamic link library DLL call relationship of the target application, and determines whether to use the Sqlite database by matching some fixed string features of Sqlite in sections such as .rdata (read-only data section). Among them, the preset number of string features that need to be matched is greater than or equal to 2, and the specific number is determined according to the number of related string features. If the number of string features is greater than or equal to 2, the accuracy of the match can be improved.

[0051] S103, according to the target application using the target database and not opening the database interface of the target database, determining the target database interface function based on the fuzzy matching rule corresponding to the target database;

[0052] Specifically, the fuzzy matching rules include:

[0053] Based on the fact that the number of function parameters is within the preset range and the parameter type is a pointer, the suspected database interface functions are preliminarily screened out;

[0054] According to the syntax features of the database execution statement contained in the pointer parameter and the return value of the suspected database interface function, the suspected database interface function is determined to be the target database interface function.

[0055] For example, when the hook library analyzes the target application that integrates the Sqlite database-related DLL or Lib library and does not export and open the database interface, the hook library matches the Sqlite database interface function through the following fuzzy matching rules:

[0056] ① Preliminarily filter functions by the number of function parameters, whether the parameter type is a pointer, etc.

[0057] ② Determine whether the pointer parameters and return values ​​contain some grammatical features of the Sqlite execution statement.

[0058] For example, take the Sqlite3_prepare_v2 function as an example. There are a total of 7 parameters when calling this function. When the number of parameters is judged to be less than this number, filtering is performed. Secondly, the second parameter of this function is a Sqlite statement string, which generally contains statements with strings such as "Select" or "Insert". Then, through this judgment, some functions can be filtered.

[0059] S104: Hook the log information of the target database interface function, and obtain the database status of the target database according to the log information analysis.

[0060] Specifically, after the target database interface function is screened out, the hook library will further hook the log information of the target database interface function, and then the database status of the target database can be obtained according to the analysis of the log information.

[0061] In actual applications, when the hook library analyzes that the target application has been opened to database interface export, the log information of the required function can be directly hooked.

[0062] For example, taking the bindText function as an example, the third parameter is the string pointed to by the database. Since the application has exported this function, this string can be directly output to the log. At the same time, the execution status can be judged by the return value of the database interface and the status can be output to the log.

[0063] For ease of understanding, this application also provides Figure 2 A flowchart of a specific database status monitoring method is shown.

[0064] like Figure 2 As shown, first, the hook library analyzes the target application to determine whether the target application uses the Sqlite database. If not, the analysis ends. If yes, it determines whether the target application has exported the database interface. If the target application has exported the database interface, the database interface is hooked to monitor the database status; if the target application has not exported the database interface, the database interface function is matched based on the above fuzzy matching rules, the matched database interface function is hooked to monitor the database status.

[0065] It can be seen that the embodiment of the present application analyzes and monitors the application's use of the Sqlite database behavior by hooking the database interface function in the application memory space based on the hook library from the perspective of the robustness and stability of the application, solving the problem that after the application integrates the Sqlite database, the database interface is not open to users and the interface parameters and Sqlite execution statements cannot be monitored. Similarly, the interface of the application that has exported the database interface can be directly hooked for users to analyze and optimize the database and application.

[0066] The database status monitoring method provided in the embodiment of the present application has the following beneficial effects:

[0067] In the present application, a monitoring request for database status is received, the monitoring request carries a target application and a target database; the target application is obtained and judged whether the target application uses the target database based on the link library call relationship and the read-only data segment of the target application; the target database interface function is determined based on the fuzzy matching rule corresponding to the target database, based on the fact that the target application uses the target database and the database interface of the target database is not open; the log information of the target database interface function is hooked, and the database status of the target database is obtained based on the analysis of the log information. Compared with the prior art, the present application can hook the log information of the database interface function based on the hook library when the database interface is not open, so that the database status of the unopened interface in the application can be monitored based on the log information, and the application can be improved in time, which can improve the robustness and stability of the application.

[0068] In the above embodiment, a database status monitoring method is provided, and correspondingly, the present application also provides a database status monitoring device. The database status monitoring device provided in the embodiment of the present application can implement the above database status monitoring method, and the database status monitoring device can be implemented by software, hardware, or a combination of software and hardware. For example, the database status monitoring device can include integrated or separate functional modules or units to perform the corresponding steps in the above methods. Please refer to Figure 3 As shown, the database status monitoring device 10 of the present application includes:

[0069] The receiving module 101 is used to receive a monitoring request for a database status, wherein the monitoring request carries a target application and a target database;

[0070] The judging module 102 is used to obtain and judge whether the target application uses the target database according to the link library calling relationship and the read-only data section of the target application;

[0071] A matching module 103, configured to determine a target database interface function based on a fuzzy matching rule corresponding to the target database, according to the fact that the target application uses the target database and the database interface of the target database is not open;

[0072] The hook module 104 is used to hook the log information of the target database interface function and obtain the database status of the target database according to the analysis of the log information.

[0073] In a possible implementation, the determining module 102 is specifically configured to:

[0074] Determining whether the target application has loaded the link library associated with the target database according to the link library calling relationship of the target application;

[0075] If the target application has loaded a link library related to the target database and a preset number of string features that are fixed and existent in the target database are matched in the read-only data section of the target application, it is determined that the target application uses the target database; otherwise, it is determined that the target application does not use the target database.

[0076] In a possible implementation, the preset number is greater than or equal to 2.

[0077] In a possible implementation, the fuzzy matching rule includes:

[0078] Based on the fact that the number of function parameters is within the preset range and the parameter type is a pointer, the suspected database interface functions are preliminarily screened out;

[0079] According to the syntax features of the database execution statement contained in the pointer parameter and the return value of the suspected database interface function, the suspected database interface function is determined to be the target database interface function.

[0080] The database status monitoring device provided in the embodiment of the present application and the database status monitoring method provided in the embodiment of the present application are based on the same inventive concept and have the same beneficial effects as the methods adopted, operated or implemented therein.

[0081] An embodiment of the present application also provides an electronic device corresponding to the method provided in the aforementioned embodiment, and the electronic device may be an electronic device for a client, such as a mobile phone, a laptop computer, a tablet computer, a desktop computer, etc., to execute the above-mentioned database status monitoring method.

[0082] Please refer to Figure 4 , which shows a schematic diagram of an electronic device provided by some embodiments of the present application. Figure 4 As shown, the electronic device 20 includes: a processor 200, a memory 201, a bus 202 and a communication interface 203, and the processor 200, the communication interface 203 and the memory 201 are connected via the bus 202; the memory 201 stores a computer program that can be run on the processor 200, and when the processor 200 runs the computer program, it executes the database status monitoring method provided in any of the aforementioned embodiments of the present application.

[0083] The memory 201 may include a high-speed random access memory (RAM), and may also include a non-volatile memory, such as at least one disk memory. The communication connection between the system network element and at least one other network element is realized through at least one communication interface 203 (which may be wired or wireless), and the Internet, wide area network, local area network, metropolitan area network, etc. may be used.

[0084] The bus 202 may be an ISA bus, a PCI bus, or an EISA bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc. The memory 201 is used to store programs, and the processor 200 executes the programs after receiving execution instructions. The database status monitoring method disclosed in any implementation of the above-mentioned embodiment of the present application may be applied to the processor 200, or implemented by the processor 200.

[0085] The processor 200 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the hardware integrated logic circuit or software instructions in the processor 200. The above processor 200 can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a readily available programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The methods, steps and logic block diagrams disclosed in the embodiments of the present application can be implemented or executed. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc. The steps of the method disclosed in the embodiments of the present application can be directly embodied as a hardware decoding processor to be executed, or the hardware and software modules in the decoding processor can be executed. The software module can be located in a mature storage medium in the field such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory 201, and the processor 200 reads the information in the memory 201 and completes the steps of the above method in combination with its hardware.

[0086] The electronic device provided in the embodiment of the present application and the database status monitoring method provided in the embodiment of the present application are based on the same inventive concept and have the same beneficial effects as the methods adopted, operated or implemented therein.

[0087] An embodiment of the present application also provides a computer-readable storage medium corresponding to the database status monitoring method provided in the aforementioned embodiment, on which a computer program (i.e., a program product) is stored. When the computer program is run by a processor, it will execute the database status monitoring method provided in any of the aforementioned embodiments.

[0088] It should be noted that examples of the computer-readable storage medium may also include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other optical or magnetic storage media, which are not listed here one by one.

[0089] The computer-readable storage medium provided in the above-mentioned embodiments of the present application and the database status monitoring method provided in the embodiments of the present application are based on the same inventive concept and have the same beneficial effects as the methods adopted, run or implemented by the application programs stored therein.

[0090] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein by equivalents. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the scope of the technical solutions of the embodiments of the present application, and they should all be included in the scope of the claims and specification of the present application.

Claims

1. A database status monitoring method, characterized in that: include: receiving a monitoring request for a database status, wherein the monitoring request carries a target application and a target database; Obtaining and judging whether the target application uses the target database according to the link library call relationship and the read-only data section of the target application; According to the target application using the target database and not opening the database interface of the target database, determining the target database interface function based on the fuzzy matching rule corresponding to the target database; The log information of the target database interface function is hooked, and the database status of the target database is obtained according to the analysis of the log information.

2. The method according to claim 1, characterized in that: According to the link library call relationship and the read-only data section of the target application, determining whether the target application uses the target database includes: Determining whether the target application has loaded the link library associated with the target database according to the link library calling relationship of the target application; If the target application has loaded a link library related to the target database and a preset number of string features that are fixed and existent in the target database are matched in the read-only data section of the target application, it is determined that the target application uses the target database; otherwise, it is determined that the target application does not use the target database.

3. The method according to claim 2, characterized in that The preset number is greater than or equal to 2.

4. The method according to claim 1, characterized in that: The fuzzy matching rules include: Based on the fact that the number of function parameters is within the preset range and the parameter type is a pointer, the suspected database interface functions are preliminarily screened out; According to the syntax features of the database execution statement contained in the pointer parameter and the return value of the suspected database interface function, the suspected database interface function is determined to be the target database interface function.

5. A database status monitoring device, characterized in that: include: A receiving module, configured to receive a monitoring request for a database status, wherein the monitoring request carries a target application and a target database; A determination module, used for obtaining and determining whether the target application uses the target database according to the link library call relationship and the read-only data section of the target application; A matching module, used to determine the target database interface function based on the fuzzy matching rule corresponding to the target database according to the fact that the target application uses the target database and the database interface of the target database is not open; The hooking module is used to hook the log information of the target database interface function and obtain the database status of the target database according to the log information analysis.

6. The device according to claim 5, characterized in that The judgment module is specifically used for: Determining whether the target application has loaded the link library associated with the target database according to the link library calling relationship of the target application; According to the target application program loading the link library related to the target database, and matching a preset number of string features fixedly existing in the target database in the read-only data section of the target application program, it is determined that the target application program uses the target database; Otherwise, it is determined that the target application does not use the target database.

7. The device according to claim 6, characterized in that The preset number is greater than or equal to 2.

8. The device according to claim 5, characterized in that The fuzzy matching rules include: Based on the fact that the number of function parameters is within the preset range and the parameter type is a pointer, the suspected database interface functions are preliminarily screened out; According to the syntax features of the database execution statement contained in the pointer parameter and the return value of the suspected database interface function, the suspected database interface function is determined to be the target database interface function.

9. An electronic device, comprising: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the method according to any one of claims 1 to 4 when executing the computer program.

10. A computer-readable storage medium, characterized in that: Computer-readable instructions are stored thereon, and the computer-readable instructions can be executed by a processor to implement the method according to any one of claims 1 to 4.