A data collection method and device

By using the debug interface to register breakpoint events in the virtual machine of the device to be monitored, the problems of high data acquisition transformation cost, high performance impact and inability to intercept specific methods in the prior art are solved, and complete data acquisition without transformation is achieved and business performance protection.

CN113742159BActive Publication Date: 2025-02-21BEIJING WODONG TIANJUN INFORMATION TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202010641104.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-07-06
Publication Date
2025-02-21
Estimated Expiration
2040-07-06

AI Technical Summary

Technical Problem

The prior art has problems such as high transformation costs, logging affects performance, inability to intercept private, protected and final methods during data collection, resulting in the inability to collect complete runtime data.

Method used

After the virtual machine of the device to be monitored is started and run, the debugging interface is used to register the breakpoint events encapsulated by the monitoring point information, and then the operation process of the monitoring device is monitored, so that the complete collection and operation is achieved without the need to transform the original device. time data.

Benefits of technology

It realizes that the operational data is collected completely without the need to transform the equipment to be monitored, and the performance impact on the equipment to be monitored is reduced through the asynchronous processing mechanism, and the business execution process and data collection process are isolated.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113742159B_ABST
    Figure CN113742159B_ABST
Patent Text Reader

Abstract

The present invention discloses a data collection method and device, and relates to the field of computer technology. A specific implementation of the method includes: starting a virtual machine of a device to be monitored in a debugging mode, triggering a startup event, and sending the startup event to a monitoring device connected to the virtual machine, so that the monitoring device initiates a monitoring point registration request; when a monitoring point registration request is monitored, the monitoring point information carried in the monitoring point registration request is encapsulated into a breakpoint event, and a debugging interface is called to register the breakpoint event; wherein the monitoring point information includes a monitoring method name; when the device to be monitored runs to the monitoring method corresponding to the monitoring method name, a breakpoint event is triggered to obtain the operating data of the device to be monitored during operation. This implementation method completely collects the runtime data without modifying the original device to be monitored.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a data acquisition method and device. Background Art

[0002] In the prior art, data collection during the operation of business systems generally adopts the following three methods: Method 1: Modify the existing application software and record the intermediate process; Method 2: Collect the logs of the existing application software and analyze them based on the log content; Method 3: Enhance the business processing through agents in the form of aspects to obtain runtime data.

[0003] In the process of implementing the present invention, the inventors found that there are at least the following problems in the prior art:

[0004] Method 1 has a high transformation cost and will introduce business processing codes that are not of concern to the business system, resulting in bloated code structure and being detrimental to the healthy development of existing projects. Method 2 requires that the existing application software has complete log records, and the log records will affect the performance of the business system. The log itself does not record the system status and cannot obtain context data. Method 3 cannot intercept private methods, protected methods, and final methods that do not implement interfaces, and cannot collect complete runtime data. Summary of the invention

[0005] In view of this, an embodiment of the present invention provides a data collection method and device. After the virtual machine of the monitored device is started and running, the debug interface is used to register the breakpoint events encapsulated by the monitoring point information, and then the operation process of the monitored device is monitored. Without modifying the original monitored device, the runtime data is completely collected.

[0006] To achieve the above objective, according to one aspect of an embodiment of the present invention, a data collection method is provided.

[0007] A data collection method according to an embodiment of the present invention comprises: starting a virtual machine of a device to be monitored in a debugging mode, triggering a startup event, and sending the startup event to a monitoring device connected to the virtual machine so that the monitoring device initiates a monitoring point registration request; when the monitoring point registration request is monitored, encapsulating the monitoring point information carried in the monitoring point registration request into a breakpoint event, and calling a debugging interface to register the breakpoint event; wherein the monitoring point information includes a monitoring method name; when the device to be monitored runs to a monitoring method corresponding to the monitoring method name, triggering the breakpoint event, and obtaining the operating data of the device to be monitored during operation.

[0008] Optionally, the monitoring point information carried in the monitoring point registration request is encapsulated into a breakpoint event, including: encapsulating the monitoring point information carried in the monitoring point registration request into a breakpoint request object, and verifying the breakpoint request object; based on the verification result, encapsulating the breakpoint request object into a breakpoint event.

[0009] Optionally, after the step of triggering the breakpoint event, the method further includes: sending the breakpoint event to an event queue, and using a connector to send the breakpoint event in the event queue to the monitoring device, so that the monitoring device asynchronously processes the breakpoint event.

[0010] To achieve the above objective, according to another aspect of an embodiment of the present invention, a data collection method is provided.

[0011] A data collection method according to an embodiment of the present invention includes: obtaining a startup event of a device to be monitored and configured monitoring point information, generating a monitoring point registration request carrying the monitoring point information; sending the monitoring point registration request to the device to be monitored so that the device to be monitored encapsulates the monitoring point information into a breakpoint event, and calls a debugging interface to register the breakpoint event; when the breakpoint event is triggered, obtaining operation data of the device to be monitored during operation.

[0012] Optionally, generating a monitoring point registration request carrying the monitoring point information includes: generating a monitoring point registration request carrying the monitoring point information according to the status information of the device to be monitored and / or the monitoring point update information.

