State monitoring method and device, equipment and storage medium

By using the calling mechanism of target service classes and target subclasses in the microservice monitoring system, combined with internal class storage and exception handling mechanisms, the problems of interface occupation and resource consumption during microservice status monitoring are solved, and flexibility and scalability are achieved Improvement of sex.

CN119440953APending Publication Date: 2025-02-14YIQIQIFUNETWORK TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411558054.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-04
Publication Date
2025-02-14

AI Technical Summary

Technical Problem

When monitoring the status of microservices, the prior art requires special configuration of additional interfaces, resulting in the interface being occupied, increasing the resource consumption of the application, and reducing the flexibility and scalability of the application.

Method used

The target subclass is called through the target service class, and the target inspection method is called in the target subclass to check the status of the target monitoring item. The target internal class stores the inspection results, return the results to the target service class, and determine whether the preset is met. Exceptional conditions. If satisfied, perform the corresponding exception handling operation.

Benefits of technology

It realizes the flexibility and scalability of the application when monitoring the state of microservices, avoids occupancy of multiple interfaces, and improves the stability and performance of the system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119440953A_ABST
    Figure CN119440953A_ABST
Patent Text Reader

Abstract

The invention discloses a state monitoring method and device, equipment and a storage medium, and relates to the field of micro-services, and the method comprises the steps: calling a target subclass through a target service class, and calling a target inspection method in the target subclass to inspect the state of a target monitoring item corresponding to the target subclass, so as to obtain an inspection result corresponding to the target monitoring item; the target subclass is a subclass inheriting the target abstract class; using the target internal class to store the inspection result, returning the inspection result to the target service class, and judging whether the inspection result meets a preset abnormal condition or not; if the check result meets the preset exception condition, calling a target name return method in the target subclass to return a monitoring item name corresponding to the target monitoring item to execute exception handling operation; the target check method and the target name return method are abstract methods in the target abstract class, and the target internal class is an internal class used for storing the check result in the target abstract class. According to the invention, the state of the target monitoring item is monitored.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of microservices, and in particular to a state monitoring method, device, equipment and storage medium. Background Art

[0002] Microservice architecture is widely used in modern enterprises to support complex business needs and rapidly changing market environments. Due to its flexibility, scalability, and independent deployment characteristics, microservice architecture is suitable for many industries and scenarios, including e-commerce platforms, financial services, logistics, Internet services, etc. Therefore, microservice status monitoring is essential to ensure the stability, reliability, and performance of the system. By monitoring the status and performance indicators of each service in real time, potential problems can be quickly discovered and handled, thereby reducing system downtime and improving overall availability. However, when monitoring the status of microservices, such as monitoring the number of active threads of the Dubbo service and the number of active connections of the database, it is often necessary to configure additional interfaces specifically for them, resulting in the interface being occupied, increasing the resource consumption of the application, and reducing the flexibility and scalability of the application.

[0003] Therefore, how to ensure the flexibility and scalability of applications when monitoring the status of microservices is an urgent problem to be solved. Summary of the invention

[0004] In view of this, the purpose of the present invention is to provide a state monitoring method, device, equipment and storage medium, which can ensure the flexibility and scalability of the application when monitoring the state of microservices. The specific scheme is as follows:

[0005] In a first aspect, the present application discloses a state monitoring method, comprising:

[0006] Using the target service class to call the target subclass, and calling the target check method in the target subclass to check the state of the target monitoring item corresponding to the target subclass, so as to obtain the inspection result corresponding to the target monitoring item; wherein the target subclass is a subclass that inherits the target abstract class;

[0007] Using the target internal class to store the inspection result, returning the inspection result to the target service class, and determining whether the inspection result meets the preset abnormal condition;

[0008] If the inspection result meets the preset exception condition, the target name return method is called in the target subclass to return the monitoring item name corresponding to the target monitoring item to perform the corresponding exception handling operation;

[0009] The inspection result is stored in the target inner class, and the inspection result is returned to the target service class, and the target name return method is called in the target subclass to return the monitoring item name corresponding to the target monitoring item;

[0010] The target inspection method and the target name return method are abstract methods in the target abstract class, and the target inner class is an inner class in the target abstract class for storing the inspection result.

[0011] Optionally, the using the target service class to call the target subclass includes:

[0012] The HrbaseDeployConfig object in the target service class is used to obtain configuration information, and the execute method is used to call each of the target subclasses in the target list based on a preset inspection time; wherein the target list is a list for storing all the target subclasses.

[0013] Optionally, the using the target service class to call the target subclass, and calling the target check method in the target subclass to check the state of the target monitoring item corresponding to the target subclass to obtain the inspection result corresponding to the target monitoring item, includes:

