WO2020019405A1 - Database monitoring method, device and apparatus, and computer storage medium - Google Patents
Database monitoring method, device and apparatus, and computer storage medium Download PDFInfo
- Publication number
- WO2020019405A1 WO2020019405A1 PCT/CN2018/103337 CN2018103337W WO2020019405A1 WO 2020019405 A1 WO2020019405 A1 WO 2020019405A1 CN 2018103337 W CN2018103337 W CN 2018103337W WO 2020019405 A1 WO2020019405 A1 WO 2020019405A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- monitoring
- database
- item
- preset
- alarm
- Prior art date
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/30—Monitoring
Definitions
- the present application relates to the technical field of database monitoring, and in particular, to a database monitoring method, device, device, and readable storage medium.
- real-time monitoring of the operating status of the database is required, including monitoring of database sessions, database logs, data file fragments, tablespaces, and user access. Real-time database operation abnormalities and resource consumption are discovered. It can quickly remind users when the database is abnormal.
- PostgreSQL object-relational database
- the main purpose of this application is to provide a database monitoring method, device, device and readable storage medium, which aims to improve the applicability and reliability of database monitoring.
- the present application provides a database monitoring method, which includes the following steps:
- connection configuration information of a database to be monitored Receiving connection configuration information of a database to be monitored, and configuring connection objects in a preset monitoring template set according to the connection configuration information to obtain a current monitoring template set;
- alarm information is generated according to the monitoring results of each monitoring sub-item, and the alarm information is sent to the alarm contact group according to a preset alarm method.
- configuring the connection objects in the preset monitoring template set to obtain the current monitoring template set includes:
- connection objects in the preset monitoring template set according to the corresponding configuration parameters of each connection object to obtain the current monitoring template set.
- the step of determining whether to trigger a database alarm instruction according to the monitoring result of each monitoring sub-item includes:
- a database alarm command is triggered; otherwise, a data alarm command is not triggered.
- the step of generating alarm information according to the monitoring results of each monitoring sub-item includes:
- the step of filling the monitoring result of each monitoring sub-item into the preset alarm information template to generate alarm information includes:
- the database monitoring method further includes:
- the execution mode of the database monitoring operation is a single task execution mode, the monitoring SQL statement of the monitoring sub-item is executed one time at a time;
- the execution mode of the database monitoring operation is a multi-tasking execution mode
- the number of synchronously executed tasks is determined according to the currently available CPU resources, and the monitoring SQL statements of the corresponding number of monitoring sub-items are executed according to the number of synchronously executed tasks.
- the step of determining the number of synchronously executed pages according to the currently available CPU resources includes:
- mapping table of currently available CPU resources and the number of synchronous execution tasks, and query the number of synchronous execution tasks corresponding to the currently available CPU resources from the mapping relationship table.
- the present application further provides a database monitoring apparatus, where the database monitoring apparatus includes:
- a configuration module configured to receive connection configuration information of a database to be monitored, and configure connection objects in a preset monitoring template set according to the connection configuration information to obtain a current monitoring template set;
- An execution module configured to execute, in the database to be monitored, a monitoring SQL statement of each monitoring sub-item in the current monitoring template set, and determine whether to trigger a database alarm instruction according to a monitoring result of each monitoring sub-item;
- the alarm module is configured to generate alarm information according to the monitoring result of each monitoring sub-item if a database alarm instruction is triggered, and send the alarm information to an alarm contact group according to a preset alarm method.
- the present application further provides a database monitoring device.
- the database monitoring device includes a processor, a memory, and computer-readable instructions stored on the memory and executable by the processor. When the computer-readable instructions are executed by the processor, the steps of the database monitoring method as described above are implemented.
- the present application further provides a readable storage medium, where the readable storage medium stores computer-readable instructions, and when the computer-readable instructions are executed by a processor, the database as described above is implemented. Steps of the monitoring method.
- This application provides a database monitoring method, device, device, and readable storage medium.
- This application receives connection configuration information of a database to be monitored, and configures connection objects in a preset monitoring template set according to the connection configuration information to obtain the current Monitoring template set; in the database to be monitored, execute the monitoring SQL statement of each monitoring sub-item in the current monitoring template set, and determine whether to trigger the database alarm command according to the monitoring results of each monitoring sub-item; if the database alarm command is triggered, according to each monitoring The monitoring results of the sub-items generate alarm information, and send the alarm information to the alarm contact group according to the preset alarm method.
- the monitoring template set is used for monitoring the PostgreSQL database under each application system, and no operation and maintenance personnel are required. Configure the monitoring strategy. Simply configure the database connection object to realize the monitoring of the PostgreSQL database, effectively reduce the deployment difficulty of monitoring, and improve the applicability of database monitoring.
- FIG. 1 is a schematic diagram of a hardware structure of a database monitoring device according to embodiments of the present application.
- FIG. 2 is a schematic flowchart of a first embodiment of a database monitoring method of the present application
- FIG. 3 is a schematic flowchart of a second embodiment of a database monitoring method of the present application.
- FIG. 4 is a schematic diagram of function modules of the first embodiment of the database monitoring apparatus of the present application.
- the database monitoring method according to the embodiment of the present application is mainly applied to a database monitoring device.
- the database monitoring device may be a PC (personal computer personal). computer), portable computers, mobile terminals and other devices with display and processing functions.
- FIG. 1 is a schematic diagram of a hardware structure of a database monitoring device involved in a solution according to an embodiment of the present application.
- the database monitoring device may include a processor 1001 (for example, a central processor Central Processing Unit, CPU), communication bus 1002, user interface 1003, network interface 1004, and memory 1005.
- the communication bus 1002 is used to implement connection and communication between these components.
- the user interface 1003 may include a display and an input unit such as a keyboard.
- the network interface 1004 may optionally include a standard wired interface and a wireless interface.
- the memory 1005 can be a high-speed RAM memory or a stable memory (non-volatile memory), such as a disk memory, the memory 1005 may optionally be a storage device independent of the foregoing processor 1001.
- the hardware structure shown in FIG. 1 does not constitute a limitation on the present application, and may include more or fewer components than shown in the figure, or combine some components, or arrange different components.
- the memory 1005 as a readable storage medium in FIG. 1 may include an operating system, a network communication module, and computer-readable instructions.
- the network communication module is mainly used to connect to a server and perform data communication with the server; and the processor 1001 can call the computer-readable instructions stored in the memory 1005 and execute the database monitoring method provided in the embodiment of the present application.
- the embodiment of the present application provides a database monitoring method.
- FIG. 2 is a schematic flowchart of a first embodiment of a database monitoring method of the present application.
- the database monitoring method is implemented by a database monitoring device.
- the database monitoring device may be a terminal device such as a PC, a palmtop computer, and a tablet computer.
- the device shown in FIG. 1 may be selected.
- the database monitoring method includes the following steps: :
- Step S101 Receive connection configuration information of a database to be monitored, and configure connection objects in a preset monitoring template set according to the connection configuration information to obtain a current monitoring template set;
- Step S102 In the database to be monitored, execute a monitoring SQL statement of each monitoring item in the current monitoring template set, and determine whether to trigger a database alarm instruction according to the monitoring result of each monitoring item;
- step S103 if a database alarm instruction is triggered, alarm information is generated according to the monitoring results of each monitoring sub-item, and the alarm information is sent to the alarm contact group according to a preset alarm method.
- the monitoring method of the PostgreSQL database is that the operation and maintenance personnel use monitoring tools and configure monitoring policies to monitor the database.
- the operation and maintenance personnel need to configure different monitoring strategies.
- the applicability and reliability of database monitoring are relatively low. Low, affecting the monitoring efficiency of the database.
- a database monitoring method is proposed in this embodiment. The specific steps of the database monitoring method are detailed below:
- Step S101 Receive connection configuration information of a database to be monitored, and configure connection objects in a preset monitoring template set according to the connection configuration information to obtain a current monitoring template set;
- the device when the configuration instruction of the monitoring data set triggered by the operation and maintenance personnel is detected, displays a connection object configuration interface, and receives the connection configuration information of the database to be monitored input by the operation and maintenance personnel based on the connection object configuration interface.
- the connection configuration information includes but is not limited to the system to which the database to be monitored belongs, the system's group, the department or subsidiary of the system, the alarm contact group, the PostgreSQL database host IP, the PostgreSQL database host port, the database name, the database login user, and the database.
- connection object configuration interface displays the object name and parameter description, and the parameter description of the system to which the database to be monitored belongs, the system's group, the department or subsidiary of the system, and the alarm contact group are alarm auxiliary information, and the PostgreSQL database host
- the parameters of IP, PostgreSQL database host port, database name, database login user, and database login password are for monitoring database configuration information.
- the device receives the connection configuration information of the database to be monitored, and configures the connection objects in the preset monitoring template set according to the connection configuration information to obtain the current monitoring template set, that is, the system to which the database to be monitored belongs in the preset monitoring template set, Configure the system group, system department or subsidiary, alarm contact group, PostgreSQL database host IP, PostgreSQL database host port, database name, database login user, and database login password.
- the preset monitoring template set includes, but is not limited to, the monitoring SQL statement of the database availability monitoring sub-item, the monitoring SQL statement of the application SQL execution efficiency monitoring sub-item, the monitoring SQL statement of the background job execution monitoring sub-item, and the database connection number monitoring sub-item.
- the monitoring SQL statement of the database availability monitoring sub-item is used to monitor whether the database can receive external requests
- the SQL execution efficiency monitoring sub-item is used to determine whether there are applications with execution efficiency lower than the preset efficiency through database snapshot information.
- the monitoring SQL statement of the background job execution monitoring sub-item is used to create the function quartzchk in the PostgreSQL database, Then call the function select * from quartzchk queries the background job execution status;
- the monitoring SQL statement of the database connection number monitoring sub-item is used to monitor whether the current total number of connections in the database accounts for the maximum allowable number of connections in the database exceeds a predetermined threshold;
- the monitoring SQL statement of the database lock monitoring sub-item is used to monitor Whether a database lock occurs in the database, and when a database lock occurs, perform a related query through the pg_locks and pg_stat_activity views to refine the lock status of each SQL statement.
- the device obtains an identification field of each connection object in a preset monitoring template set, and obtains corresponding configuration parameters of each connection object from the connection configuration information according to the identification field of each connection object, that is, the configuration parameters in the connection configuration information and
- the identification fields have a corresponding relationship.
- the corresponding configuration parameters of each connection object can be obtained through the identification fields of each connection object, and then according to the corresponding configuration parameters of each connection object, the connection objects in the preset monitoring template set are configured to obtain the current
- the monitoring template set that is, the specific parameters of each connection object in the preset monitoring template set is configured as corresponding configuration parameters.
- Step S102 In the database to be monitored, execute a monitoring SQL statement of each monitoring item in the current monitoring template set, and determine whether to trigger a database alarm instruction according to the monitoring result of each monitoring item;
- the device executes the monitoring SQL statement of each monitoring sub-item in the current monitoring template set in the database to be monitored, and according to the monitoring results of each monitoring sub-item Determines whether a database alert command is triggered.
- the monitoring SQL statement of the database availability monitoring sub-item is executed to monitor whether the database can receive external requests. If the database cannot receive external requests, the monitoring result is an abnormal database access. If the database is monitored, external data can be received. Request, the monitoring result is that the database access is normal;
- Monitor SQL statements of the application SQL execution efficiency monitoring sub-item monitor database snapshot information, count the application SQL execution in the most recent specified number of days, determine whether there is application SQL with an execution efficiency lower than the preset efficiency, and obtain the application SQL through the pg_stat_activity view
- the current execution time determines whether there is any application SQL whose current execution time exceeds the specified duration. If there is an application SQL whose execution efficiency is lower than the preset efficiency or an application SQL whose current execution time exceeds the specified time, the monitoring result is that the execution efficiency is lower than the Efficient application SQL or application SQL whose current execution time exceeds a specified time, that is, SQL execution efficiency is abnormal. If the execution efficiency of each application SQL is higher than or equal to a preset efficiency, and the current execution time of each application SQL does not exceed the specified Time, the monitoring result is that the SQL execution efficiency is normal;
- Quartzchk In the PostgreSQL database, the function select * from quartzchk queries the background job execution and monitors the results for the background role execution; among them, the function quartzchk is created first, and then the function select * from is called
- the quartzchk method can be used to query the execution of background jobs, which can avoid the SQL statement error when monitoring the system without background jobs and improve the applicability;
- the monitoring SQL statement of the database lock monitoring sub-item to monitor whether there is a lock status SQL statement in the database. If there is a lock status SQL statement in the database, use the pg_locks and pg_stat_activity views to perform related queries to refine the lock status of the SQL statement.
- the monitoring results include the PID of the process that generated the lock, the lock mode, and the transaction information of the lock. If the database does not have SQL statements in the lock state, no monitoring results are generated.
- the lock mode includes AccessShareLock, RowShareLock, RowExclusiveLock, ShareUpdateExclusiveLock, ShareLock, ShareRowExclusiveLock , ExclusiveLock and AccessExclusiveLock.
- the device determines whether the monitoring result of at least one monitoring sub-item in each monitoring sub-item is located in a preset monitoring result group, and if the monitoring result of at least one monitoring sub-item in each monitoring sub-item is located in a preset monitoring result group , The database alarm instruction is triggered, otherwise the data alarm instruction is not triggered, that is, the monitoring results of each monitoring sub-item are not in the preset monitoring result group, and the data alarm instruction is not triggered.
- the above-mentioned preset monitoring result group may be set by a person skilled in the art based on actual conditions, which is not specifically limited in this embodiment.
- step S103 if a database alarm instruction is triggered, alarm information is generated according to the monitoring results of each monitoring sub-item, and the alarm information is sent to the alarm contact group according to a preset alarm method.
- alarm information is generated according to the monitoring results of each monitoring sub-item, and the alarm information is sent to the alarm contact group according to a preset alarm method.
- a preset alarm information template is obtained, and the monitoring result of each monitoring sub-item is filled into the preset alarm information template to generate alarm information, that is, the information of each monitoring sub-item in the preset alarm information template is obtained.
- Location information and according to the location information of each monitoring sub-item, determine the filling position of each monitoring sub-item in the preset alarm information template, and fill the monitoring result of each monitoring sub-item with the corresponding affiliation in the preset alarm information template Fill in the position to generate alarm information.
- the alarm information includes, but is not limited to, the system to which the system belongs, the group to which the system belongs, the department or subsidiary of the system, the alarm contact group, and abnormal information
- the abnormal information includes, but is not limited to, database disconnection, inefficient application SQL, background SQL statements for job execution and lock status.
- the alarm methods include, but are not limited to, email alerts, SMS alerts, and phone alerts.
- the application receives the connection configuration information of the database to be monitored, and configures the connection objects in the preset monitoring template set according to the connection configuration information to obtain the current monitoring template set.
- the current monitoring is performed.
- the template focuses on the monitoring SQL statements of each monitoring sub-item, and determines whether to trigger a database alarm command based on the monitoring results of each monitoring sub-item. If a database alarm command is triggered, an alarm message is generated based on the monitoring results of each monitoring sub-item, and according to the preset
- the alarm method sends alarm information to the alarm contact group.
- the monitoring template set is used for monitoring the PostgreSQL database under each application system. There is no need for operation and maintenance personnel to configure the monitoring strategy. You only need to configure the database connection object.
- the monitoring of the PostgreSQL database can be realized, the deployment difficulty of the monitoring is effectively reduced, and the applicability of the database monitoring is improved.
- the database monitoring method further includes:
- Step 104 Obtain the currently available CPU resources, and determine whether the execution mode of the database monitoring operation is a single-task execution mode or a multi-task execution mode according to the currently available CPU resources.
- the device obtains the currently available CPU resources, and determines whether the execution method of the database monitoring operation is a single-task execution mode or a multi-task execution mode according to the currently available CPU resources, and specifically determines whether the currently available CPU resources exceed a preset CPU Resources, if the currently available CPU resources exceed the preset CPU resources, you can determine that the database monitoring operation is performed in a multi-tasking execution mode, and if the currently available CPU resources do not exceed the preset CPU resources, you can determine that the database monitoring operation is performed as Single task execution.
- Step 105 If the execution mode of the database monitoring operation is a multi-task execution mode, determine the number of synchronous execution tasks according to the currently available CPU resources, and execute the monitoring SQL statements of the corresponding number of monitoring sub-items according to the number of synchronous execution tasks.
- the number of synchronous execution tasks is determined according to the currently available CPU resources, that is, a pre-stored mapping table of the currently available CPU resources and the number of synchronous execution pages is obtained, and In the mapping relationship table, query the number of synchronous execution tasks corresponding to the currently available CPU resources, and execute the monitoring SQL statements of the corresponding number of monitoring sub-items according to the number of synchronous execution tasks, that is, the device performs the preset execution order in the database to be monitored Execute the monitoring SQL statements of the monitoring sub-items corresponding to the number of synchronously executed tasks.
- the monitoring SQL statements of the monitoring sub-items are executed one at a time, that is, the device executes the monitoring sub-items of the current monitoring template set in the database to be monitored in the preset execution order.
- Monitor SQL statements It should be noted that the foregoing preset execution order may be set by a person skilled in the art based on actual conditions, and this embodiment does not specifically limit this.
- the preset CPU resources can be set according to the total CPU resources, or set by the user according to specific needs.
- the number of synchronous pages that can be executed simultaneously can be determined according to the mapping relationship between the available CPU resources and the number of synchronized pages. For example, in the mapping relationship, when the available CPU resources are less than A, the corresponding The number of simultaneous pages that are executed simultaneously is 2; when the available CPU resources are greater than or equal to A and less than B, the number of simultaneous pages that can be executed simultaneously is 3; when the available CPU resources are greater than or equal to B and less than C, the corresponding can be executed simultaneously
- the number of synchronized pages is 4, where A ⁇ B ⁇ C.
- the present application determines the monitoring SQL statements of the monitoring sub-items that are executed synchronously based on the currently available CPU resources of the device.
- the device can simultaneously execute the monitoring SQL statements of multiple monitoring sub-items, effectively improving the database monitoring efficiency.
- an embodiment of the present application further provides a database monitoring device.
- FIG. 4 is a schematic diagram of functional modules of a first embodiment of a database monitoring apparatus of the present application.
- the database monitoring device of the present application is a virtual device, which is stored in the memory 1005 of the database monitoring device shown in FIG. 1 and is used to implement all the functions of the computer-readable instructions; receiving the connection configuration information of the database to be monitored, and according to the connection configuration information To configure the connection objects in the preset monitoring template set to obtain the current monitoring template set; in the database to be monitored, execute a monitoring SQL statement of each monitoring sub-item in the current monitoring template set, and according to each monitoring sub-item The monitoring result determines whether a database alarm instruction is triggered; if the database alarm instruction is triggered, alarm information is generated according to the monitoring results of each monitoring sub-item, and the alarm information is sent to the alarm contact group according to a preset alarm method.
- the database monitoring apparatus includes:
- a configuration module 101 is configured to receive connection configuration information of a database to be monitored, and configure connection objects in a preset monitoring template set according to the connection configuration information to obtain a current monitoring template set;
- the execution module 102 is configured to execute, in the database to be monitored, a monitoring SQL statement of each monitoring sub-item in the current monitoring template set, and determine whether to trigger a database alarm instruction according to a monitoring result of each monitoring sub-item;
- the alarm module 103 is configured to generate alarm information according to the monitoring result of each monitoring sub-item if a database alarm instruction is triggered, and send the alarm information to an alarm contact group according to a preset alarm method.
- configuration module 101 is further configured to:
- connection objects in the preset monitoring template set according to the corresponding configuration parameters of each connection object to obtain the current monitoring template set.
- execution module 102 is further configured to:
- a database alarm command is triggered; otherwise, a data alarm command is not triggered.
- the alarm module 103 is further configured to:
- the alarm module 103 is further configured to:
- the database monitoring device further includes:
- the execution module 102 is further configured to execute a monitoring SQL statement of a monitoring sub-item each time if the execution mode of the database monitoring operation is a single task execution mode;
- the execution module 102 is further configured to: if the database monitoring operation is performed in a multi-tasking mode, determine the number of tasks to be executed synchronously according to the currently available CPU resources, and execute a corresponding number of monitoring sub-items according to the number of tasks executed synchronously Monitor SQL statements.
- execution module 102 is further configured to:
- mapping table of currently available CPU resources and the number of synchronous execution tasks, and query the number of synchronous execution tasks corresponding to the currently available CPU resources from the mapping relationship table.
- each module in the above-mentioned database monitoring apparatus corresponds to each step in the above-mentioned embodiment of the database monitoring method, and the functions and implementation processes thereof are not repeated here one by one.
- an embodiment of the present application further provides a readable storage medium, and the readable storage medium may be a non-volatile readable storage medium.
- Computer-readable instructions are stored on the readable storage medium of this application, and when the computer-readable instructions are executed by a processor, the steps of the database monitoring method as described above are implemented.
- the methods in the above embodiments can be implemented by means of software plus a necessary universal hardware platform, and of course, also by hardware, but in many cases the former is better.
- Implementation Based on such an understanding, the technical solution of this application that is essentially or contributes to the existing technology can be embodied in the form of a software product.
- the computer software product is stored in a storage medium (such as ROM / RAM) as described above. , Magnetic disk, optical disc), including a number of instructions for causing a terminal device (which may be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to execute the methods described in the embodiments of the present application.
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Quality & Reliability (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Telephonic Communication Services (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
The present application provides a database monitoring method, comprising: receiving connection configuration information about a database to be monitored, and configuring, according to the connection configuration information, a connection object in a preset monitoring template set, so as to acquire a current monitoring template set; in said database, executing monitoring SQL statement of each monitoring sub-item in the current monitoring template set, and determining whether to trigger a database alarm instruction according to a monitoring result of each monitoring sub-item; and if the database alarm instruction is triggered, generating alarm information according to the monitoring result of each monitoring sub-item, and sending, in a preset alarm mode, the alarm information to an alarm contact group. The present application further provides a database monitoring device and apparatus, and a readable storage medium.
Description
本申请要求于2018年7月26日提交中国专利局、申请号为201810835443.0、发明名称为“数据库监控方法、装置、设备及可读存储介质”的中国专利申请的优先权,其全部内容通过引用结合在申请中。This application claims the priority of a Chinese patent application filed on July 26, 2018 with the Chinese Patent Office, application number 201810835443.0, and the invention name is "Database Monitoring Method, Device, Device, and Readable Storage Medium", the entire contents of which are incorporated by reference. Incorporated in the application.
技术领域Technical field
本申请涉及数据库监控的技术领域,尤其涉及一种数据库监控方法、装置、设备及可读存储介质。The present application relates to the technical field of database monitoring, and in particular, to a database monitoring method, device, device, and readable storage medium.
背景技术Background technique
在数据库的运行过程中,需要对数据库的运行状态进行实时的监控,包括对数据库会话、数据库日志、数据文件碎片、表空间和用户访问等的监控,实时发现数据库的运行异常和资源消耗情况,能够在数据库运行异常时,快速的提醒用户。During the operation of the database, real-time monitoring of the operating status of the database is required, including monitoring of database sessions, database logs, data file fragments, tablespaces, and user access. Real-time database operation abnormalities and resource consumption are discovered. It can quickly remind users when the database is abnormal.
目前,PostgreSQL(对象-关系数据库)的监控方式为运维人员使用监控工具,配置监控策略监控数据库,针对在不同应用系统下使用的数据库,运维人员需要配置不同的监控策略,数据库监控的适用性较低。At present, the monitoring method of PostgreSQL (object-relational database) is that operation and maintenance personnel use monitoring tools and configure monitoring policies to monitor the database. For databases used in different application systems, operation and maintenance personnel need to configure different monitoring strategies. Database monitoring is applicable. Sex is low.
因此,如何提高数据库监控的适用性是目前亟待解决的问题。Therefore, how to improve the applicability of database monitoring is an urgent problem to be solved.
发明内容Summary of the Invention
本申请的主要目的在于提供一种数据库监控方法、装置、设备及可读存储介质,旨在提高数据库监控的适用性和可靠性。The main purpose of this application is to provide a database monitoring method, device, device and readable storage medium, which aims to improve the applicability and reliability of database monitoring.
为实现上述目的,本申请提供一种数据库监控方法,所述数据库监控方法包括以下步骤:To achieve the above objective, the present application provides a database monitoring method, which includes the following steps:
接收待监控数据库的连接配置信息,并依据所述连接配置信息,对预设监控模板集中的连接对象进行配置,以获取当前监控模板集;Receiving connection configuration information of a database to be monitored, and configuring connection objects in a preset monitoring template set according to the connection configuration information to obtain a current monitoring template set;
在所述待监控数据库中,执行所述当前监控模板集中各监控子项的监控SQL语句,并依据各监控子项的监控结果确定是否触发数据库告警指令;In the database to be monitored, execute a monitoring SQL statement of each monitoring sub-item in the current monitoring template set, and determine whether to trigger a database alarm instruction according to the monitoring result of each monitoring sub-item;
若触发数据库告警指令,则依据各监控子项的监控结果生成告警信息,并按照预设的告警方式将所述告警信息发送给告警联系组。If a database alarm instruction is triggered, alarm information is generated according to the monitoring results of each monitoring sub-item, and the alarm information is sent to the alarm contact group according to a preset alarm method.
可选地,依据所述连接配置信息,对预设监控模板集中的连接对象进行配置,以获取当前监控模板集的步骤包括:Optionally, according to the connection configuration information, configuring the connection objects in the preset monitoring template set to obtain the current monitoring template set includes:
获取预设监控模板集中各连接对象的标识字段,并依据各连接对象的标识字段,从所述连接配置信息中获取各连接对象的对应配置参数;Obtaining an identification field of each connection object in a preset monitoring template set, and obtaining corresponding configuration parameters of each connection object from the connection configuration information according to the identification field of each connection object;
依据各连接对象的对应配置参数,对预设监控模板集中的连接对象进行配置,以获取当前监控模板集。Configure the connection objects in the preset monitoring template set according to the corresponding configuration parameters of each connection object to obtain the current monitoring template set.
可选地,所述依据各监控子项的监控结果确定是否触发数据库告警指令的步骤包括:Optionally, the step of determining whether to trigger a database alarm instruction according to the monitoring result of each monitoring sub-item includes:
确定各监控子项中是否存在至少一监控子项的监控结果位于预设监控结果组中;Determining whether the monitoring result of at least one monitoring sub-item in each monitoring sub-item is in a preset monitoring result group;
若各监控子项中存在至少一监控子项的监控结果位于预设监控结果组中,则触发数据库告警指令,否则不触发数据告警指令。If the monitoring result of at least one monitoring sub-item in each monitoring sub-item is in a preset monitoring result group, a database alarm command is triggered; otherwise, a data alarm command is not triggered.
可选地,所述依据各监控子项的监控结果生成告警信息的步骤包括:Optionally, the step of generating alarm information according to the monitoring results of each monitoring sub-item includes:
获取预设告警信息模板,并将各监控子项的监控结果填充至所述预设告警信息模板中,以生成告警信息。Obtain a preset alarm information template, and fill the monitoring results of each monitoring sub-item into the preset alarm information template to generate alarm information.
可选地,所述将各监控子项的监控结果填充至所述预设告警信息模板中,以生成告警信息的步骤包括:Optionally, the step of filling the monitoring result of each monitoring sub-item into the preset alarm information template to generate alarm information includes:
获取所述预设告警信息模板中的各监控子项的位置信息;Acquiring position information of each monitoring sub-item in the preset alarm information template;
依据各监控子项的位置信息,确定各监控子项在预设告警信息模板中的所属填充位置;Determine the filling position of each monitoring sub-item in the preset alarm information template according to the location information of each monitoring sub-item;
将各监控子项的监控结果填充至预设告警信息模板中的对应所属填充位置。Fill the monitoring results of each monitoring sub-item to the corresponding filling position in the preset alarm information template.
可选地,所述数据库监控方法还包括:Optionally, the database monitoring method further includes:
获取当前可用CPU资源,并依据当前可用CPU资源,确定数据库监控操作的执行方式是单任务执行方式,还是多任务执行方式;Obtain the currently available CPU resources and determine whether the execution mode of the database monitoring operation is a single task execution mode or a multi-task execution mode according to the currently available CPU resources;
若数据库监控操作的执行方式是单任务执行方式,则每次执行一监控子项的监控SQL语句;If the execution mode of the database monitoring operation is a single task execution mode, the monitoring SQL statement of the monitoring sub-item is executed one time at a time;
若数据库监控操作的执行方式是多任务执行方式,则依据当前可用CPU资源确定同步执行任务数,并按照所述同步执行任务数,执行对应数量的监控子项的监控SQL语句。If the execution mode of the database monitoring operation is a multi-tasking execution mode, the number of synchronously executed tasks is determined according to the currently available CPU resources, and the monitoring SQL statements of the corresponding number of monitoring sub-items are executed according to the number of synchronously executed tasks.
可选地,所述根据当前可用CPU资源确定同步执行页面数的步骤包括:Optionally, the step of determining the number of synchronously executed pages according to the currently available CPU resources includes:
获取预存的当前可用CPU资源与同步执行任务数的映射关系表,并从所述映射关系表中,查询与当前可用CPU资源对应的同步执行任务数。Obtain a pre-stored mapping table of currently available CPU resources and the number of synchronous execution tasks, and query the number of synchronous execution tasks corresponding to the currently available CPU resources from the mapping relationship table.
此外,为实现上述目的,本申请还提供一种数据库监控装置,所述数据库监控装置包括:In addition, in order to achieve the foregoing object, the present application further provides a database monitoring apparatus, where the database monitoring apparatus includes:
配置模块,用于接收待监控数据库的连接配置信息,并依据所述连接配置信息,对预设监控模板集中的连接对象进行配置,以获取当前监控模板集;A configuration module, configured to receive connection configuration information of a database to be monitored, and configure connection objects in a preset monitoring template set according to the connection configuration information to obtain a current monitoring template set;
执行模块,用于在所述待监控数据库中,执行所述当前监控模板集中各监控子项的监控SQL语句,并依据各监控子项的监控结果确定是否触发数据库告警指令;An execution module, configured to execute, in the database to be monitored, a monitoring SQL statement of each monitoring sub-item in the current monitoring template set, and determine whether to trigger a database alarm instruction according to a monitoring result of each monitoring sub-item;
告警模块,用于若触发数据库告警指令,则依据各监控子项的监控结果生成告警信息,并按照预设的告警方式将所述告警信息发送给告警联系组。The alarm module is configured to generate alarm information according to the monitoring result of each monitoring sub-item if a database alarm instruction is triggered, and send the alarm information to an alarm contact group according to a preset alarm method.
此外,为实现上述目的,本申请还提供一种数据库监控设备,所述数据库监控设备包括处理器、存储器、以及存储在所述存储器上并可被所述处理器执行的计算机可读指令,其中所述计算机可读指令被所述处理器执行时,实现如上述的数据库监控方法的步骤。In addition, in order to achieve the above-mentioned object, the present application further provides a database monitoring device. The database monitoring device includes a processor, a memory, and computer-readable instructions stored on the memory and executable by the processor. When the computer-readable instructions are executed by the processor, the steps of the database monitoring method as described above are implemented.
此外,为实现上述目的,本申请还提供一种可读存储介质,所述可读存储介质上存储有计算机可读指令,其中所述计算机可读指令被处理器执行时,实现如上述的数据库监控方法的步骤。In addition, in order to achieve the foregoing object, the present application further provides a readable storage medium, where the readable storage medium stores computer-readable instructions, and when the computer-readable instructions are executed by a processor, the database as described above is implemented. Steps of the monitoring method.
本申请提供一种数据库监控方法、装置、设备及可读存储介质,本申请接收待监控数据库的连接配置信息,并依据连接配置信息,对预设监控模板集中的连接对象进行配置,以获取当前监控模板集;在待监控数据库中,执行当前监控模板集中各监控子项的监控SQL语句,并依据各监控子项的监控结果确定是否触发数据库告警指令;若触发数据库告警指令,则依据各监控子项的监控结果生成告警信息,并按照预设的告警方式将告警信息发送给告警联系组,通过设置监控模板集,监控模板集使用于各应用系统下PostgreSQL数据库的监控,不需要运维人员配置监控策略,只需简单的配置数据库连接对象,即可实现PostgreSQL数据库的监控,有效的减低监控的部署难度,提高数据库监控的适用性。This application provides a database monitoring method, device, device, and readable storage medium. This application receives connection configuration information of a database to be monitored, and configures connection objects in a preset monitoring template set according to the connection configuration information to obtain the current Monitoring template set; in the database to be monitored, execute the monitoring SQL statement of each monitoring sub-item in the current monitoring template set, and determine whether to trigger the database alarm command according to the monitoring results of each monitoring sub-item; if the database alarm command is triggered, according to each monitoring The monitoring results of the sub-items generate alarm information, and send the alarm information to the alarm contact group according to the preset alarm method. By setting a monitoring template set, the monitoring template set is used for monitoring the PostgreSQL database under each application system, and no operation and maintenance personnel are required. Configure the monitoring strategy. Simply configure the database connection object to realize the monitoring of the PostgreSQL database, effectively reduce the deployment difficulty of monitoring, and improve the applicability of database monitoring.
附图说明BRIEF DESCRIPTION OF THE DRAWINGS
图1为本申请各实施例涉及的数据库监控设备的硬件结构示意图;FIG. 1 is a schematic diagram of a hardware structure of a database monitoring device according to embodiments of the present application; FIG.
图2为本申请数据库监控方法第一实施例的流程示意图;2 is a schematic flowchart of a first embodiment of a database monitoring method of the present application;
图3为本申请数据库监控方法第二实施例的流程示意图;3 is a schematic flowchart of a second embodiment of a database monitoring method of the present application;
图4为本申请数据库监控装置第一实施例的功能模块示意图。FIG. 4 is a schematic diagram of function modules of the first embodiment of the database monitoring apparatus of the present application.
本申请目的的实现、功能特点及优点将结合实施例,参照附图做进一步说明。The implementation, functional features and advantages of the purpose of this application will be further described with reference to the embodiments and the drawings.
具体实施方式detailed description
应当理解,此处所描述的具体实施例仅仅用以解释本申请,并不用于限定本申请。It should be understood that the specific embodiments described herein are only used to explain the application, and are not used to limit the application.
本申请实施例涉及的数据库监控方法主要应用于数据库监控设备,该数据库监控设备可以是PC(个人计算机personal
computer)、便携计算机、移动终端等具有显示和处理功能的设备。The database monitoring method according to the embodiment of the present application is mainly applied to a database monitoring device. The database monitoring device may be a PC (personal computer personal).
computer), portable computers, mobile terminals and other devices with display and processing functions.
参照图1,图1为本申请实施例方案中涉及的数据库监控设备的硬件结构示意图。本申请实施例中,数据库监控设备可以包括处理器1001(例如中央处理器Central
Processing
Unit、CPU),通信总线1002,用户接口1003,网络接口1004,存储器1005。其中,通信总线1002用于实现这些组件之间的连接通信;用户接口1003可以包括显示屏(Display)、输入单元比如键盘(Keyboard);网络接口1004可选的可以包括标准的有线接口、无线接口(如WI-FI接口);存储器1005可以是高速RAM存储器,也可以是稳定的存储器(non-volatile
memory),例如磁盘存储器,存储器1005可选的还可以是独立于前述处理器1001的存储装置。本领域技术人员可以理解,图1中示出的硬件结构并不构成对本申请的限定,可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件布置。Referring to FIG. 1, FIG. 1 is a schematic diagram of a hardware structure of a database monitoring device involved in a solution according to an embodiment of the present application. In the embodiment of the present application, the database monitoring device may include a processor 1001 (for example, a central processor Central
Processing
Unit, CPU), communication bus 1002, user interface 1003, network interface 1004, and memory 1005. The communication bus 1002 is used to implement connection and communication between these components. The user interface 1003 may include a display and an input unit such as a keyboard. The network interface 1004 may optionally include a standard wired interface and a wireless interface. (Such as the WI-FI interface); the memory 1005 can be a high-speed RAM memory or a stable memory (non-volatile
memory), such as a disk memory, the memory 1005 may optionally be a storage device independent of the foregoing processor 1001. Those skilled in the art can understand that the hardware structure shown in FIG. 1 does not constitute a limitation on the present application, and may include more or fewer components than shown in the figure, or combine some components, or arrange different components.
继续参照图1,图1中作为一种可读存储介质的存储器1005可以包括操作系统、网络通信模块以及计算机可读指令。在图1中,网络通信模块主要用于连接服务器,与服务器进行数据通信;而处理器1001可以调用存储器1005中存储的计算机可读指令,并执行本申请实施例提供的数据库监控方法。With continued reference to FIG. 1, the memory 1005 as a readable storage medium in FIG. 1 may include an operating system, a network communication module, and computer-readable instructions. In FIG. 1, the network communication module is mainly used to connect to a server and perform data communication with the server; and the processor 1001 can call the computer-readable instructions stored in the memory 1005 and execute the database monitoring method provided in the embodiment of the present application.
本申请实施例提供了一种数据库监控方法。The embodiment of the present application provides a database monitoring method.
参照图2,图2为本申请数据库监控方法第一实施例的流程示意图。Referring to FIG. 2, FIG. 2 is a schematic flowchart of a first embodiment of a database monitoring method of the present application.
本实施例中,该数据库监控方法由数据库监控设备实现,该数据库监控设备可以是PC、掌上电脑和平板电脑等终端设备,可选为图1所示的设备,所述数据库监控方法包括以下步骤:In this embodiment, the database monitoring method is implemented by a database monitoring device. The database monitoring device may be a terminal device such as a PC, a palmtop computer, and a tablet computer. The device shown in FIG. 1 may be selected. The database monitoring method includes the following steps: :
步骤S101,接收待监控数据库的连接配置信息,并依据连接配置信息,对预设监控模板集中的连接对象进行配置,以获取当前监控模板集;Step S101: Receive connection configuration information of a database to be monitored, and configure connection objects in a preset monitoring template set according to the connection configuration information to obtain a current monitoring template set;
步骤S102,在待监控数据库中,执行当前监控模板集中各监控子项的监控SQL语句,并依据各监控子项的监控结果确定是否触发数据库告警指令;Step S102: In the database to be monitored, execute a monitoring SQL statement of each monitoring item in the current monitoring template set, and determine whether to trigger a database alarm instruction according to the monitoring result of each monitoring item;
步骤S103,若触发数据库告警指令,则依据各监控子项的监控结果生成告警信息,并按照预设的告警方式将告警信息发送给告警联系组。In step S103, if a database alarm instruction is triggered, alarm information is generated according to the monitoring results of each monitoring sub-item, and the alarm information is sent to the alarm contact group according to a preset alarm method.
目前,PostgreSQL数据库的监控方式为运维人员使用监控工具,配置监控策略监控数据库,针对在不同应用系统下使用的数据库,运维人员需要配置不同的监控策略,数据库监控的适用性和可靠性较低,影响数据库的监控效率。考虑到上述问题,本实施例中提出一种数据库监控方法,以下详细介绍数据库监控方法的具体步骤:At present, the monitoring method of the PostgreSQL database is that the operation and maintenance personnel use monitoring tools and configure monitoring policies to monitor the database. For the databases used in different application systems, the operation and maintenance personnel need to configure different monitoring strategies. The applicability and reliability of database monitoring are relatively low. Low, affecting the monitoring efficiency of the database. In view of the above problems, a database monitoring method is proposed in this embodiment. The specific steps of the database monitoring method are detailed below:
步骤S101,接收待监控数据库的连接配置信息,并依据连接配置信息,对预设监控模板集中的连接对象进行配置,以获取当前监控模板集;Step S101: Receive connection configuration information of a database to be monitored, and configure connection objects in a preset monitoring template set according to the connection configuration information to obtain a current monitoring template set;
本实施例中,当监测到运维人员触发的监控数据集的配置指令时,设备显示连接对象配置界面,并接收运维人员基于该连接对象配置界面输入的待监控数据库的连接配置信息。其中,该连接配置信息包括但不限于待监控数据库的所属系统、系统所在分组、系统所属部门或子公司、告警联系组、PostgreSQL数据库主机IP、PostgreSQL数据库主机端口、数据库名称、数据库登录用户和数据库登录密码,该连接对象配置界面显示有对象名称和参数说明,且待监控数据库的所属系统、系统所在分组、系统所属部门或子公司和告警联系组的参数说明为告警附属信息,而PostgreSQL数据库主机IP、PostgreSQL数据库主机端口、数据库名称、数据库登录用户和数据库登录密码的参数说明为监控数据库配置信息。In this embodiment, when the configuration instruction of the monitoring data set triggered by the operation and maintenance personnel is detected, the device displays a connection object configuration interface, and receives the connection configuration information of the database to be monitored input by the operation and maintenance personnel based on the connection object configuration interface. The connection configuration information includes but is not limited to the system to which the database to be monitored belongs, the system's group, the department or subsidiary of the system, the alarm contact group, the PostgreSQL database host IP, the PostgreSQL database host port, the database name, the database login user, and the database. Login password, the connection object configuration interface displays the object name and parameter description, and the parameter description of the system to which the database to be monitored belongs, the system's group, the department or subsidiary of the system, and the alarm contact group are alarm auxiliary information, and the PostgreSQL database host The parameters of IP, PostgreSQL database host port, database name, database login user, and database login password are for monitoring database configuration information.
设备接收待监控数据库的连接配置信息,并依据连接配置信息,对预设监控模板集中的连接对象进行配置,以获取当前监控模板集,即对预设监控模板集中的待监控数据库的所属系统、系统所在分组、系统所属部门或子公司、告警联系组、PostgreSQL数据库主机IP、PostgreSQL数据库主机端口、数据库名称、数据库登录用户和数据库登录密码进行配置。The device receives the connection configuration information of the database to be monitored, and configures the connection objects in the preset monitoring template set according to the connection configuration information to obtain the current monitoring template set, that is, the system to which the database to be monitored belongs in the preset monitoring template set, Configure the system group, system department or subsidiary, alarm contact group, PostgreSQL database host IP, PostgreSQL database host port, database name, database login user, and database login password.
其中,预设监控模板集包括但不限于数据库可用性监控子项的监控SQL语句、应用SQL执行效率监控子项的监控SQL语句、后台作业执行情况监控子项的监控SQL语句、数据库连接数监控子项的监控SQL语句以及数据库锁监控子项的监控SQL语句。数据库可用性监控子项的监控SQL语句用于监控数据库是否可以接收到外部请求、应用SQL执行效率监控子项的监控SQL语句用于通过数据库快照信息,确定是否存在执行效率低于预设效率的应用SQL以及用于通过pg_stat_activity视图获取应用SQL的当前执行时间,确定是否存在当前执行时间超过指定时长的应用SQL;后台作业执行情况监控子项的监控SQL语句用于在PostgreSQL数据库中创建函数quartzchk,
再调用函数select * from
quartzchk查询后台作业执行情况;数据库连接数监控子项的监控SQL语句用于监控数据库的当前连接总数占数据库最大允许连接数的比例是否超过既定阈值;数据库锁监控子项的监控SQL语句用于监控数据库是否出现数据库锁,且出现数据库锁时,通过pg_locks和pg_stat_activity视图进行关联查询,细化各个SQL语句锁状态。The preset monitoring template set includes, but is not limited to, the monitoring SQL statement of the database availability monitoring sub-item, the monitoring SQL statement of the application SQL execution efficiency monitoring sub-item, the monitoring SQL statement of the background job execution monitoring sub-item, and the database connection number monitoring sub-item. The item's monitoring SQL statement and the database lock monitoring child item's monitoring SQL statement. The monitoring SQL statement of the database availability monitoring sub-item is used to monitor whether the database can receive external requests, and the SQL execution efficiency monitoring sub-item is used to determine whether there are applications with execution efficiency lower than the preset efficiency through database snapshot information. SQL and used to obtain the current execution time of the application SQL through the pg_stat_activity view to determine whether there is any application SQL whose current execution time exceeds the specified time; the monitoring SQL statement of the background job execution monitoring sub-item is used to create the function quartzchk in the PostgreSQL database,
Then call the function select * from
quartzchk queries the background job execution status; the monitoring SQL statement of the database connection number monitoring sub-item is used to monitor whether the current total number of connections in the database accounts for the maximum allowable number of connections in the database exceeds a predetermined threshold; the monitoring SQL statement of the database lock monitoring sub-item is used to monitor Whether a database lock occurs in the database, and when a database lock occurs, perform a related query through the pg_locks and pg_stat_activity views to refine the lock status of each SQL statement.
具体地,设备获取预设监控模板集中各连接对象的标识字段,并依据各连接对象的标识字段,从该连接配置信息中获取各连接对象的对应配置参数,即连接配置信息中的配置参数与标识字段具备对应关系,通过各连接对象的标识字段可查询获取到各连接对象的对应配置参数,然后依据各连接对象的对应配置参数,对预设监控模板集中的连接对象进行配置,以获取当前监控模板集,即将预设监控模板集中的各连接对象的具体参数配置为对应的配置参数。Specifically, the device obtains an identification field of each connection object in a preset monitoring template set, and obtains corresponding configuration parameters of each connection object from the connection configuration information according to the identification field of each connection object, that is, the configuration parameters in the connection configuration information and The identification fields have a corresponding relationship. The corresponding configuration parameters of each connection object can be obtained through the identification fields of each connection object, and then according to the corresponding configuration parameters of each connection object, the connection objects in the preset monitoring template set are configured to obtain the current The monitoring template set, that is, the specific parameters of each connection object in the preset monitoring template set is configured as corresponding configuration parameters.
步骤S102,在待监控数据库中,执行当前监控模板集中各监控子项的监控SQL语句,并依据各监控子项的监控结果确定是否触发数据库告警指令;Step S102: In the database to be monitored, execute a monitoring SQL statement of each monitoring item in the current monitoring template set, and determine whether to trigger a database alarm instruction according to the monitoring result of each monitoring item;
本实施例中,在配置完预设模板集中待监控数据库的连接对象之后,设备在待监控数据库中,执行当前监控模板集中各监控子项的监控SQL语句,并依据各监控子项的监控结果确定是否触发数据库告警指令。具体地,执行数据库可用性监控子项的监控SQL语句,监控数据库是否可以接收到外部请求,如果监控到数据库无法接收到外部请求,则监控结果为数据库接入异常,如果监控到数据库可以接收到外部请求,则监控结果为数据库接入正常;In this embodiment, after the connection objects of the database to be monitored in the preset template set are configured, the device executes the monitoring SQL statement of each monitoring sub-item in the current monitoring template set in the database to be monitored, and according to the monitoring results of each monitoring sub-item Determines whether a database alert command is triggered. Specifically, the monitoring SQL statement of the database availability monitoring sub-item is executed to monitor whether the database can receive external requests. If the database cannot receive external requests, the monitoring result is an abnormal database access. If the database is monitored, external data can be received. Request, the monitoring result is that the database access is normal;
执行应用SQL执行效率监控子项的监控SQL语句,监控数据库快照信息,统计最近指定天数内的应用SQL执行情况,确定是否存在执行效率低于预设效率的应用SQL以及通过pg_stat_activity视图获取应用SQL的当前执行时间,确定是否存在当前执行时间超过指定时长的应用SQL,如果存在执行效率低于预设效率的应用SQL或者存在当前执行时间超过指定时长的应用SQL,则监控结果为执行效率低于预设效率的应用SQL或当前执行时间超过指定时长的应用SQL,即SQL执行效率异常,如果各应用SQL的执行效率均高于或等于预设效率,且各应用SQL的当前执行时间均不超过指定时长,则监控结果为SQL执行效率正常;Monitor SQL statements of the application SQL execution efficiency monitoring sub-item, monitor database snapshot information, count the application SQL execution in the most recent specified number of days, determine whether there is application SQL with an execution efficiency lower than the preset efficiency, and obtain the application SQL through the pg_stat_activity view The current execution time determines whether there is any application SQL whose current execution time exceeds the specified duration. If there is an application SQL whose execution efficiency is lower than the preset efficiency or an application SQL whose current execution time exceeds the specified time, the monitoring result is that the execution efficiency is lower than the Efficient application SQL or application SQL whose current execution time exceeds a specified time, that is, SQL execution efficiency is abnormal. If the execution efficiency of each application SQL is higher than or equal to a preset efficiency, and the current execution time of each application SQL does not exceed the specified Time, the monitoring result is that the SQL execution efficiency is normal;
执行后台作业执行情况监控子项的监控SQL语句,在PostgreSQL数据库中创建函数quartzchk,
再调用函数select * from
quartzchk查询后台作业执行情况,并监控结果为后台作用执行情况;其中,利用先创建函数quartzchk,,再调用函数select * from
quartzchk的方式查询后台作业执行情况时,可避免监控无后台作业的系统时,出现的SQL语句报错现象,提高适用性;Execute the monitoring SQL statements of the background job execution monitoring sub-item, create a function quartzchk in the PostgreSQL database,
Then call the function select * from
quartzchk queries the background job execution and monitors the results for the background role execution; among them, the function quartzchk is created first, and then the function select * from is called
The quartzchk method can be used to query the execution of background jobs, which can avoid the SQL statement error when monitoring the system without background jobs and improve the applicability;
执行数据库连接数监控子项的监控SQL语句,监控数据库的当前连接总数占数据库最大允许连接数的比例是否超过预设阈值,如果数据库的当前连接总数占数据库最大允许连接数的比例超过预设阈值,则监控结果为各用户的连接数,且数据库超负荷,如果数据库的当前连接总数占数据库最大允许连接数的比例不超过既定阈值,则监控结果为数据库未超负荷;Execute the monitoring SQL statement of the database connection number monitoring sub-item to monitor whether the proportion of the current total number of connections in the database to the maximum allowed number of connections in the database exceeds a preset threshold. If the proportion of the total number of current connections in the database to the maximum allowed number of connections in the database exceeds a preset threshold , The monitoring result is the number of connections for each user, and the database is overloaded. If the proportion of the current total number of connections in the database to the maximum allowed number of connections in the database does not exceed a predetermined threshold, the monitoring result is that the database is not overloaded;
执行数据库锁监控子项的监控SQL语句,监控数据库中是否存在锁状态的SQL语句,如果数据库存在锁状态的SQL语句,则通过pg_locks和pg_stat_activity视图进行关联查询,细化该SQL语句的锁状态,监控结果包括产生锁的进程的PID、锁模式以及锁的事务信息,如果数据库不存在锁状态的SQL语句,则不生成监控结果,其中,锁模式包括AccessShareLock、RowShareLock、RowExclusiveLock、ShareUpdateExclusiveLock、ShareLock、ShareRowExclusiveLock、ExclusiveLock和AccessExclusiveLock等。Execute the monitoring SQL statement of the database lock monitoring sub-item to monitor whether there is a lock status SQL statement in the database. If there is a lock status SQL statement in the database, use the pg_locks and pg_stat_activity views to perform related queries to refine the lock status of the SQL statement. The monitoring results include the PID of the process that generated the lock, the lock mode, and the transaction information of the lock. If the database does not have SQL statements in the lock state, no monitoring results are generated. Among them, the lock mode includes AccessShareLock, RowShareLock, RowExclusiveLock, ShareUpdateExclusiveLock, ShareLock, ShareRowExclusiveLock , ExclusiveLock and AccessExclusiveLock.
具体地,设备确定各监控子项中是否存在至少一监控子项的监控结果位于预设监控结果组中,若各监控子项中存在至少一监控子项的监控结果位于预设监控结果组中,则触发数据库告警指令,否则不触发数据告警指令,即各监控子项的监控结果均不位于预设监控结果组中,则不触发数据告警指令。需要说明的是,上述预设监控结果组可由本领域技术人员基于实际情况进行设置,本实施例对此不作具体限定。Specifically, the device determines whether the monitoring result of at least one monitoring sub-item in each monitoring sub-item is located in a preset monitoring result group, and if the monitoring result of at least one monitoring sub-item in each monitoring sub-item is located in a preset monitoring result group , The database alarm instruction is triggered, otherwise the data alarm instruction is not triggered, that is, the monitoring results of each monitoring sub-item are not in the preset monitoring result group, and the data alarm instruction is not triggered. It should be noted that the above-mentioned preset monitoring result group may be set by a person skilled in the art based on actual conditions, which is not specifically limited in this embodiment.
步骤S103,若触发数据库告警指令,则依据各监控子项的监控结果生成告警信息,并按照预设的告警方式将告警信息发送给告警联系组。In step S103, if a database alarm instruction is triggered, alarm information is generated according to the monitoring results of each monitoring sub-item, and the alarm information is sent to the alarm contact group according to a preset alarm method.
本实施例中,如果触发数据库告警指令,则依据各监控子项的监控结果生成告警信息,并按照预设的告警方式将该告警信息发送给告警联系组。具体地,获取预设告警信息模板,并将各监控子项的监控结果填充至所述预设告警信息模板中,以生成告警信息,即获取该预设告警信息模板中的各监控子项的位置信息,并依据各监控子项的位置信息,确定各监控子项在预设告警信息模板中的所属填充位置,且将各监控子项的监控结果填充至预设告警信息模板中的对应所属填充位置,以生成告警信息。其中,告警信息包括但不限于所属系统、系统所在分组、系统所属部门或子公司、告警联系组和异常信息,且该异常信息包括但不限于数据库断开连接、执行效率低的应用SQL、后台作业执行情况和锁状态的SQL语句,该告警方式包括但不限于邮件告警、短信告警和电话告警。In this embodiment, if a database alarm instruction is triggered, alarm information is generated according to the monitoring results of each monitoring sub-item, and the alarm information is sent to the alarm contact group according to a preset alarm method. Specifically, a preset alarm information template is obtained, and the monitoring result of each monitoring sub-item is filled into the preset alarm information template to generate alarm information, that is, the information of each monitoring sub-item in the preset alarm information template is obtained. Location information, and according to the location information of each monitoring sub-item, determine the filling position of each monitoring sub-item in the preset alarm information template, and fill the monitoring result of each monitoring sub-item with the corresponding affiliation in the preset alarm information template Fill in the position to generate alarm information. Among them, the alarm information includes, but is not limited to, the system to which the system belongs, the group to which the system belongs, the department or subsidiary of the system, the alarm contact group, and abnormal information, and the abnormal information includes, but is not limited to, database disconnection, inefficient application SQL, background SQL statements for job execution and lock status. The alarm methods include, but are not limited to, email alerts, SMS alerts, and phone alerts.
本实施例中,本申请接收待监控数据库的连接配置信息,并依据连接配置信息,对预设监控模板集中的连接对象进行配置,以获取当前监控模板集;在待监控数据库中,执行当前监控模板集中各监控子项的监控SQL语句,并依据各监控子项的监控结果确定是否触发数据库告警指令;若触发数据库告警指令,则依据各监控子项的监控结果生成告警信息,并按照预设的告警方式将告警信息发送给告警联系组,通过设置监控模板集,监控模板集使用于各应用系统下PostgreSQL数据库的监控,不需要运维人员配置监控策略,只需简单的配置数据库连接对象,即可实现PostgreSQL数据库的监控,有效的减低监控的部署难度,提高数据库监控的适用性。In this embodiment, the application receives the connection configuration information of the database to be monitored, and configures the connection objects in the preset monitoring template set according to the connection configuration information to obtain the current monitoring template set. In the database to be monitored, the current monitoring is performed. The template focuses on the monitoring SQL statements of each monitoring sub-item, and determines whether to trigger a database alarm command based on the monitoring results of each monitoring sub-item. If a database alarm command is triggered, an alarm message is generated based on the monitoring results of each monitoring sub-item, and according to the preset The alarm method sends alarm information to the alarm contact group. By setting a monitoring template set, the monitoring template set is used for monitoring the PostgreSQL database under each application system. There is no need for operation and maintenance personnel to configure the monitoring strategy. You only need to configure the database connection object. The monitoring of the PostgreSQL database can be realized, the deployment difficulty of the monitoring is effectively reduced, and the applicability of the database monitoring is improved.
进一步地,参照图3,基于上述第一实施例,提出了本申请数据库监控方法的第二实施例,与前述实施例的区别在于,该数据库监控方法还包括:Further, referring to FIG. 3, based on the above-mentioned first embodiment, a second embodiment of the database monitoring method of the present application is proposed. The difference from the foregoing embodiment is that the database monitoring method further includes:
步骤104、获取当前可用CPU资源,并依据当前可用CPU资源,确定数据库监控操作的执行方式是单任务执行方式,还是多任务执行方式;Step 104: Obtain the currently available CPU resources, and determine whether the execution mode of the database monitoring operation is a single-task execution mode or a multi-task execution mode according to the currently available CPU resources.
本实施例中,设备获取当前可用CPU资源,并根据当前可用CPU资源,确定数据库监控操作的执行方式是单任务执行方式,还是多任务执行方式,具体为确定当前可用CPU资源是否超过预设CPU资源,如果当前可用CPU资源超过预设CPU资源,则可以确定数据库监控操作的执行方式是多任务执行方式,如果当前可用CPU资源未超过预设CPU资源,则可以确定数据库监控操作的执行方式是单任务执行方式。In this embodiment, the device obtains the currently available CPU resources, and determines whether the execution method of the database monitoring operation is a single-task execution mode or a multi-task execution mode according to the currently available CPU resources, and specifically determines whether the currently available CPU resources exceed a preset CPU Resources, if the currently available CPU resources exceed the preset CPU resources, you can determine that the database monitoring operation is performed in a multi-tasking execution mode, and if the currently available CPU resources do not exceed the preset CPU resources, you can determine that the database monitoring operation is performed as Single task execution.
步骤105、若数据库监控操作的执行方式是多任务执行方式,则依据当前可用CPU资源确定同步执行任务数,并按照所述同步执行任务数,执行对应数量的监控子项的监控SQL语句。Step 105: If the execution mode of the database monitoring operation is a multi-task execution mode, determine the number of synchronous execution tasks according to the currently available CPU resources, and execute the monitoring SQL statements of the corresponding number of monitoring sub-items according to the number of synchronous execution tasks.
本实施例中,如果数据库监控操作的执行方式是多任务执行方式,则依据当前可用CPU资源确定同步执行任务数,即获取预存的当前可用CPU资源与同步执行页面数的映射关系表,并从映射关系表中,查询与当前可用CPU资源对应的同步执行任务数,并按照同步执行任务数,执行对应数量的监控子项的监控SQL语句,即设备按照预设执行顺序,在待监控数据库中,执行与同步执行任务数对应数量的监控子项的监控SQL语句。如果数据库监控操作的执行方式是单任务执行方式,则每次执行一监控子项的监控SQL语句,即设备按照预设执行顺序,在待监控数据库中,执行当前监控模板集中各监控子项的监控SQL语句。需要说明的是,上述预设执行顺序可由本领域技术人员基于实际情况进行设置,本实施例对此不作具体限定。In this embodiment, if the execution mode of the database monitoring operation is a multi-tasking execution mode, the number of synchronous execution tasks is determined according to the currently available CPU resources, that is, a pre-stored mapping table of the currently available CPU resources and the number of synchronous execution pages is obtained, and In the mapping relationship table, query the number of synchronous execution tasks corresponding to the currently available CPU resources, and execute the monitoring SQL statements of the corresponding number of monitoring sub-items according to the number of synchronous execution tasks, that is, the device performs the preset execution order in the database to be monitored Execute the monitoring SQL statements of the monitoring sub-items corresponding to the number of synchronously executed tasks. If the database monitoring operation is performed in a single task, the monitoring SQL statements of the monitoring sub-items are executed one at a time, that is, the device executes the monitoring sub-items of the current monitoring template set in the database to be monitored in the preset execution order. Monitor SQL statements. It should be noted that the foregoing preset execution order may be set by a person skilled in the art based on actual conditions, and this embodiment does not specifically limit this.
其中,预设CPU资源可根据CPU总资源来设置,或者由用户根据具体需要而设置。当CPU资源未超过预设CPU资源时,可根据可用CPU资源与同步页面数量之间的映射关系确定可同时执行的同步页面数量,如在映射关系中,当可用CPU资源小于A时,对应可同时执行的同步页面数量为2;当可用CPU资源大于或者等于A,小于B时,对应可同时执行的同步页面数量为3;当可用CPU资源大于或者等于B,小于C时,对应可同时执行的同步页面数量为4,其中,A<B<C。The preset CPU resources can be set according to the total CPU resources, or set by the user according to specific needs. When the CPU resources do not exceed the preset CPU resources, the number of synchronous pages that can be executed simultaneously can be determined according to the mapping relationship between the available CPU resources and the number of synchronized pages. For example, in the mapping relationship, when the available CPU resources are less than A, the corresponding The number of simultaneous pages that are executed simultaneously is 2; when the available CPU resources are greater than or equal to A and less than B, the number of simultaneous pages that can be executed simultaneously is 3; when the available CPU resources are greater than or equal to B and less than C, the corresponding can be executed simultaneously The number of synchronized pages is 4, where A <B <C.
本实施例中,本申请通过设备的当前可用CPU资源确定同步执行的监控子项的监控SQL语句,设备可同时执行多个监控子项的监控SQL语句,有效的提高数据库监控效率。In this embodiment, the present application determines the monitoring SQL statements of the monitoring sub-items that are executed synchronously based on the currently available CPU resources of the device. The device can simultaneously execute the monitoring SQL statements of multiple monitoring sub-items, effectively improving the database monitoring efficiency.
此外,本申请实施例还提供一种数据库监控装置。In addition, an embodiment of the present application further provides a database monitoring device.
参照图4,图4为本申请数据库监控装置第一实施例的功能模块示意图。Referring to FIG. 4, FIG. 4 is a schematic diagram of functional modules of a first embodiment of a database monitoring apparatus of the present application.
本申请数据库监控装置为虚拟装置,存储于图1所示数据库监控设备的存储器1005中,用于实现计算机可读指令的所有功能;接收待监控数据库的连接配置信息,并依据所述连接配置信息,对预设监控模板集中的连接对象进行配置,以获取当前监控模板集;在所述待监控数据库中,执行所述当前监控模板集中各监控子项的监控SQL语句,并依据各监控子项的监控结果确定是否触发数据库告警指令;若触发数据库告警指令,则依据各监控子项的监控结果生成告警信息,并按照预设的告警方式将所述告警信息发送给告警联系组。The database monitoring device of the present application is a virtual device, which is stored in the memory 1005 of the database monitoring device shown in FIG. 1 and is used to implement all the functions of the computer-readable instructions; receiving the connection configuration information of the database to be monitored, and according to the connection configuration information To configure the connection objects in the preset monitoring template set to obtain the current monitoring template set; in the database to be monitored, execute a monitoring SQL statement of each monitoring sub-item in the current monitoring template set, and according to each monitoring sub-item The monitoring result determines whether a database alarm instruction is triggered; if the database alarm instruction is triggered, alarm information is generated according to the monitoring results of each monitoring sub-item, and the alarm information is sent to the alarm contact group according to a preset alarm method.
具体的,本实施例中,所述数据库监控装置包括:Specifically, in this embodiment, the database monitoring apparatus includes:
配置模块101,用于接收待监控数据库的连接配置信息,并依据所述连接配置信息,对预设监控模板集中的连接对象进行配置,以获取当前监控模板集;A configuration module 101 is configured to receive connection configuration information of a database to be monitored, and configure connection objects in a preset monitoring template set according to the connection configuration information to obtain a current monitoring template set;
执行模块102,用于在所述待监控数据库中,执行所述当前监控模板集中各监控子项的监控SQL语句,并依据各监控子项的监控结果确定是否触发数据库告警指令;The execution module 102 is configured to execute, in the database to be monitored, a monitoring SQL statement of each monitoring sub-item in the current monitoring template set, and determine whether to trigger a database alarm instruction according to a monitoring result of each monitoring sub-item;
告警模块103,用于若触发数据库告警指令,则依据各监控子项的监控结果生成告警信息,并按照预设的告警方式将所述告警信息发送给告警联系组。The alarm module 103 is configured to generate alarm information according to the monitoring result of each monitoring sub-item if a database alarm instruction is triggered, and send the alarm information to an alarm contact group according to a preset alarm method.
进一步地,所述配置模块101还用于:Further, the configuration module 101 is further configured to:
获取预设监控模板集中各连接对象的标识字段,并依据各连接对象的标识字段,从所述连接配置信息中获取各连接对象的对应配置参数;Obtaining an identification field of each connection object in a preset monitoring template set, and obtaining corresponding configuration parameters of each connection object from the connection configuration information according to the identification field of each connection object;
依据各连接对象的对应配置参数,对预设监控模板集中的连接对象进行配置,以获取当前监控模板集。Configure the connection objects in the preset monitoring template set according to the corresponding configuration parameters of each connection object to obtain the current monitoring template set.
进一步地,所述执行模块102还用于:Further, the execution module 102 is further configured to:
确定各监控子项中是否存在至少一监控子项的监控结果位于预设监控结果组中;Determining whether the monitoring result of at least one monitoring sub-item in each monitoring sub-item is in a preset monitoring result group;
若各监控子项中存在至少一监控子项的监控结果位于预设监控结果组中,则触发数据库告警指令,否则不触发数据告警指令。If the monitoring result of at least one monitoring sub-item in each monitoring sub-item is in a preset monitoring result group, a database alarm command is triggered; otherwise, a data alarm command is not triggered.
进一步地,所述告警模块103还用于:Further, the alarm module 103 is further configured to:
获取预设告警信息模板,并将各监控子项的监控结果填充至所述预设告警信息模板中,以生成告警信息。Obtain a preset alarm information template, and fill the monitoring results of each monitoring sub-item into the preset alarm information template to generate alarm information.
进一步地,所述告警模块103还用于:Further, the alarm module 103 is further configured to:
获取所述预设告警信息模板中的各监控子项的位置信息;Acquiring position information of each monitoring sub-item in the preset alarm information template;
依据各监控子项的位置信息,确定各监控子项在预设告警信息模板中的所属填充位置;Determine the filling position of each monitoring sub-item in the preset alarm information template according to the location information of each monitoring sub-item;
将各监控子项的监控结果填充至预设告警信息模板中的对应所属填充位置。Fill the monitoring results of each monitoring sub-item to the corresponding filling position in the preset alarm information template.
进一步地,所述数据库监控装置还包括:Further, the database monitoring device further includes:
确定模块,用于获取当前可用CPU资源,并依据当前可用CPU资源,确定数据库监控操作的执行方式是单任务执行方式,还是多任务执行方式;A determining module for obtaining the currently available CPU resources and determining whether the execution mode of the database monitoring operation is a single-task execution mode or a multi-task execution mode according to the currently available CPU resources;
所述执行模块102,还用于若数据库监控操作的执行方式是单任务执行方式,则每次执行一监控子项的监控SQL语句;The execution module 102 is further configured to execute a monitoring SQL statement of a monitoring sub-item each time if the execution mode of the database monitoring operation is a single task execution mode;
所述执行模块102,还用于若数据库监控操作的执行方式是多任务执行方式,则依据当前可用CPU资源确定同步执行任务数,并按照所述同步执行任务数,执行对应数量的监控子项的监控SQL语句。The execution module 102 is further configured to: if the database monitoring operation is performed in a multi-tasking mode, determine the number of tasks to be executed synchronously according to the currently available CPU resources, and execute a corresponding number of monitoring sub-items according to the number of tasks executed synchronously Monitor SQL statements.
进一步地,所述执行模块102,还用于:Further, the execution module 102 is further configured to:
获取预存的当前可用CPU资源与同步执行任务数的映射关系表,并从所述映射关系表中,查询与当前可用CPU资源对应的同步执行任务数。Obtain a pre-stored mapping table of currently available CPU resources and the number of synchronous execution tasks, and query the number of synchronous execution tasks corresponding to the currently available CPU resources from the mapping relationship table.
其中,上述数据库监控装置中各个模块的功能实现与上述数据库监控方法实施例中各步骤相对应,其功能和实现过程在此处不再一一赘述。The function implementation of each module in the above-mentioned database monitoring apparatus corresponds to each step in the above-mentioned embodiment of the database monitoring method, and the functions and implementation processes thereof are not repeated here one by one.
此外,本申请实施例还提供一种可读存储介质,该可读存储介质可以为非易失性可读存储介质。In addition, an embodiment of the present application further provides a readable storage medium, and the readable storage medium may be a non-volatile readable storage medium.
本申请可读存储介质上存储有计算机可读指令,其中所述计算机可读指令被处理器执行时,实现如上述的数据库监控方法的步骤。Computer-readable instructions are stored on the readable storage medium of this application, and when the computer-readable instructions are executed by a processor, the steps of the database monitoring method as described above are implemented.
其中,计算机可读指令被执行时所实现的方法可参照本申请数据库监控方法的各个实施例,此处不再赘述。For the method implemented when the computer-readable instructions are executed, reference may be made to various embodiments of the database monitoring method of the present application, and details are not described herein again.
需要说明的是,在本文中,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者系统不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者系统所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括该要素的过程、方法、物品或者系统中还存在另外的相同要素。It should be noted that, in this article, the terms "including", "including" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or system including a series of elements includes not only those elements, It also includes other elements not explicitly listed, or elements inherent to such a process, method, article, or system. Without more restrictions, an element limited by the sentence "including a ..." does not exclude the existence of other identical elements in the process, method, article, or system that includes the element.
上述本申请实施例序号仅仅为了描述,不代表实施例的优劣。The above-mentioned serial numbers of the embodiments of the present application are merely for description, and do not represent the superiority or inferiority of the embodiments.
通过以上的实施方式的描述,本领域的技术人员可以清楚地了解到上述实施例方法可借助软件加必需的通用硬件平台的方式来实现,当然也可以通过硬件,但很多情况下前者是更佳的实施方式。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品存储在如上所述的一个存储介质(如ROM/RAM、磁碟、光盘)中,包括若干指令用以使得一台终端设备(可以是手机,计算机,服务器,空调器,或者网络设备等)执行本申请各个实施例所述的方法。Through the description of the above embodiments, those skilled in the art can clearly understand that the methods in the above embodiments can be implemented by means of software plus a necessary universal hardware platform, and of course, also by hardware, but in many cases the former is better. Implementation. Based on such an understanding, the technical solution of this application that is essentially or contributes to the existing technology can be embodied in the form of a software product. The computer software product is stored in a storage medium (such as ROM / RAM) as described above. , Magnetic disk, optical disc), including a number of instructions for causing a terminal device (which may be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to execute the methods described in the embodiments of the present application.
以上仅为本申请的优选实施例,并非因此限制本申请的专利范围,凡是利用本申请说明书及附图内容所作的等效结构或等效流程变换,或直接或间接运用在其他相关的技术领域,均同理包括在本申请的专利保护范围内。The above are only preferred embodiments of the present application, and thus do not limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made by using the description and drawings of the present application, or directly or indirectly used in other related technical fields Are included in the scope of patent protection of this application.
Claims (20)
- 一种数据库监控方法,其特征在于,所述数据库监控方法包括以下步骤: A database monitoring method, characterized in that the database monitoring method includes the following steps:接收待监控数据库的连接配置信息,并依据所述连接配置信息,对预设监控模板集中的连接对象进行配置,以获取当前监控模板集;Receiving connection configuration information of a database to be monitored, and configuring connection objects in a preset monitoring template set according to the connection configuration information to obtain a current monitoring template set;在所述待监控数据库中,执行所述当前监控模板集中各监控子项的监控SQL语句,并依据各监控子项的监控结果确定是否触发数据库告警指令;In the database to be monitored, execute a monitoring SQL statement of each monitoring sub-item in the current monitoring template set, and determine whether to trigger a database alarm instruction according to the monitoring result of each monitoring sub-item;若触发数据库告警指令,则依据各监控子项的监控结果生成告警信息,并按照预设的告警方式将所述告警信息发送给告警联系组。If a database alarm instruction is triggered, alarm information is generated according to the monitoring results of each monitoring sub-item, and the alarm information is sent to the alarm contact group according to a preset alarm method.
- 如权利要求1所述的数据库监控方法,其特征在于,依据所述连接配置信息,对预设监控模板集中的连接对象进行配置,以获取当前监控模板集的步骤包括:The database monitoring method according to claim 1, wherein the step of configuring the connection objects in the preset monitoring template set to obtain the current monitoring template set according to the connection configuration information comprises:获取预设监控模板集中各连接对象的标识字段,并依据各连接对象的标识字段,从所述连接配置信息中获取各连接对象的对应配置参数;Obtaining an identification field of each connection object in a preset monitoring template set, and obtaining corresponding configuration parameters of each connection object from the connection configuration information according to the identification field of each connection object;依据各连接对象的对应配置参数,对预设监控模板集中的连接对象进行配置,以获取当前监控模板集。Configure the connection objects in the preset monitoring template set according to the corresponding configuration parameters of each connection object to obtain the current monitoring template set.
- 如权利要求1所述的数据库监控方法,其特征在于,所述依据各监控子项的监控结果确定是否触发数据库告警指令的步骤包括:The database monitoring method according to claim 1, wherein the step of determining whether to trigger a database alarm instruction according to the monitoring results of each monitoring sub-item comprises:确定各监控子项中是否存在至少一监控子项的监控结果位于预设监控结果组中;Determining whether the monitoring result of at least one monitoring sub-item in each monitoring sub-item is in a preset monitoring result group;若各监控子项中存在至少一监控子项的监控结果位于预设监控结果组中,则触发数据库告警指令,否则不触发数据告警指令。If the monitoring result of at least one monitoring sub-item in each monitoring sub-item is in a preset monitoring result group, a database alarm command is triggered; otherwise, a data alarm command is not triggered.
- 如权利要求1所述的数据库监控方法,其特征在于,所述依据各监控子项的监控结果生成告警信息的步骤包括:The database monitoring method according to claim 1, wherein the step of generating alarm information according to a monitoring result of each monitoring sub-item comprises:获取预设告警信息模板,并将各监控子项的监控结果填充至所述预设告警信息模板中,以生成告警信息。Obtain a preset alarm information template, and fill the monitoring results of each monitoring sub-item into the preset alarm information template to generate alarm information.
- 如权利要求4所述的数据库监控方法,其特征在于,所述将各监控子项的监控结果填充至所述预设告警信息模板中,以生成告警信息的步骤包括:The database monitoring method according to claim 4, wherein the step of filling the monitoring result of each monitoring sub-item into the preset alarm information template to generate the alarm information comprises:获取所述预设告警信息模板中的各监控子项的位置信息;Acquiring position information of each monitoring sub-item in the preset alarm information template;依据各监控子项的位置信息,确定各监控子项在预设告警信息模板中的所属填充位置;Determine the filling position of each monitoring sub-item in the preset alarm information template according to the location information of each monitoring sub-item;将各监控子项的监控结果填充至预设告警信息模板中的对应所属填充位置。Fill the monitoring results of each monitoring sub-item to the corresponding filling position in the preset alarm information template.
- 如权利要求1所述的数据库监控方法,其特征在于,所述数据库监控方法还包括:The database monitoring method according to claim 1, wherein the database monitoring method further comprises:获取当前可用CPU资源,并依据当前可用CPU资源,确定数据库监控操作的执行方式是否为多任务执行方式;Obtain the currently available CPU resources, and determine whether the execution mode of the database monitoring operation is a multi-tasking execution mode based on the currently available CPU resources;若数据库监控操作的执行方式是多任务执行方式,则依据当前可用CPU资源确定同步执行任务数,并按照所述同步执行任务数,执行对应数量的监控子项的监控SQL语句。If the execution mode of the database monitoring operation is a multi-tasking execution mode, the number of synchronously executed tasks is determined according to the currently available CPU resources, and the monitoring SQL statements of the corresponding number of monitoring sub-items are executed according to the number of synchronously executed tasks.
- 如权利要求6所述的数据库监控方法,其特征在于,所述根据当前可用CPU资源确定同步执行页面数的步骤包括:The database monitoring method according to claim 6, wherein the step of determining the number of synchronously executed pages according to the currently available CPU resources comprises:获取预存的当前可用CPU资源与同步执行任务数的映射关系表,并从所述映射关系表中,查询与当前可用CPU资源对应的同步执行任务数。Obtain a pre-stored mapping table of currently available CPU resources and the number of synchronous execution tasks, and query the number of synchronous execution tasks corresponding to the currently available CPU resources from the mapping relationship table.
- 一种数据库监控装置,其特征在于,所述数据库监控装置包括:A database monitoring device, characterized in that the database monitoring device includes:配置模块,用于接收待监控数据库的连接配置信息,并依据所述连接配置信息,对预设监控模板集中的连接对象进行配置,以获取当前监控模板集;A configuration module, configured to receive connection configuration information of a database to be monitored, and configure connection objects in a preset monitoring template set according to the connection configuration information to obtain a current monitoring template set;执行模块,用于在所述待监控数据库中,执行所述当前监控模板集中各监控子项的监控SQL语句,并依据各监控子项的监控结果确定是否触发数据库告警指令;An execution module, configured to execute, in the database to be monitored, a monitoring SQL statement of each monitoring sub-item in the current monitoring template set, and determine whether to trigger a database alarm instruction according to a monitoring result of each monitoring sub-item;告警模块,用于若触发数据库告警指令,则依据各监控子项的监控结果生成告警信息,并按照预设的告警方式将所述告警信息发送给告警联系组。The alarm module is configured to generate alarm information according to the monitoring result of each monitoring sub-item if a database alarm instruction is triggered, and send the alarm information to an alarm contact group according to a preset alarm method.
- 如权利要求8所述的数据库监控装置,其特征在于,所述配置模块还用于:The database monitoring device according to claim 8, wherein the configuration module is further configured to:获取预设监控模板集中各连接对象的标识字段,并依据各连接对象的标识字段,从所述连接配置信息中获取各连接对象的对应配置参数;Obtaining an identification field of each connection object in a preset monitoring template set, and obtaining corresponding configuration parameters of each connection object from the connection configuration information according to the identification field of each connection object;依据各连接对象的对应配置参数,对预设监控模板集中的连接对象进行配置,以获取当前监控模板集。Configure the connection objects in the preset monitoring template set according to the corresponding configuration parameters of each connection object to obtain the current monitoring template set.
- 如权利要求8所述的数据库监控装置,其特征在于,所述执行模块还用于:The database monitoring device according to claim 8, wherein the execution module is further configured to:确定各监控子项中是否存在至少一监控子项的监控结果位于预设监控结果组中;Determining whether the monitoring result of at least one monitoring sub-item in each monitoring sub-item is in a preset monitoring result group;若各监控子项中存在至少一监控子项的监控结果位于预设监控结果组中,则触发数据库告警指令,否则不触发数据告警指令。If the monitoring result of at least one monitoring sub-item in each monitoring sub-item is in a preset monitoring result group, a database alarm command is triggered; otherwise, a data alarm command is not triggered.
- 如权利要求8所述的数据库监控装置,其特征在于,所述告警模块还用于:The database monitoring device according to claim 8, wherein the alarm module is further configured to:获取预设告警信息模板,并将各监控子项的监控结果填充至所述预设告警信息模板中,以生成告警信息。Obtain a preset alarm information template, and fill the monitoring results of each monitoring sub-item into the preset alarm information template to generate alarm information.
- 如权利要求11所述的数据库监控装置,其特征在于,所述告警模块还用于:The database monitoring device according to claim 11, wherein the alarm module is further configured to:获取所述预设告警信息模板中的各监控子项的位置信息;Acquiring position information of each monitoring sub-item in the preset alarm information template;依据各监控子项的位置信息,确定各监控子项在预设告警信息模板中的所属填充位置;Determine the filling position of each monitoring sub-item in the preset alarm information template according to the location information of each monitoring sub-item;将各监控子项的监控结果填充至预设告警信息模板中的对应所属填充位置。Fill the monitoring results of each monitoring sub-item to the corresponding filling position in the preset alarm information template.
- 一种数据库监控设备,其特征在于,所述数据库监控设备包括处理器、存储器、以及存储在所述存储器上并可被所述处理器执行的计算机可读指令,其中所述计算机可读指令被所述处理器执行时,实现以下步骤:A database monitoring device, characterized in that the database monitoring device includes a processor, a memory, and computer-readable instructions stored on the memory and executable by the processor, wherein the computer-readable instructions are When the processor executes, the following steps are implemented:接收待监控数据库的连接配置信息,并依据所述连接配置信息,对预设监控模板集中的连接对象进行配置,以获取当前监控模板集;Receiving connection configuration information of a database to be monitored, and configuring connection objects in a preset monitoring template set according to the connection configuration information to obtain a current monitoring template set;在所述待监控数据库中,执行所述当前监控模板集中各监控子项的监控SQL语句,并依据各监控子项的监控结果确定是否触发数据库告警指令;In the database to be monitored, execute a monitoring SQL statement of each monitoring sub-item in the current monitoring template set, and determine whether to trigger a database alarm instruction according to the monitoring result of each monitoring sub-item;若触发数据库告警指令,则依据各监控子项的监控结果生成告警信息,并按照预设的告警方式将所述告警信息发送给告警联系组。If a database alarm instruction is triggered, alarm information is generated according to the monitoring results of each monitoring sub-item, and the alarm information is sent to the alarm contact group according to a preset alarm method.
- 如权利要求13所述的数据库监控设备,其特征在于,所述计算机可读指令被所述处理器执行时,还实现以下步骤:The database monitoring device according to claim 13, wherein when the computer-readable instructions are executed by the processor, the following steps are further implemented:获取预设监控模板集中各连接对象的标识字段,并依据各连接对象的标识字段,从所述连接配置信息中获取各连接对象的对应配置参数;Obtaining an identification field of each connection object in a preset monitoring template set, and obtaining corresponding configuration parameters of each connection object from the connection configuration information according to the identification field of each connection object;依据各连接对象的对应配置参数,对预设监控模板集中的连接对象进行配置,以获取当前监控模板集。Configure the connection objects in the preset monitoring template set according to the corresponding configuration parameters of each connection object to obtain the current monitoring template set.
- 如权利要求13所述的数据库监控设备,其特征在于,所述计算机可读指令被所述处理器执行时,还实现以下步骤:The database monitoring device according to claim 13, wherein when the computer-readable instructions are executed by the processor, the following steps are further implemented:确定各监控子项中是否存在至少一监控子项的监控结果位于预设监控结果组中;Determining whether the monitoring result of at least one monitoring sub-item in each monitoring sub-item is in a preset monitoring result group;若各监控子项中存在至少一监控子项的监控结果位于预设监控结果组中,则触发数据库告警指令,否则不触发数据告警指令。If the monitoring result of at least one monitoring sub-item in each monitoring sub-item is in a preset monitoring result group, a database alarm command is triggered; otherwise, a data alarm command is not triggered.
- 如权利要求13所述的数据库监控设备,其特征在于,所述计算机可读指令被所述处理器执行时,还实现以下步骤:The database monitoring device according to claim 13, wherein when the computer-readable instructions are executed by the processor, the following steps are further implemented:获取预设告警信息模板,并将各监控子项的监控结果填充至所述预设告警信息模板中,以生成告警信息。Obtain a preset alarm information template, and fill the monitoring results of each monitoring sub-item into the preset alarm information template to generate alarm information.
- 一种可读存储介质,其特征在于,所述可读存储介质上存储有计算机可读指令,其中所述计算机可读指令被处理器执行时,实现以下步骤:A readable storage medium is characterized in that computer-readable instructions are stored on the readable storage medium, and when the computer-readable instructions are executed by a processor, the following steps are implemented:接收待监控数据库的连接配置信息,并依据所述连接配置信息,对预设监控模板集中的连接对象进行配置,以获取当前监控模板集;Receiving connection configuration information of a database to be monitored, and configuring connection objects in a preset monitoring template set according to the connection configuration information to obtain a current monitoring template set;在所述待监控数据库中,执行所述当前监控模板集中各监控子项的监控SQL语句,并依据各监控子项的监控结果确定是否触发数据库告警指令;In the database to be monitored, execute a monitoring SQL statement of each monitoring sub-item in the current monitoring template set, and determine whether to trigger a database alarm instruction according to the monitoring result of each monitoring sub-item;若触发数据库告警指令,则依据各监控子项的监控结果生成告警信息,并按照预设的告警方式将所述告警信息发送给告警联系组。If a database alarm instruction is triggered, alarm information is generated according to the monitoring results of each monitoring sub-item, and the alarm information is sent to the alarm contact group according to a preset alarm method.
- 如权利要求17所述的可读存储介质,其中,所述计算机可读指令被所述处理器执行时,还实现以下步骤:The readable storage medium of claim 17, wherein when the computer-readable instructions are executed by the processor, the following steps are further implemented:获取预设监控模板集中各连接对象的标识字段,并依据各连接对象的标识字段,从所述连接配置信息中获取各连接对象的对应配置参数;Obtaining an identification field of each connection object in a preset monitoring template set, and obtaining corresponding configuration parameters of each connection object from the connection configuration information according to the identification field of each connection object;依据各连接对象的对应配置参数,对预设监控模板集中的连接对象进行配置,以获取当前监控模板集。Configure the connection objects in the preset monitoring template set according to the corresponding configuration parameters of each connection object to obtain the current monitoring template set.
- 如权利要求17所述的可读存储介质,其特征在于,所述计算机可读指令被所述处理器执行时,还实现以下步骤:The readable storage medium of claim 17, wherein when the computer-readable instructions are executed by the processor, the following steps are further implemented:确定各监控子项中是否存在至少一监控子项的监控结果位于预设监控结果组中;Determining whether the monitoring result of at least one monitoring sub-item in each monitoring sub-item is in a preset monitoring result group;若各监控子项中存在至少一监控子项的监控结果位于预设监控结果组中,则触发数据库告警指令,否则不触发数据告警指令。If the monitoring result of at least one monitoring sub-item in each monitoring sub-item is in a preset monitoring result group, a database alarm command is triggered; otherwise, a data alarm command is not triggered.
- 如权利要求17所述的可读存储介质,其特征在于,所述计算机可读指令被所述处理器执行时,还实现以下步骤:The readable storage medium of claim 17, wherein when the computer-readable instructions are executed by the processor, the following steps are further implemented:获取预设告警信息模板,并将各监控子项的监控结果填充至所述预设告警信息模板中,以生成告警信息。 Obtain a preset alarm information template, and fill the monitoring results of each monitoring sub-item into the preset alarm information template to generate alarm information.
Applications Claiming Priority (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810835443.0A CN109726073A (en) | 2018-07-26 | 2018-07-26 | Database monitoring method, device, equipment and readable storage medium storing program for executing |
CN201810835443.0 | 2018-07-26 |
Publications (1)
Publication Number | Publication Date |
---|---|
WO2020019405A1 true WO2020019405A1 (en) | 2020-01-30 |
Family
ID=66294587
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
PCT/CN2018/103337 WO2020019405A1 (en) | 2018-07-26 | 2018-08-30 | Database monitoring method, device and apparatus, and computer storage medium |
Country Status (2)
Country | Link |
---|---|
CN (1) | CN109726073A (en) |
WO (1) | WO2020019405A1 (en) |
Families Citing this family (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113127290B (en) * | 2019-12-31 | 2024-05-31 | 北京金山云网络技术有限公司 | Service operation index monitoring method, device and server |
CN111737233A (en) * | 2020-06-24 | 2020-10-02 | 浙江大华技术股份有限公司 | Data monitoring method and device |
CN112787858B (en) * | 2020-12-30 | 2022-05-10 | 浙江三维利普维网络有限公司 | Data model parameter configuration method and device, electronic device and storage medium |
CN113204565A (en) * | 2021-05-28 | 2021-08-03 | 中国工商银行股份有限公司 | Database monitoring method and device |
CN115118598A (en) * | 2022-06-23 | 2022-09-27 | 三六零科技集团有限公司 | Information acquisition method, device, equipment and storage medium |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101763389A (en) * | 2008-12-23 | 2010-06-30 | 中兴通讯股份有限公司 | Device and method for controlling database resource |
CN101989283A (en) * | 2009-08-04 | 2011-03-23 | 中兴通讯股份有限公司 | Monitoring method and device of performance of database |
US20120246520A1 (en) * | 2011-03-25 | 2012-09-27 | Fujitsu Limited | Monitoring method, information processing apparatus, and computer-readable medium storing monitoring program |
WO2013121529A1 (en) * | 2012-02-14 | 2013-08-22 | 株式会社日立製作所 | Computer program and monitoring device |
Family Cites Families (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US10176036B2 (en) * | 2015-10-29 | 2019-01-08 | Commvault Systems, Inc. | Monitoring, diagnosing, and repairing a management database in a data storage management system |
CN105427545B (en) * | 2015-12-30 | 2018-07-17 | 山东中创软件商用中间件股份有限公司 | Device Alarm Management method and device based on drools |
CN107797866B (en) * | 2016-05-31 | 2020-11-24 | Oppo广东移动通信有限公司 | Processor resource allocation method, mobile terminal and medium product |
CN107491371B (en) * | 2016-06-13 | 2021-03-16 | 阿里巴巴集团控股有限公司 | Deployment monitoring method and device |
CN106385331A (en) * | 2016-09-08 | 2017-02-08 | 努比亚技术有限公司 | Method and system for monitoring alarm based on log |
CN108052553B (en) * | 2017-11-29 | 2020-08-07 | 平安养老保险股份有限公司 | Method and device for generating electronic manual, computer equipment and storage medium |
-
2018
- 2018-07-26 CN CN201810835443.0A patent/CN109726073A/en active Pending
- 2018-08-30 WO PCT/CN2018/103337 patent/WO2020019405A1/en active Application Filing
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101763389A (en) * | 2008-12-23 | 2010-06-30 | 中兴通讯股份有限公司 | Device and method for controlling database resource |
CN101989283A (en) * | 2009-08-04 | 2011-03-23 | 中兴通讯股份有限公司 | Monitoring method and device of performance of database |
US20120246520A1 (en) * | 2011-03-25 | 2012-09-27 | Fujitsu Limited | Monitoring method, information processing apparatus, and computer-readable medium storing monitoring program |
WO2013121529A1 (en) * | 2012-02-14 | 2013-08-22 | 株式会社日立製作所 | Computer program and monitoring device |
Also Published As
Publication number | Publication date |
---|---|
CN109726073A (en) | 2019-05-07 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
WO2020019405A1 (en) | Database monitoring method, device and apparatus, and computer storage medium | |
WO2020048047A1 (en) | System fault warning method, apparatus, and device, and storage medium | |
WO2018214320A1 (en) | Database service logic monitoring method and system, and storage medium | |
WO2020224246A1 (en) | Block chain-based data management method and apparatus, device and storage medium | |
WO2020155360A1 (en) | Network distribution method for household appliance, household appliance, mobile terminal and storage medium | |
WO2020015064A1 (en) | System fault processing method, apparatus, device and storage medium | |
WO2019037196A1 (en) | Method and device for task assignment, and computer-readable storage medium | |
WO2020253116A1 (en) | Batch data execution method, device, storage medium, and member host in cluster | |
WO2020119115A1 (en) | Data verification method, device, apparatus, and storage medium | |
WO2019174090A1 (en) | Screenshot file sharing control method, apparatus and device, and computer storage medium | |
WO2020062658A1 (en) | Contract generation method and apparatus, and device and storage medium | |
WO2020015061A1 (en) | Monitoring alarm method, device and system for weblogic server, and computer storage medium | |
WO2020015060A1 (en) | Power consumption anomaly estimation method and apparatus, device, and computer storage medium | |
WO2020147385A1 (en) | Data entry method and apparatus, terminal and computer-readable storage medium | |
WO2020119369A1 (en) | Intelligent it operation and maintenance fault positioning method, apparatus and device, and readable storage medium | |
WO2020087983A1 (en) | Task allocation method and apparatus, device and storage medium | |
WO2020098075A1 (en) | Financial data processing method, apparatus and device, and storage medium | |
WO2020042464A1 (en) | Data interaction method, apparatus and device, and readable storage medium | |
WO2020253135A1 (en) | Automated analysis method and device, user equipment, and storage medium | |
WO2016090775A1 (en) | Synchronous operation method and system for short message data | |
WO2019024485A1 (en) | Data sharing method and device and computer readable storage medium | |
WO2020042471A1 (en) | Firewall policy verification method, system and device, and readable storage medium | |
WO2020024534A1 (en) | Power consumption control method, apparatus, and device based on electric quantity prediction, and storage medium | |
WO2020087981A1 (en) | Method and apparatus for generating risk control audit model, device and readable storage medium | |
WO2020224251A1 (en) | Block chain transaction processing method, device, apparatus and storage medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 18927613 Country of ref document: EP Kind code of ref document: A1 |
|
NENP | Non-entry into the national phase |
Ref country code: DE |
|
122 | Ep: pct application non-entry in european phase |
Ref document number: 18927613 Country of ref document: EP Kind code of ref document: A1 |