[0013] Optionally, the method further includes: acquiring the breakpoint event from an event queue, and asynchronously processing the breakpoint event; wherein the breakpoint event is sent to the event queue by the device to be monitored after the breakpoint event is triggered.

[0014] Optionally, the method further includes: converting the format of the operation data, and storing the operation data after the format conversion.

[0015] To achieve the above objective, according to another aspect of an embodiment of the present invention, a data acquisition device is provided.

[0016] A data acquisition device according to an embodiment of the present invention includes: an event sending module, which is used to start a virtual machine of a device to be monitored in a debugging mode, trigger a startup event, and send the startup event to a monitoring device connected to the virtual machine, so that the monitoring device initiates a monitoring point registration request; an encapsulation registration module, which is used to encapsulate the monitoring point information carried in the monitoring point registration request into a breakpoint event when the monitoring point registration request is monitored, and call a debugging interface to register the breakpoint event; wherein the monitoring point information includes a monitoring method name; and a data acquisition module, which is used to trigger the breakpoint event when the device to be monitored runs to the monitoring method corresponding to the monitoring method name, and obtain the operating data of the device to be monitored during operation.

[0017] Optionally, the encapsulation registration module is further used to encapsulate the monitoring point information carried in the monitoring point registration request into a breakpoint request object, verify the breakpoint request object; and encapsulate the breakpoint request object into a breakpoint event based on the verification result.

[0018] Optionally, the apparatus further comprises: a queue processing module, configured to send the breakpoint event to an event queue, and use a connector to send the breakpoint event in the event queue to the monitoring device, so that the monitoring device asynchronously processes the breakpoint event.

[0019] To achieve the above objective, according to another aspect of an embodiment of the present invention, a data acquisition device is provided.

[0020] A data acquisition device according to an embodiment of the present invention includes: a request generation module, which is used to obtain the startup event of a device to be monitored and the configured monitoring point information, and generate a monitoring point registration request carrying the monitoring point information; a request sending module, which is used to send the monitoring point registration request to the device to be monitored, so that the device to be monitored encapsulates the monitoring point information into a breakpoint event and calls a debugging interface to register the breakpoint event; and a data collection module, which is used to obtain the operating data of the device to be monitored during operation when the breakpoint event is triggered.

[0021] Optionally, the request generation module is further configured to generate a monitoring point registration request carrying the monitoring point information according to the status information of the device to be monitored and / or the monitoring point update information.

[0022] Optionally, the device further includes: an asynchronous processing module, used to obtain the breakpoint event from the event queue and asynchronously process the breakpoint event; wherein the breakpoint event is sent to the event queue by the monitored device after the breakpoint event is triggered.

[0023] Optionally, the device further includes: a data processing module, configured to perform format conversion on the operation data and store the operation data after format conversion.

[0024] To achieve the above objective, according to another aspect of an embodiment of the present invention, an electronic device is provided.

[0025] An electronic device according to an embodiment of the present invention includes: one or more processors; a storage device for storing one or more programs, and when the one or more programs are executed by the one or more processors, the one or more processors implement a data collection method according to an embodiment of the present invention.

[0026] To achieve the above objective, according to another aspect of the embodiments of the present invention, a computer readable medium is provided.

[0027] A computer-readable medium according to an embodiment of the present invention stores a computer program, and when the program is executed by a processor, a data collection method according to an embodiment of the present invention is implemented.

[0028] An embodiment of the above invention has the following advantages or beneficial effects: after the virtual machine of the device to be monitored is started and run, the breakpoint event encapsulated by the monitoring point information is registered using the debugging interface, and then the operation process of the device to be monitored is monitored, and the runtime data is completely collected without modifying the original device to be monitored; in the process of encapsulating the breakpoint event, the legitimacy of the breakpoint request object is verified to ensure the integrity of the data contained in the object and the correctness of the structure; an event queue mechanism is introduced to asynchronously process the processing, reduce the impact on the device to be monitored, isolate the business execution process and the data collection process, and ensure the business performance and business correctness of the device to be monitored.

[0029] An embodiment of the above invention has the following advantages or beneficial effects: by configuring the monitoring point information, a monitoring point registration request containing the monitoring point information is generated after receiving the start event, so that the monitored device calls the debugging interface to encapsulate the monitoring point information into a breakpoint event, and then obtains the operation data after the breakpoint event is triggered, thereby realizing the collection function of runtime data; generating a monitoring point registration request based on the status information of the monitored device and / or the monitoring point update information to ensure the completeness of the monitoring point; asynchronously processing breakpoint events to reduce the performance impact on the monitored device; format conversion and storage of the collected operation data to facilitate subsequent data analysis, visualization and other operations.

[0030] The further effects of the above-mentioned non-conventional optional manner will be described below in conjunction with the specific implementation manner. BRIEF DESCRIPTION OF THE DRAWINGS

[0031] The accompanying drawings are used to better understand the present invention and do not constitute an improper limitation of the present invention.