[0014] Using the target service class to call the first target subclass, and calling the target check method in the first target subclass to check the thread pool state of the thread pool of the Dubbo service, so as to obtain a first check result corresponding to the thread pool state; the first check result includes the number of active threads of the Dubbo service, the maximum number of threads of the Dubbo service, and an alarm flag;

[0015] Accordingly, the use of the target internal class to store the inspection result and returning the inspection result to the target service class includes:

[0016] The first inspection result is stored in a target internal class, and the first inspection result is returned to a target service class.

[0017] Optionally, calling the target check method in the first target subclass to check the thread pool state of the thread pool of the Dubbo service to obtain a first check result corresponding to the thread pool state includes:

[0018] Obtain all ExecutorService objects from the DataStore, and determine the first ExecutorService object as the object to be converted; wherein each ExecutorService object is a thread pool used by the Dubbo service;

[0019] Convert the object to be converted into an object of ThreadPoolExecutor type to obtain a first converted object, determine the number of active threads and the maximum number of threads using the first converted object, and determine whether the number of active threads is greater than a preset number of threads; wherein the preset number of threads is the product of the maximum number of threads and a first preset threshold percentage;

[0020] If the number of active threads is greater than the preset number of threads, the alarm flag is set to true and the number of active threads is recorded;

[0021] The first inspection result is generated based on the number of active threads, the maximum number of threads, and the warning flag.

[0022] Optionally, the using the target service class to call the target subclass, and calling the target check method in the target subclass to check the state of the target monitoring item corresponding to the target subclass to obtain the inspection result corresponding to the target monitoring item, includes:

[0023] Using the target service class to call the second target subclass, and calling the target check method in the second target subclass to check the connection pool state of the database connection pool, so as to obtain a second check result corresponding to the connection pool state; the second check result includes the number of active connections in the connection pool, the maximum number of connections in the connection pool, and an alarm flag;

[0024] Accordingly, the use of the target internal class to store the inspection result and returning the inspection result to the target service class includes:

[0025] The second inspection result is stored in the target inner class, and the second inspection result is returned to the target service class.

[0026] Optionally, the using the target service class to call the second target subclass, and calling the target check method in the second target subclass to check the connection pool state of the database connection pool to obtain a second check result corresponding to the connection pool state, includes:

[0027] Obtain the current target DataSource object from the Spring container, and make a preliminary judgment on whether the target DataSource object is of the DruidDataSource type to obtain a corresponding preliminary judgment result; wherein the target DataSource object is the data source used by the database;

[0028] If the initial determination result indicates that the target DataSource object is not of the DruidDataSource type, jump to the step of obtaining the current target DataSource object from the Spring container;

[0029] If the initial determination result indicates that the target DataSource object is of DruidDataSource type, converting the type of the target DataSource object to DruidDataSource type, so that the type of the corresponding second converted object is finally determined to be DruidDataSource type;

[0030] Determine the number of active connections and the maximum number of connections based on the second converted object, and judge whether the number of active connections is greater than a preset number of connections; wherein the preset number of connections is the product of the maximum number of connections and a second preset threshold percentage;

[0031] If the number of active connections is greater than the preset number of connections, the alarm flag is set to true and the number of active connections is recorded;

[0032] The second inspection result is generated based on the number of active connections, the maximum number of connections, and the warning flag.

[0033] Optionally, if the inspection result meets the preset exception condition, calling the target name return method in the target subclass to return the monitoring item name corresponding to the target monitoring item to perform a corresponding exception handling operation, including:

[0034] If the alarm flag in at least one of the inspection results is true, the target name return method is called in the target subclass to return the monitoring item name corresponding to the target monitoring item, the log information corresponding to the inspection result is printed, and the alarm information is generated based on the log information;

[0035] Determining a target parameter of a target receiving terminal, and determining whether the target parameter is empty;

[0036] If the target parameter is not empty, sending the alarm information based on the target parameter;

[0037] If the target parameter is empty, an error log is printed and the process jumps to the step of using the target service class to call the target subclass.

[0038] In a second aspect, the present application discloses a state monitoring device, comprising:

[0039] An inspection result acquisition module is used to call a target subclass using a target service class, and call a target inspection method in the target subclass to inspect the state of a target monitoring item corresponding to the target subclass, so as to obtain an inspection result corresponding to the target monitoring item; wherein the target subclass is a subclass that inherits a target abstract class;

[0040] An abnormality judgment module, used to store the inspection result by using the target internal class, return the inspection result to the target service class, and judge whether the inspection result meets the preset abnormality condition;

[0041] The exception handling module is used to call the target name return method in the target subclass to return the monitoring item name corresponding to the target monitoring item to perform the corresponding exception handling operation if the inspection result meets the preset exception condition.

[0042] In a third aspect, the present application discloses an electronic device, comprising:

[0043] Memory, used to store computer programs;

[0044] The processor is used to execute the computer program to implement the aforementioned state monitoring method.

[0045] In a fourth aspect, the present application discloses a computer-readable storage medium for storing a computer program, wherein the computer program implements the aforementioned status monitoring method when executed by a processor.

[0046] In the present application, in order to realize the status monitoring of microservices, the target service class is used to call the target subclass, and the target check method is called in the target subclass to check the status of the target monitoring item corresponding to the target subclass to obtain the inspection result corresponding to the target monitoring item; wherein, the target subclass is a subclass that inherits the target abstract class; the inspection result is stored in the target inner class, and the inspection result is returned to the target service class, and it is determined whether the inspection result meets the preset exception condition. If the inspection result meets the preset exception condition, the target name return method is called in the target subclass to return the monitoring item name corresponding to the target monitoring item to perform the corresponding exception handling operation; wherein, the target check method and the target name return method are abstract methods in the target abstract class, and the target inner class is an inner class in the target abstract class for storing the inspection result. It can be seen that the target service class in the present application can call the target subclass. Since the target subclasses are all subclasses that inherit the target abstract class, the target abstract class defines a target check method that can be used to check the status of the target monitoring item and a target name return method that can return the monitoring item name corresponding to the target monitoring item. The target subclass corresponds to the target monitoring item one by one. After the target service class injects dependencies into each target subclass, it can realize task scheduling for each target subclass, so as to monitor the status of the target monitoring item by using the target check method and the target name return method, and automatically execute the corresponding exception handling operation when the returned inspection result meets the preset exception condition, thereby realizing support for customization and expansion of different types of monitoring items, avoiding occupying multiple interfaces, and realizing the monitoring of the status of microservices while improving the flexibility and scalability of the application. BRIEF DESCRIPTION OF THE DRAWINGS

[0047] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying creative work.

[0048] Figure 1 A flow chart of a state monitoring method disclosed in this application;

[0049] Figure 2 This is a schematic diagram of the structure of a status monitoring device disclosed in this application;

[0050] Figure 3 This is a structural diagram of an electronic device disclosed in this application. DETAILED DESCRIPTION

[0051] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0052] At present, when monitoring the status of microservices, such as monitoring the number of active threads of Dubbo services and the number of active connections of databases, it is often necessary to configure additional interfaces specifically for them, resulting in the interface being occupied, increasing the resource consumption of the application, and reducing the flexibility and scalability of the application. In order to solve the above technical problems, the present application discloses a status monitoring method, which can ensure the flexibility and scalability of the application when monitoring the status of microservices.

[0053] See also Figure 1 As shown, an embodiment of the present invention discloses a state monitoring method, including:

[0054] Step S11, using the target service class to call the target subclass, and calling the target inspection method in the target subclass to inspect the status of the target monitoring item corresponding to the target subclass to obtain the inspection result corresponding to the target monitoring item; wherein the target subclass is a subclass that inherits the target abstract class.

[0055] In this embodiment, when the target service class is used to call the target subclass, the target service class is used to inject dependencies into each target subclass and schedule each target subclass based on the dependencies to perform the task of monitoring the target monitoring item. The process of calling the target subclass using the target service class may include: using the HrbaseDeployConfig object in the target service class to obtain configuration information, and using the execute method to call each target subclass in the target list based on the preset inspection time; wherein the target list is a list for storing all target subclasses, and the target list can be a static constant list named MONITOR_LIST, and the execute method uses the @Scheduled annotation to identify the preset inspection time, such as executing the execute method every 5 seconds. At the same time, the target service class also includes a static constant string DATA_SOURCE_BEAN_NAME used to represent the bean name of the data source. In addition, in order to monitor the status of the target monitoring item in the target service class, the target service class also includes an init method, and when the init method is initialized, the name of the target subclass corresponding to the target monitoring item will be added to the target list.

[0056] In this embodiment, in order to monitor the status of the target monitoring item, it is necessary to call the target subclass through the target service class, and call the target check method in the target subclass. In a specific implementation, the target service class can be used to monitor the thread pool status of the thread pool of the Dubbo service, that is, the target service class is used to call the first target subclass, and the target check method is called in the first target subclass to check the thread pool status of the thread pool of the Dubbo service to obtain the first check result corresponding to the thread pool status; wherein the first check result includes the number of active threads of the Dubbo service, the maximum number of threads of the Dubbo service, and the alarm flag. Specifically, the target check method is called in the first target subclass to check the thread pool state of the thread pool of the Dubbo service to obtain the first check result corresponding to the thread pool state, including: obtaining all ExecutorService objects from the DataStore, and determining the first ExecutorService object as the object to be converted; wherein each ExecutorService object is a thread pool used by the Dubbo service; converting the object to be converted into an object of the ThreadPoolExecutor type to obtain a first converted object, using the first converted object to determine the number of active threads and the maximum number of threads, and judging whether the number of active threads is greater than the preset number of threads; wherein the preset number of threads is the product of the maximum number of threads and a first preset threshold percentage (such as 10%); if the number of active threads is greater than the preset number of threads, setting the alarm flag to true and recording the number of active threads; generating the first check result based on the number of active threads, the maximum number of threads and the alarm flag.