[0032] Figure 1 is a schematic diagram of the main steps of the data collection method according to an embodiment of the present invention;

[0033] Figure 2 is a schematic diagram of the main steps of the data collection method according to an embodiment of the present invention;

[0034] Figure 3 is a schematic diagram of the implementation principle of the data collection method according to an embodiment of the present invention;

[0035] Figure 4 is a schematic diagram of a system architecture of a data collection method according to an embodiment of the present invention;

[0036] Figure 5 is a schematic diagram of the main flow of a data collection method according to an embodiment of the present invention;

[0037] Figure 6 is a schematic diagram of main modules of a data acquisition device according to an embodiment of the present invention;

[0038] Figure 7 is a schematic diagram of main modules of a data acquisition device according to an embodiment of the present invention;

[0039] Figure 8 is an exemplary system architecture diagram to which embodiments of the present invention may be applied;

[0040] Fig. 9 It is a schematic diagram of the structure of a computer device suitable for implementing the electronic device of the embodiment of the present invention. DETAILED DESCRIPTION

[0041] The following is a description of exemplary embodiments of the present invention in conjunction with the accompanying drawings, including various details of the embodiments of the present invention to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present invention. Similarly, for clarity and conciseness, the description of well-known functions and structures is omitted in the following description.

[0042] The technical terms involved in the embodiments of the present invention are explained below.

[0043] JDI: It is the abbreviation of Java Debug Interface. It is the highest level interface in the three-level module of JPDA. It defines some debugging interfaces required by the debugger. Based on these interfaces, the debugger can timely understand the status of the target virtual machine, such as which classes and instances are on the target virtual machine.

[0044] JPDA: It is the abbreviation of Java Platform Debugger Architecture, which is also the abbreviation of Java platform debugging architecture. It consists of the Java virtual machine back end and the debugging platform front end.

[0045] Netty: is a Java open source framework that provides an asynchronous, event-driven network application framework and tools for quickly developing high-performance, high-reliability network servers and client programs.

[0046] JVM: It is the abbreviation of Java Virtual Machine. JVM is a specification for computing devices. It is a fictional computer that is implemented by simulating various computer functions on an actual computer.

[0047] SPI: It is the abbreviation of Service Provider Interface, which is a set of APIs (Application Programming Interface) provided by Java for implementation or extension by third parties. It can be used to enable framework extension and replacement components.

[0048] Figure 1 FIG. 1 is a schematic diagram of the main steps of the data collection method according to an embodiment of the present invention. Figure 1 As shown, the data collection method of the embodiment of the present invention is performed by the device to be monitored and mainly includes the following steps:

[0049] Step S101: Start the virtual machine of the device to be monitored in debug mode, trigger a startup event, and send the startup event to the monitoring device connected to the virtual machine, so that the monitoring device initiates a monitoring point registration request. Normally, the virtual machine of the device to be monitored does not trigger a JDI event when it is started. In order to collect runtime data (i.e., the operating data generated when the device to be monitored is running), it is necessary to add startup parameters when the virtual machine is started and start it in debug mode.

[0050] After the virtual machine of the monitored device is started, a startup event is triggered and sent to the monitoring device through the network. When the monitoring device receives the startup event, it will update the status information of the monitored device maintained by the monitoring device itself, and register the monitoring point according to the real-time status of the monitored device to ensure the completeness of the monitoring point.

[0051] Step S102: When the monitoring point registration request is intercepted, the monitoring point information carried in the monitoring point registration request is encapsulated into a breakpoint event, and the debugging interface is called to register the breakpoint event. The monitoring point registration request includes monitoring point information, and the monitoring point information includes the monitoring method name. When the monitoring device intercepts the monitoring point registration request, it starts to process the monitoring point information. Specifically, the monitoring point information is first encapsulated into a breakpoint request object, the breakpoint request object is verified, and the breakpoint request object that passes the verification is encapsulated into a breakpoint event; then the debugging interface (i.e., JDI interface) is called to register the breakpoint event.

[0052] Step S103: When the monitored device runs to the monitoring method corresponding to the monitoring method name, the breakpoint event is triggered to obtain the operation data of the monitored device during operation. When the monitored device matches the monitoring point information during operation, the breakpoint event is triggered, that is, when the monitored device runs to the monitoring method specified in the monitoring point information, the breakpoint event is triggered, and the operation data of the monitored device when running to the monitoring method is obtained.

[0053] Figure 2 FIG. 1 is a schematic diagram of the main steps of the data collection method according to an embodiment of the present invention. Figure 2 As shown, the data collection method of the embodiment of the present invention is performed by a monitoring device and mainly includes the following steps:

[0054] Step S201: Obtain the startup event of the device to be monitored and the configured monitoring point information, and generate a monitoring point registration request carrying the monitoring point information. Configure the monitoring point information on the monitoring device according to business requirements, and the monitoring point information includes the monitoring method name, monitoring time and monitoring object. After the monitoring point information is configured, the monitoring point information can be maintained on the monitoring device, including adding, updating and deleting monitoring point information. The business requirements here include the timing of business triggering, the status of the business when it is running, the data information when the business is running, etc.