[0057] In a specific implementation, the target service class can be used to monitor the connection pool status of the database connection pool, that is, the target service class is used to call the second target subclass, and the target check method is called in the second target subclass to check the connection pool status of the database connection pool to obtain a second check result corresponding to the connection pool status; the second check result includes the number of active connections in the connection pool, the maximum number of connections in the connection pool, and an alarm flag. Specifically, the target check method is called in the second target subclass to check the connection pool status of the database connection pool to obtain the second check result corresponding to the connection pool status, including: obtaining the current target DataSource object from the Spring container, and performing an initial judgment on whether the target DataSource object is of the DruidDataSource type to obtain the corresponding initial judgment result; wherein the target DataSource object is the data source used by the database; if the initial judgment result indicates that the target DataSource object is not of the DruidDataSource type, jump to the step of obtaining the current target DataSource object from the Spring container ... If the inspection result shows that the target DataSource object is of DruidDataSource type, the type of the target DataSource object is converted to DruidDataSource type, so that the type of the corresponding second converted object is finally determined to be DruidDataSource type; based on the second converted object, the number of active connections and the maximum number of connections are determined, and it is determined whether the number of active connections is greater than the preset number of connections; wherein the preset number of connections is the product of the maximum number of connections and a second preset threshold percentage (such as 10%); if the number of active connections is greater than the preset number of connections, the alarm flag is set to true, and the number of active connections is recorded; and a second inspection result is generated based on the number of active connections, the maximum number of connections, and the alarm flag.

[0058] It is understandable that if the first target subclass is named DubboMonitor and the second target subclass is named DatabaseMonitor, if it is necessary to monitor the thread pool status of the Dubbo service thread pool and the connection pool status of the database connection pool at the same time, then when initializing the init method in the target service class, it is necessary to add DubboMonitor and DatabaseMonitor to the aforementioned target list; if the current application does not use a database, that is, it is not necessary to monitor the connection pool status of the database connection pool, then only DubboMonitor needs to be added to the target list, and DatabaseMonitor does not need to be added to the target list. It should be pointed out that the init method uses the @PostConstruct annotation to indicate that the init method is executed after the constructor. In addition, when using the execute method to traverse the target subclass corresponding to each target monitoring item in the target list, it will first determine whether the target subclass has the inspection function enabled. If the currently traversed target subclass does not have the inspection function enabled, it can directly traverse the next target subclass, or directly end the traversal of the target subclasses corresponding to each target monitoring item in the target list, and jump to the step of obtaining configuration information using the HrbaseDeployConfig object in the target service class. When calling the target inspection method, you can also create a LinkedHashMap corresponding to the target monitoring item to store indicators related to the status of the target monitoring item, and set this Map to the indicator attribute of the inspection result corresponding to the target monitoring item. These indicators can be used to assist users in judging and troubleshooting abnormalities when abnormalities occur in the inspection results.

[0059] Step S12: Use the target internal class to store the inspection result, return the inspection result to the target service class, and determine whether the inspection result meets the preset abnormal condition.

[0060] In this embodiment, the inspection result obtained by calling the target inspection method in the target subclass will be stored using the target inner class. The target inspection method and the target name return method are abstract methods in the target abstract class, and the target inner class is an inner class in the target abstract class for storing the inspection result. After obtaining the inspection result, it is necessary to encapsulate the inspection result using the target inner class so that the inspection result can be returned to the target service class. Specifically, if the first target subclass is called, the first inspection result will be encapsulated using the target inner class, and the inspection result will be returned to the target service class, and the target name return method will be called to return the monitoring item name corresponding to the thread pool state; if the second target subclass is called, the second inspection result will be encapsulated using the target inner class, and the second inspection result will be returned to the target service class, so as to determine whether the service is abnormal based on whether each inspection result meets the preset abnormal conditions.

[0061] Step S13: If the inspection result meets the preset exception condition, the target name return method is called in the target subclass to return the monitoring item name corresponding to the target monitoring item to perform a corresponding exception handling operation.