[0055] When the virtual machine of the monitored device is started in debug mode, a startup event is triggered, and the monitored device sends the startup event to the monitoring device connected to it through the network. After receiving the startup event, the monitoring device generates a monitoring point registration request based on the monitoring point information.

[0056] Step S202: Send the monitoring point registration request to the device to be monitored, so that the device to be monitored encapsulates the monitoring point information into a breakpoint event and calls the debugging interface to register the breakpoint event. The monitoring device sends the monitoring point registration request to the device to be monitored, so that the device to be monitored starts to perform relevant operations on the monitoring point information. Specifically, the monitoring point information is first encapsulated into a breakpoint event, and then the JDI interface is called to register the breakpoint event.

[0057] Step S203: When the breakpoint event is triggered, the operation data of the monitored device is obtained. When the monitored device runs to the monitoring method specified in the monitoring point information, the breakpoint event is triggered, and the operation data of the monitored device running to the monitoring method is obtained, and then the operation data is sent to the monitoring device through the network. After receiving the operation data, the monitoring device can further process the operation data according to business needs, such as format conversion.

[0058] The data collection method of the embodiment of the present invention mainly relies on the JPDA mechanism of the JVM, and is tailored and functionally enhanced according to its own business needs. Specifically, since non-method-level breakpoints (BreakPoint) are not related to data collection, the non-method-level BreakPoints in JPDA are mainly tailored (i.e. deleted). In the functional enhancement part, the event queue mechanism is introduced through custom network components to asynchronously process the processing, reduce the impact on the monitored equipment, and isolate the business execution process and the data collection process to ensure business performance and business correctness.

[0059] Figure 3 FIG. 1 is a schematic diagram showing the implementation principle of the data collection method according to an embodiment of the present invention. Figure 3 As shown, the data collection method of the embodiment of the present invention is implemented by a device to be monitored, a connector (i.e., a network component) and a monitoring device. The device to be monitored is a device that executes a specific business process, which can be a business system. It needs to be started in debug mode to allow the connector to connect to the device to be monitored and send the operating data to the monitoring device as a producer.

[0060] The connector is a bridge between the device to be monitored and the monitoring device, and is used to realize communication between the device to be monitored and the monitoring device, such as remotely forwarding the operating data of the device to be monitored to the monitoring device.

[0061] The implementation of monitoring equipment is related to specific business needs and includes the following functions: configure monitoring point information according to business needs; manage the status information of the monitored equipment. If the status information of the monitored equipment changes (such as restart, deployment, downtime, etc.), the monitoring point information can be adjusted in real time; handle breakpoint events and operation data; perform data analysis and visualization on operation data; output data analysis results for reference in business decision-making.

[0062] Figure 4 is a schematic diagram of a system architecture of a data collection method according to an embodiment of the present invention, Figure 5 FIG. 1 is a schematic diagram of the main flow of the data collection method according to an embodiment of the present invention. Figure 4 and Figure 5 As shown, the data collection method of the embodiment of the present invention mainly includes the following steps:

[0063] Step S501: Start the virtual machine of the device to be monitored in debug mode, establish a connection between the virtual machine of the device to be monitored and the monitoring device, and load the monitoring point management class package into the virtual machine. When the device to be monitored is started, a virtual machine object will be formed in the JVM. Normally, the JVM will not trigger JDI events when it is running. In order to collect running data, it is necessary to add the -Xdebug parameter when starting the JVM and start it in debug mode so that the monitoring device can connect to the JVM.

[0064] When the monitored device is started, the monitoring point management class package can be loaded into the JVM through the Java Agent mechanism, so as to facilitate the use in subsequent monitoring point registration, unloading, triggering, etc. Among them, the monitoring point management class package includes monitoring point monitoring, monitoring point data collection, monitoring point data processing and other class package information.

[0065] like Figure 4 As shown, the virtual machine of the monitored device and the monitoring device are connected through their respective network connection services. The network connection service is a wrapper for the connector, which is used to implement specific business functions. At the same time, the network connection service of the monitored device and the network connection service of the monitoring device play different roles at different times. When registering a monitoring point, the network connection service of the monitored device acts as a server to receive the monitoring point registration request of the monitoring device; when a monitoring point event is triggered, the network connection service of the monitoring device acts as a server to receive the operation data collected by the monitored device.

[0066] In a preferred embodiment, when the monitored device is started, the JavaAgent+SPI mechanism is used to automatically start the network connection service, avoiding the display of the startup service in the monitored device. This method can reduce the coupling to the monitored device and achieve zero intrusion of the monitored device in terms of network connection. In the embodiment, the network connection service can be implemented using Netty. Among them, JavaAgent is a Java agent, and the SPI mechanism is a mechanism for a certain interface to find a service implementation. Display startup means that the network connection service will start automatically, and there is no need to write the code to start the network connection service in the monitored device.

[0067] Step S502: Send the startup event triggered by the startup of the virtual machine to the monitoring device. The startup event is triggered when the monitored device is started, and the startup event is sent to the monitoring device through the network connection service. The startup event is used to let the monitoring device know that a new monitored device has been started, including the IP address of the monitored device.

[0068] It should be noted that a stop event will be triggered when the system upgrade deployment of the device to be monitored is triggered. When this event is triggered, the network connection resources of the device to be monitored and the network connection resources of the monitoring device will be released.

[0069] Step S503: The monitored device sends heartbeat information and its own status information to the monitoring device. In order to ensure the robustness of the monitored device, the monitored device needs to regularly send heartbeat information and its own status information to the monitoring device. Among them, regularly sending heartbeat information allows the monitoring device to sense whether the monitored device is online or offline; status information such as online, offline, restart, deployment, etc.

[0070] Step S504: After receiving the startup event or heartbeat information, the monitoring device updates the status information of the device to be monitored that it maintains, and sends a monitoring point registration request or a monitoring point uninstallation request to the device to be monitored based on the status information and / or monitoring point update information. When the monitoring device monitors the following situations, it will send a monitoring point registration request or a monitoring point uninstallation request to the device to be monitored: monitoring the restart of the device to be monitored, monitoring the status change of the device to be monitored, or the monitoring device actively adds, changes, or deletes monitoring point information. In the above situations, a monitoring point uninstallation request is sent when the status of the device to be monitored changes to offline or deployed, and the monitoring point information is deleted, and a monitoring point registration request is sent in other situations.

[0071] Among them, the monitoring point update information is to add, change, and delete monitoring point information. The monitoring point registration request includes the monitoring point information, which includes the monitoring method name, monitoring time (before execution, after execution, execution exception), and monitoring object (method input parameters, return value). Taking the monitoring of the user's order payment action as an example, the monitoring point information includes the method name to be called for order payment, the monitoring time (before payment, after payment, payment failure), and the monitoring object (method input parameters and return value). The monitoring point uninstallation request includes the monitoring point information, which includes the monitoring method name, which is used to uninstall the monitoring added to the method.

[0072] JDI defines a variety of event types, such as ClassPrepareEvent, ClassUnloadEvent, BreakingpointEvent, ExceptionEvent, MethodEntryEvent, MethodExitEvent, etc. For data collection of the monitored device, it is only necessary to monitor ExceptionEvent, MethodEntryEvent, and MethodExitEvent to avoid the abuse of monitoring point information and affect the operation of the monitored device.

[0073] Among them, ClassPrepareEvent is an event triggered by loading a specified class, ClassUnloadEvent is an event triggered by unloading a specified class, BreakingpointEvent is an event triggered by setting a breakpoint, ExceptionEvent is an event triggered by throwing a specified exception during the operation of the target virtual machine, MethodEntryEvent is an event triggered when entering a specified method body, and MethodExitEvent is an event triggered after a specified method is executed.

[0074] Step S505: The device to be monitored encapsulates the monitoring point information into a breakpoint event, calls the debugging interface to register or uninstall the breakpoint event, and waits for the breakpoint event to be triggered. After receiving the monitoring point registration request or the monitoring point uninstallation request, the device to be monitored first encapsulates the monitoring point information into a monitoring point request (BreakPointRequest) object, then verifies the monitoring point request object, and encapsulates it into a breakpoint event (BreakPointEvent) after the verification passes. The verification here is used to verify the integrity of the data contained in the monitoring point request object and the correctness of the structure.

[0075] JDI supports multiple BreakPointEvents. Since this method is intended to collect running data, breakpoint events can be filtered to filter out events that update the context to ensure the correctness of the collected data. Then call the JDI interface to register the filtered BreakPointEvent and wait for the BreakPointEvent to be triggered. Context refers to the information obtained when the breakpoint event is triggered, generally the method's input parameters, return value, and other information.

[0076] Step S506: When the monitored device runs to the monitoring method corresponding to the monitoring method name, a breakpoint event is triggered, event data is obtained, and the event data is sent to the monitoring device. During the operation of the JVM of the monitored device, the SPI discovery mechanism is relied on. When the monitoring method corresponding to the monitoring method name is run, JDI will trigger BreakPointEvent, and then send the event data to the monitoring device through the network connection service. The event data here is the data obtained after the breakpoint event is triggered, which can be the operation data corresponding to the registration, or the uninstallation data corresponding to the uninstallation.

[0077] Step S507: The monitoring device distributes the event data to the processor for processing and saves the processing results. The monitoring device pre-specifies a specific processor (Handler) for the monitoring point information. Taking the operation data as an example, the monitoring device distributes the operation data to the corresponding processor for processing, and saves the processing results for common business parties or operations. The processing here can be format conversion of the operation data. Among them, the operation data can be the specific value of the monitored object, that is, the specific value of the input parameter and return value of the method. In an embodiment, the processing results can be saved to a database such as ES (ElasticSearch), Redis, Time Serise DB (time series database), and DB is DataBase (database).