[0062] In this embodiment, the preset abnormal condition can be that the alarm flag of one or more inspection results is true, that is, if the alarm flag in at least one inspection result is true, the corresponding abnormal handling operation can be performed. The abnormal handling operation can specifically include: calling the target name return method in the target subclass to return the name of the monitoring item corresponding to the target monitoring item, printing the log information corresponding to the inspection result, and generating the alarm information based on the log information. That is to say, the preset abnormal condition is that the alarm flag in at least one inspection result is true, that is, the active number of the target monitoring item exceeds the corresponding threshold, and the active number includes the number of active threads and the number of active connections. When printing the log information corresponding to the inspection result, only the log information corresponding to the inspection result with an abnormality can be printed, or the log information corresponding to all inspection results can be printed. Printing the log information can indicate the start of sending the alarm information, that is, generating the alarm information based on the log information. Before sending the alarm information, it is also necessary to determine the target parameter of the target receiving terminal and determine whether the target parameter is empty; if the target parameter is not empty, the alarm information is sent based on the target parameter; if the target parameter is empty, the error log is printed, and the step of calling the target subclass using the target service class is jumped.

[0063] In a specific implementation, alarm information can be generated based on log information by calling a pre-set build method. The specific process may include: obtaining a Map object of indicators from the inspection result object, and using a StringBuilder object to splice the content of the alarm information. The content of the alarm information may include some fixed text and formats, such as "something big happened", "thread pool is almost full", "machine name", "operating environment", "occurrence time", etc., and can also be used <font>Tag to set font color, etc. In addition, the content of the alarm information can also include information about the number of active items, and use the ">" symbol to indicate indentation. At the same time, after traversing the Map object of the indicator, the name and value of the indicator can be added to the content based on each key-value pair, and the ">" symbol can be used to indicate indentation. Finally, these contents are spliced ​​together, and the spliced ​​content is returned as content as a string with msgtype of markdown, and the string is used as the parameter string to be sent to the target receiving terminal, thereby realizing the use of a unified format and content to construct alarm information, and automatically generating alarm information based on the name and indicator information of the monitoring item, reducing the cost of code writing and maintenance.

[0064] After obtaining the parameter string, the target tool class can be called to determine the target parameters of the target receiving terminal, so as to generate the corresponding post request based on the target parameters, that is, in the target tool class, the static method sendPost is used to pass in the Key and parameter string of the target receiving terminal, so as to generate the corresponding post request and send the post request to the target receiving terminal, and then obtain the JSONObject object returned by the target receiving terminal as the corresponding response result, and print out the log information to complete the sending of the alarm information. The process can specifically include: splicing the URL (Uniform Resource Locator) string corresponding to the target receiving terminal, and creating a target URL object based on the URL string, opening the connection of the target URL object to obtain the corresponding URLConnection object; then setting the doOutput and doInput properties of the URLConnection object to true, that is, allowing output and input. Then, the output stream of this URLConnection object is obtained, and the output stream is packaged as a PrintWriter object in the encoding format of UTF-8 (Universal Character Set / Unicode Transformation Format, a variable-length character encoding for Unicode), so that the aforementioned parameter string can be printed to the output stream using the PrintWriter object, and the corresponding buffer can be refreshed; in addition, the input stream of the URLConnection object needs to be obtained, and this input stream is packaged as a BufferedReader object in the encoding format of UTF-8, and all the contents of the input stream are read and stored using the target StringBuilder object; finally, the target StringBuilder object is converted into a string and parsed into a JSONObject object, and the aforementioned input stream and output stream are closed, and the JSONObject object is returned to print the log information, thereby realizing the acquisition and judgment of the status of the monitoring item based on the built-in thread pool and data storage, and using the target tool class to implement the call to the interface of the target receiving terminal, reducing the resource consumption and network overhead of the application.

[0065] It can be seen that the target service class in the present application can call the target subclass. Since the target subclasses are all subclasses that inherit the target abstract class, the target abstract class defines a target check method that can be used to check the status of the target monitoring item and a target name return method that can return the monitoring item name corresponding to the target monitoring item. The target subclass corresponds to the target monitoring item one by one. After the target service class injects dependencies into each target subclass, it can realize task scheduling for each target subclass, so as to monitor the status of the target monitoring item by using the target check method and the target name return method, and automatically execute the corresponding exception handling operation when the returned inspection result meets the preset exception condition, thereby realizing support for customization and expansion of different types of monitoring items, avoiding occupying multiple interfaces, and realizing the monitoring of the status of microservices while improving the flexibility and scalability of the application.

[0066] See also Figure 2 As shown, the present application discloses a state monitoring device, comprising:

[0067] The inspection result acquisition module 11 is used to call the target subclass by using the target service class, and call the target inspection method in the target subclass to inspect the state of the target monitoring item corresponding to the target subclass, so as to obtain the inspection result corresponding to the target monitoring item; wherein the target subclass is a subclass that inherits the target abstract class;

[0068] The abnormality judgment module 12 is used to store the inspection result by using the target internal class, return the inspection result to the target service class, and judge whether the inspection result meets the preset abnormality condition;

[0069] The exception handling module 13 is used to call the target name return method in the target subclass to return the monitoring item name corresponding to the target monitoring item to perform the corresponding exception handling operation if the inspection result meets the preset exception condition.

[0070] It can be seen that the target service class in the present application can call the target subclass. Since the target subclasses are all subclasses that inherit the target abstract class, the target abstract class defines a target check method that can be used to check the status of the target monitoring item and a target name return method that can return the monitoring item name corresponding to the target monitoring item. The target subclass corresponds to the target monitoring item one by one. After the target service class injects dependencies into each target subclass, it can realize task scheduling for each target subclass, so as to monitor the status of the target monitoring item by using the target check method and the target name return method, and automatically execute the corresponding exception handling operation when the returned inspection result meets the preset exception condition, thereby realizing support for customization and expansion of different types of monitoring items, avoiding occupying multiple interfaces, and realizing the monitoring of the status of microservices while improving the flexibility and scalability of the application.

[0071] In a specific implementation, the inspection result acquisition module 11 may specifically include:

[0072] The target subclass calling submodule is used to obtain configuration information using the HrbaseDeployConfig object in the target service class, and call each target subclass in the target list using the execute method based on a preset inspection time; wherein the target list is a list for storing all the target subclasses.

[0073] In a specific implementation, the inspection result acquisition module 11 may specifically include:

[0074] The first target subclass calling submodule is used to call the first target subclass using the target service class, and call the target check method in the first target subclass to check the thread pool state of the thread pool of the Dubbo service to obtain a first check result corresponding to the thread pool state; the first check result includes the number of active threads of the Dubbo service, the maximum number of threads of the Dubbo service, and an alarm flag;

[0075] Accordingly, the abnormality judgment module 12 may specifically include:

[0076] The first result returning unit is used to store the first inspection result by using a target internal class, and return the first inspection result to a target service class.

[0077] In a specific implementation, the first target subclass calling submodule may specifically include:

[0078] The unit for determining the object to be converted is used to obtain all ExecutorService objects from the DataStore and determine the first ExecutorService object as the object to be converted; wherein each ExecutorService object is a thread pool used by the Dubbo service;

[0079] a first abnormality judgment unit, configured to convert the object to be converted into an object of the ThreadPoolExecutor type to obtain a first converted object, determine the number of active threads and the maximum number of threads using the first converted object, and judge whether the number of active threads is greater than a preset number of threads; wherein the preset number of threads is the product of the maximum number of threads and a first preset threshold percentage;

[0080] A first abnormal operation unit, configured to set the alarm flag to true and record the number of active threads if the number of active threads is greater than the preset number of threads;

[0081] The first inspection result generating unit is used to generate the first inspection result based on the number of active threads, the maximum number of threads and the alarm flag.

[0082] In a specific implementation, the inspection result acquisition module 11 may specifically include:

[0083] The second target subclass calling submodule is used to call the second target subclass by using the target service class, and call the target check method in the second target subclass to check the connection pool state of the database connection pool to obtain a second check result corresponding to the connection pool state; the second check result includes the number of active connections in the connection pool, the maximum number of connections in the connection pool, and an alarm flag;

[0084] Accordingly, the abnormality judgment module 12 may specifically include:

[0085] The second result returning unit is used to store the second inspection result by using the target internal class, and return the second inspection result to the target service class.

[0086] In a specific implementation, the first target subclass calling submodule may specifically include:

[0087] The initial determination result obtaining unit is used to obtain the current target DataSource object from the Spring container, and to perform an initial determination on whether the target DataSource object is of the DruidDataSource type, so as to obtain a corresponding initial determination result; wherein the target DataSource object is the data source used by the database;

[0088] An object re-acquisition unit, configured to jump to the step of acquiring the current target DataSource object from the Spring container if the initial determination result indicates that the target DataSource object is not of the DruidDataSource type;

[0089] an object type conversion unit, configured to convert the type of the target DataSource object into the DruidDataSource type if the initial determination result indicates that the target DataSource object is of the DruidDataSource type, so that the type of the corresponding second converted object is finally determined to be the DruidDataSource type;

[0090] a second abnormality judgment unit, configured to determine the number of active connections and the maximum number of connections based on the second converted object, and to judge whether the number of active connections is greater than a preset number of connections; wherein the preset number of connections is the product of the maximum number of connections and a second preset threshold percentage;