[0078] Since the processing process of each event is similar, the template mode can be used for processing, that is, the common processing process is encapsulated for direct call by the Handler. Specifically, the standard process is specified in the template method, and the default implementation is provided. Each Handler only needs to implement the message parsing to complete the implementation of the Handler. The default implementation, for example, parses the message into JSON (Java Script Object Notation, JS object notation), XML (Extensible Markup Language, Extensible Markup Language) format, etc.

[0079] In a preferred embodiment, in order to reduce the impact of data collection on the monitored device, an event queue mechanism is introduced. When the monitored device triggers the action of interest (such as a breakpoint event trigger), the corresponding event is sent to the event queue, and then the monitoring device processes the event, realizing the decoupling of business and monitoring. The reject mechanism of the event queue is set to discard to avoid the impact on the monitored device. At the same time, the monitoring device consumes events asynchronously, greatly improving the processing efficiency.

[0080] The embodiment of the present invention directly utilizes the inherent capability of JVM to monitor the monitored device, which can truly achieve zero intrusion into the monitored device and obtain complete runtime data. At the same time, based on the event queue mechanism, data is processed asynchronously, which minimizes the impact on the performance of the monitored device.

[0081] Figure 6 Schematic diagram of the main modules of the data acquisition device according to an embodiment of the present invention. Figure 6 As shown, the data acquisition device 600 (i.e., the device to be monitored) of the embodiment of the present invention mainly includes:

[0082] The event sending module 601 is used to start the virtual machine of the device to be monitored in debug mode, trigger a startup event, and send the startup event to the monitoring device connected to the virtual machine, so that the monitoring device initiates a monitoring point registration request. Normally, the virtual machine of the device to be monitored does not trigger a JDI event when it is started. In order to collect runtime data, it is necessary to add startup parameters when the virtual machine is started and start it in debug mode.

[0083] After the virtual machine of the monitored device is started, a startup event is triggered and sent to the monitoring device through the network. When the monitoring device receives the startup event, it will update the status information of the monitored device maintained by the monitoring device itself, and register the monitoring point according to the real-time status of the monitored device to ensure the completeness of the monitoring point.

[0084] The encapsulation registration module 602 is used to encapsulate the monitoring point information carried in the monitoring point registration request into a breakpoint event when the monitoring point registration request is monitored, and call the debugging interface to register the breakpoint event. The monitoring point registration request includes the monitoring point information, and the monitoring point information includes the monitoring method name. When the monitoring device monitors the monitoring point registration request, it starts to process the monitoring point information. Specifically, the monitoring point information is first encapsulated into a breakpoint request object, the breakpoint request object is verified, and the breakpoint request object that passes the verification is encapsulated into a breakpoint event; then the JDI interface is called to register the breakpoint event.

[0085] The data acquisition module 603 is used to trigger the breakpoint event and obtain the operation data of the monitored device when the monitored device runs to the monitoring method corresponding to the monitoring method name. The breakpoint event will be triggered when the monitored device matches the monitoring point information during operation, that is, the breakpoint event will be triggered when the monitored device runs to the monitoring method specified in the monitoring point information, and the operation data of the monitored device running to the monitoring method will be obtained.

[0086] In addition, the data acquisition device 600 of the embodiment of the present invention may also include: a queue processing module ( Figure 6 The module is used to send the breakpoint event to an event queue, and use a connector to send the breakpoint event in the event queue to the monitoring device, so that the monitoring device asynchronously processes the breakpoint event.

[0087] From the above description, it can be seen that after the virtual machine of the monitored device is started and running, the debug interface is used to register the breakpoint events encapsulated by the monitoring point information, and then the operation process of the monitored device is monitored. Without modifying the original monitored device, the runtime data is completely collected.

[0088] Figure 7Schematic diagram of the main modules of the data acquisition device according to an embodiment of the present invention. Figure 7 As shown, the data acquisition device 700 (i.e., monitoring device) of the embodiment of the present invention mainly includes:

[0089] The request generation module 701 is used to obtain the startup event of the device to be monitored and the configured monitoring point information, and generate a monitoring point registration request carrying the monitoring point information. The monitoring point information is configured on the monitoring device according to business requirements, and the monitoring point information includes the monitoring method name, monitoring time and monitoring object. After the monitoring point information is configured, the monitoring point information can be maintained on the monitoring device, including adding, updating and deleting monitoring point information. The business requirements here include the timing of business triggering, the status of the business when it is running, the data information when the business is running, etc.

[0090] When the virtual machine of the monitored device is started in debug mode, a startup event is triggered, and the monitored device sends the startup event to the monitoring device connected to it through the network. After receiving the startup event, the monitoring device generates a monitoring point registration request based on the monitoring point information.

[0091] The request sending module 702 is used to send the monitoring point registration request to the device to be monitored, so that the device to be monitored encapsulates the monitoring point information into a breakpoint event and calls the debugging interface to register the breakpoint event. The monitoring device sends the monitoring point registration request to the device to be monitored, so that the device to be monitored starts to perform relevant operations on the monitoring point information. Specifically, the monitoring point information is first encapsulated into a breakpoint event, and then the JDI interface is called to register the breakpoint event.

[0092] The data collection module 703 is used to obtain the operation data of the monitored device when the breakpoint event is triggered. When the monitored device runs to the monitoring method specified in the monitoring point information, the breakpoint event is triggered to obtain the operation data of the monitored device running to the monitoring method, and then send the operation data to the monitoring device through the network. After receiving the operation data, the monitoring device can further process the operation data according to business needs, such as format conversion.

[0093] In addition, the data acquisition device 700 of the embodiment of the present invention may also include: an asynchronous processing module and a data processing module ( Figure 7 The asynchronous processing module is used to obtain the breakpoint event from the event queue and asynchronously process the breakpoint event; wherein the breakpoint event is sent to the event queue by the device to be monitored after the breakpoint event is triggered. The data processing module is used to convert the format of the operation data and store the operation data after the format conversion.

[0094] From the above description, it can be seen that by configuring the monitoring point information, a monitoring point registration request containing the monitoring point information is generated after receiving the startup event, so that the monitored device calls the debugging interface to encapsulate the monitoring point information into a breakpoint event, and then obtains the operation data after the breakpoint event is triggered, thereby realizing the collection function of runtime data on the monitoring device side.

[0095] Figure 8 An exemplary system architecture 800 is shown to which the data collection method or data collection device according to the embodiment of the present invention can be applied.

[0096] like Figure 8 As shown, system architecture 800 may include terminal devices 801, 802, 803, a network 804, and a server 805. Network 804 is used to provide a medium for communication links between terminal devices 801, 802, 803 and server 805. Network 804 may include various connection types, such as wired, wireless communication links, or optical fiber cables, etc.

[0097] The user can use the terminal devices 801, 802, 803 to interact with the server 805 through the network 804 to receive or send messages, etc. Various communication client applications can be installed on the terminal devices 801, 802, 803. The terminal devices 801, 802, 803 can be various electronic devices with display screens and supporting web browsing, including but not limited to smart phones, tablet computers, laptop portable computers, desktop computers, etc.

[0098] The server 805 may be a server that provides various services, such as a background management server that processes the startup events sent by the administrator using the terminal devices 801, 802, and 803. The background management server may configure monitoring point information, generate monitoring point registration requests, and feed back processing results (such as monitoring point registration requests) to the terminal device.

[0099] It should be noted that the data collection method provided in the embodiment of the present application is generally executed by the terminal device 801 , 802 , 803 or the server 805 , and accordingly, the data collection device is generally arranged in the terminal device 801 , 802 , 803 or the server 805 .

[0100] It should be understood that Figure 8 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.

[0101] According to an embodiment of the present invention, the present invention also provides an electronic device and a computer-readable medium.

[0102] The electronic device of the present invention comprises: one or more processors; a storage device for storing one or more programs, and when the one or more programs are executed by the one or more processors, the one or more processors implement a data acquisition method of an embodiment of the present invention.

[0103] The computer-readable medium of the present invention stores a computer program, and when the program is executed by a processor, a data collection method according to an embodiment of the present invention is implemented.

[0104] Reference below Fig. 9 , which shows a schematic diagram of the structure of a computer system 900 suitable for implementing an electronic device of an embodiment of the present invention. Fig. 9 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.

[0105] like Fig. 9 As shown, the computer system 900 includes a central processing unit (CPU) 901, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 902 or a program loaded from a storage part 908 into a random access memory (RAM) 903. In the RAM 903, various programs and data required for the operation of the computer system 900 are also stored. The CPU 901, the ROM 902, and the RAM 903 are connected to each other via a bus 904. An input / output (I / O) interface 905 is also connected to the bus 904.

[0106] The following components are connected to the I / O interface 905: an input section 906 including a keyboard, a mouse, etc.; an output section 907 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 908 including a hard disk, etc.; and a communication section 909 including a network interface card such as a LAN card, a modem, etc. The communication section 909 performs communication processing via a network such as the Internet. A drive 910 is also connected to the I / O interface 905 as needed. A removable medium 911, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 910 as needed, so that a computer program read therefrom is installed into the storage section 908 as needed.

[0107] In particular, according to the embodiments disclosed in the present invention, the process described in the main step diagram above can be implemented as a computer software program. For example, the embodiments disclosed in the present invention include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the main step diagram. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 909, and / or installed from the removable medium 911. When the computer program is executed by the central processing unit (CPU) 901, the above-mentioned functions defined in the system of the present invention are executed.

[0108] It should be noted that the computer-readable medium shown in the present invention may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present invention, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present invention, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.

[0109] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present invention. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0110] The modules involved in the embodiments of the present invention may be implemented in software or hardware. The modules described may also be set in a processor, for example, they may be described as: a processor including an event sending module, an encapsulation registration module and a data acquisition module. The names of these modules do not constitute limitations on the modules themselves in certain cases. For example, the event sending module may also be described as "a module that starts a virtual machine of a device to be monitored in debug mode, triggers a start event, and sends the start event to a monitoring device connected to the virtual machine, so that the monitoring device initiates a monitoring point registration request."

[0111] As another aspect, the present invention also provides a computer-readable medium, which may be included in the device described in the above embodiment; or it may exist independently and not be assembled into the device. The above computer-readable medium carries one or more programs. When the above one or more programs are executed by a device, the device includes: starting the virtual machine of the device to be monitored in debug mode, triggering a startup event, sending the startup event to the monitoring device connected to the virtual machine, so that the monitoring device initiates a monitoring point registration request; when the monitoring point registration request is monitored, the monitoring point information carried in the monitoring point registration request is encapsulated into a breakpoint event, and the debugging interface is called to register the breakpoint event; wherein the monitoring point information includes the monitoring method name; when the device to be monitored runs to the monitoring method corresponding to the monitoring method name, the breakpoint event is triggered to obtain the running data of the device to be monitored during operation.

[0112] According to the technical solution of the embodiment of the present invention, after the virtual machine of the monitored device is started and run, the debug interface is used to register the breakpoint events encapsulated by the monitoring point information, and then the running process of the monitored device is monitored. Without modifying the original monitored device, the runtime data is completely collected.

[0113] The above product can execute the method provided by the embodiment of the present invention, and has the functional modules and beneficial effects corresponding to the execution method. For technical details not described in detail in this embodiment, please refer to the method provided by the embodiment of the present invention.

[0114] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may occur depending on design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.

Claims

1. A data collection method, characterized in that: Executed by the device to be monitored, including: Starting a virtual machine of a device to be monitored in a debugging mode, triggering a startup event, and sending the startup event to a monitoring device connected to the virtual machine, so that the monitoring device initiates a monitoring point registration request; When the monitoring point registration request is intercepted, the monitoring point information carried in the monitoring point registration request is encapsulated into a breakpoint event, and the debugging interface is called to register the breakpoint event; wherein the monitoring point information includes the monitoring method name, monitoring time and monitoring object; When the device to be monitored runs to the monitoring method corresponding to the monitoring method name, the breakpoint event is triggered to obtain the running data of the device to be monitored during the running.

2. The method according to claim 1, characterized in that: Encapsulating the monitoring point information carried in the monitoring point registration request into a breakpoint event, including: Encapsulating the monitoring point information carried in the monitoring point registration request into a breakpoint request object, and verifying the breakpoint request object; According to the verification result, the breakpoint request object is encapsulated into a breakpoint event.

3. The method according to claim 1 or 2, characterized in that: After the step of triggering the breakpoint event, the method further includes: The breakpoint event is sent to an event queue, and the breakpoint event in the event queue is sent to the monitoring device using a connector, so that the monitoring device asynchronously processes the breakpoint event.

4. A data collection method, characterized in that: Performed by monitoring equipment, including: Obtaining the startup event of the device to be monitored and the configured monitoring point information, and generating a monitoring point registration request carrying the monitoring point information; wherein the monitoring point information includes the monitoring method name, monitoring time and monitoring object; Sending the monitoring point registration request to the device to be monitored, so that the device to be monitored encapsulates the monitoring point information into a breakpoint event, and calls a debugging interface to register the breakpoint event; When the breakpoint event is triggered, the operation data of the device to be monitored is obtained.

5. The method according to claim 4, characterized in that Generating a monitoring point registration request carrying the monitoring point information, including: A monitoring point registration request carrying the monitoring point information is generated according to the status information of the device to be monitored and / or the monitoring point update information.

6. The method according to claim 4, characterized in that The method further comprises: The breakpoint event is obtained from an event queue, and the breakpoint event is processed asynchronously; wherein the breakpoint event is sent to the event queue by the device to be monitored after the breakpoint event is triggered.

7. The method according to any one of claims 4 to 6, characterized in that: The method further comprises: The operation data is formatted and the operation data after the format conversion is stored.

8. A data acquisition device, characterized in that: include: An event sending module, used to start the virtual machine of the device to be monitored in debugging mode, trigger a start event, and send the start event to the monitoring device connected to the virtual machine, so that the monitoring device initiates a monitoring point registration request; The encapsulation registration module is used to encapsulate the monitoring point information carried in the monitoring point registration request into a breakpoint event when the monitoring point registration request is monitored, and call the debugging interface to register the breakpoint event; wherein the monitoring point information includes the monitoring method name, monitoring time and monitoring object; The data acquisition module is used to trigger the breakpoint event when the monitored device runs to the monitoring method corresponding to the monitoring method name, and obtain the operation data of the monitored device during operation.

9. A data acquisition device, characterized in that: include: A request generation module, used to obtain the startup event of the device to be monitored and the configured monitoring point information, and generate a monitoring point registration request carrying the monitoring point information; wherein the monitoring point information includes the monitoring method name, monitoring time and monitoring object; A request sending module, used for sending the monitoring point registration request to the device to be monitored, so that the device to be monitored encapsulates the monitoring point information into a breakpoint event and calls a debugging interface to register the breakpoint event; The data collection module is used to obtain the operation data of the monitored device when the breakpoint event is triggered.

10. An electronic device, characterized in that: include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 7.

11. A computer readable medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.

Citation Information

Patent Citations

  • Application program debugging method and device

    CN103699485A