[0091] A second abnormal operation unit, configured to set the alarm flag to true and record the number of active connections if the number of active connections is greater than the preset number of connections;

[0092] The second inspection result returning unit is used to generate the second inspection result based on the number of active connections, the maximum number of connections and the alarm flag.

[0093] In a specific implementation, the exception handling module 13 may specifically include:

[0094] An alarm information generating unit is used to call a target name return method in the target subclass to return the monitoring item name corresponding to the target monitoring item if the alarm flag in at least one of the inspection results is true, print the log information corresponding to the inspection result, and generate alarm information based on the log information;

[0095] A target parameter determination unit, used to determine a target parameter of a target receiving terminal and determine whether the target parameter is empty;

[0096] an alarm information sending unit, configured to send the alarm information based on the target parameter if the target parameter is not empty;

[0097] The error log printing unit is used to print the error log if the target parameter is empty, and jump to the step of calling the target subclass by using the target service class.

[0098] Furthermore, the present application also discloses an electronic device. Figure 3 This is a structural diagram of an electronic device 20 according to an exemplary embodiment. The content in the diagram cannot be regarded as any limitation on the scope of use of the present application.

[0099] Figure 3 A schematic diagram of the structure of an electronic device 20 provided in an embodiment of the present application. The electronic device 20 may specifically include: at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input / output interface 25, and a communication bus 26. The memory 22 is used to store a computer program, which is loaded and executed by the processor 21 to implement the relevant steps in the state monitoring method disclosed in any of the aforementioned embodiments. In addition, the electronic device 20 in this embodiment may specifically be an electronic computer.

[0100] In this embodiment, the power supply 23 is used to provide working voltage for each hardware device on the electronic device 20; the communication interface 24 can create a data transmission channel between the electronic device 20 and the external device, and the communication protocol it follows is any communication protocol that can be applied to the technical solution of the present application, and is not specifically limited here; the input and output interface 25 is used to obtain external input data or output data to the outside world, and its specific interface type can be selected according to specific application needs and is not specifically limited here.

[0101] In addition, the memory 22 as a carrier for resource storage may be a read-only memory, a random access memory, a disk or an optical disk, etc. The resources stored thereon may include an operating system 221, a computer program 222, etc., and the storage method may be temporary storage or permanent storage.

[0102] The operating system 221 is used to manage and control the hardware devices and computer programs 222 on the electronic device 20, and may be Windows Server, Netware, Unix, Linux, etc. In addition to the computer program that can be used to complete the state monitoring method performed by the electronic device 20 disclosed in any of the aforementioned embodiments, the computer program 222 may further include computer programs that can be used to complete other specific tasks.

[0103] Furthermore, the present application also discloses a computer-readable storage medium for storing a computer program; wherein the computer program, when executed by a processor, implements the aforementioned disclosed state monitoring method. For the specific steps of the method, reference may be made to the corresponding contents disclosed in the aforementioned embodiments, and no further description will be given here.

[0104] In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part.

[0105] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.

[0106] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.

[0107] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "comprise", "include" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the statement "comprises a..." does not exclude the presence of other identical elements in the process, method, article or device including the element.

[0108] The technical solution provided by the present application is introduced in detail above. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea. At the same time, for general technicians in this field, according to the idea of ​​the present application, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.< / font>

Claims

1. A state monitoring method, characterized in that: include: Using the target service class to call the target subclass, and calling the target check method in the target subclass to check the state of the target monitoring item corresponding to the target subclass, so as to obtain the inspection result corresponding to the target monitoring item; wherein the target subclass is a subclass that inherits the target abstract class; Using the target internal class to store the inspection result, returning the inspection result to the target service class, and determining whether the inspection result meets the preset abnormal condition; If the inspection result meets the preset exception condition, the target name return method is called in the target subclass to return the monitoring item name corresponding to the target monitoring item to perform the corresponding exception handling operation; The target inspection method and the target name return method are abstract methods in the target abstract class, and the target inner class is an inner class in the target abstract class for storing the inspection result.

2. The state monitoring method according to claim 1, characterized in that: The method of using the target service class to call the target subclass includes: The HrbaseDeployConfig object in the target service class is used to obtain configuration information, and the execute method is used to call each of the target subclasses in the target list based on a preset inspection time; wherein the target list is a list for storing all the target subclasses.

3. The state monitoring method according to claim 1, characterized in that: The target service class is used to call the target subclass, and the target inspection method is called in the target subclass to inspect the state of the target monitoring item corresponding to the target subclass to obtain the inspection result corresponding to the target monitoring item, including: Using the target service class to call the first target subclass, and calling the target check method in the first target subclass to check the thread pool state of the thread pool of the Dubbo service, so as to obtain a first check result corresponding to the thread pool state; the first check result includes the number of active threads of the Dubbo service, the maximum number of threads of the Dubbo service, and an alarm flag; Accordingly, the use of the target internal class to store the inspection result and return the inspection result to the target service class includes: The first inspection result is stored in a target internal class, and the first inspection result is returned to a target service class.

4. The state monitoring method according to claim 3, characterized in that: The calling of the target check method in the first target subclass to check the thread pool state of the thread pool of the Dubbo service to obtain a first check result corresponding to the thread pool state includes: Obtain all ExecutorService objects from the DataStore, and determine the first ExecutorService object as the object to be converted; wherein each ExecutorService object is a thread pool used by the Dubbo service; Convert the object to be converted into an object of ThreadPoolExecutor type to obtain a first converted object, determine the number of active threads and the maximum number of threads using the first converted object, and determine whether the number of active threads is greater than a preset number of threads; wherein the preset number of threads is the product of the maximum number of threads and a first preset threshold percentage; If the number of active threads is greater than the preset number of threads, the alarm flag is set to true and the number of active threads is recorded; The first inspection result is generated based on the number of active threads, the maximum number of threads, and the warning flag.

5. The state monitoring method according to claim 1, characterized in that: The target service class is used to call the target subclass, and the target inspection method is called in the target subclass to inspect the state of the target monitoring item corresponding to the target subclass to obtain the inspection result corresponding to the target monitoring item, including: Using the target service class to call the second target subclass, and calling the target check method in the second target subclass to check the connection pool state of the database connection pool, so as to obtain a second check result corresponding to the connection pool state; the second check result includes the number of active connections in the connection pool, the maximum number of connections in the connection pool, and an alarm flag; Accordingly, the use of the target internal class to store the inspection result and return the inspection result to the target service class includes: The second inspection result is stored in the target inner class, and the second inspection result is returned to the target service class.

6. The state monitoring method according to claim 5, characterized in that: The method of using the target service class to call the second target subclass and calling the target check method in the second target subclass to check the connection pool state of the database connection pool to obtain a second check result corresponding to the connection pool state includes: Obtain the current target DataSource object from the Spring container, and make a preliminary judgment on whether the target DataSource object is of the DruidDataSource type to obtain a corresponding preliminary judgment result; wherein the target DataSource object is the data source used by the database; If the initial determination result indicates that the target DataSource object is not of the DruidDataSource type, jump to the step of obtaining the current target DataSource object from the Spring container; If the initial determination result indicates that the target DataSource object is of DruidDataSource type, converting the type of the target DataSource object to DruidDataSource type, so that the type of the corresponding second converted object is finally determined to be DruidDataSource type; Determine the number of active connections and the maximum number of connections based on the second converted object, and judge whether the number of active connections is greater than a preset number of connections; wherein the preset number of connections is the product of the maximum number of connections and a second preset threshold percentage; If the number of active connections is greater than the preset number of connections, the alarm flag is set to true and the number of active connections is recorded; The second inspection result is generated based on the number of active connections, the maximum number of connections, and the warning flag.

7. The state monitoring method according to any one of claims 1 to 6, characterized in that: If the inspection result meets the preset exception condition, the target name return method is called in the target subclass to return the monitoring item name corresponding to the target monitoring item to perform the corresponding exception handling operation, including: If the alarm flag in at least one of the inspection results is true, the target name return method is called in the target subclass to return the monitoring item name corresponding to the target monitoring item, the log information corresponding to the inspection result is printed, and the alarm information is generated based on the log information; Determining a target parameter of a target receiving terminal, and determining whether the target parameter is empty; If the target parameter is not empty, sending the alarm information based on the target parameter; If the target parameter is empty, an error log is printed and the process jumps to the step of using the target service class to call the target subclass.

8. A state monitoring device, characterized in that: include: An inspection result acquisition module is used to call a target subclass using a target service class, and call a target inspection method in the target subclass to inspect the state of a target monitoring item corresponding to the target subclass, so as to obtain an inspection result corresponding to the target monitoring item; wherein the target subclass is a subclass that inherits a target abstract class; An abnormality judgment module, used to store the inspection result by using the target internal class, return the inspection result to the target service class, and judge whether the inspection result meets the preset abnormality condition; The exception handling module is used to call the target name return method in the target subclass to return the monitoring item name corresponding to the target monitoring item to perform the corresponding exception handling operation if the inspection result meets the preset exception condition.

9. An electronic device, characterized in that: include: Memory, used to store computer programs; A processor, configured to execute the computer program to implement the status monitoring method according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that: Used to store a computer program, wherein when the computer program is executed by a processor, the status monitoring method according to any one of claims 1 to 7 is implemented.