CN109542444B - JAVA application monitoring method, device, server and storage medium - Google Patents

JAVA application monitoring method, device, server and storage medium Download PDF

Info

Publication number
CN109542444B
CN109542444B CN201710641288.4A CN201710641288A CN109542444B CN 109542444 B CN109542444 B CN 109542444B CN 201710641288 A CN201710641288 A CN 201710641288A CN 109542444 B CN109542444 B CN 109542444B
Authority
CN
China
Prior art keywords
monitored
java application
function
point
accurate
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201710641288.4A
Other languages
Chinese (zh)
Other versions
CN109542444A (en
Inventor
向小佳
迟显军
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Huawei Technologies Co Ltd
Original Assignee
Huawei Technologies Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Huawei Technologies Co Ltd filed Critical Huawei Technologies Co Ltd
Priority to CN201710641288.4A priority Critical patent/CN109542444B/en
Publication of CN109542444A publication Critical patent/CN109542444A/en
Application granted granted Critical
Publication of CN109542444B publication Critical patent/CN109542444B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/31Programming languages or programming paradigms
    • G06F8/315Object-oriented languages

Abstract

The application provides a monitoring method, a monitoring device, a server and a storage medium of JAVA application, wherein the method comprises the following steps: pre-compiling the JAVA application to be monitored in combination with DSL to obtain a filter; the filter is used for screening key points needing to be monitored in the program code of the JAVA application; when the JAVA application to be monitored runs, performing hash operation filtering on a program code of the JAVA application to be monitored by using a filter to obtain suspected plug-in points; performing word and grammar matching processing on the suspected insertion points according to the filter to obtain accurate insertion points and insertion logics; and performing alternative plugging operation on the accurate plugging points according to the plugging logic to obtain a monitoring result. By combining DSL precompilation and generating a bloom filter, the matching process of the plugged type is accelerated, the performance is improved, and the monitoring can be flexibly controlled through the alternative plugging.

Description

JAVA application monitoring method, device, server and storage medium
Technical Field
The present application relates to communications technologies, and in particular, to a monitoring method, an apparatus, a server, and a storage medium for a JAVA application.
Background
The complexity of large-scale JAVA application is higher and higher, and the application range is wider and wider. Therefore, the method monitors the application, ensures the stable and efficient operation of the application, can quickly locate the fault and becomes an important requirement of a software development enterprise.
Currently, monitoring of large JAVA applications mostly adopts a framework or program embedded point mode or a non-intrusive monitoring technology. The way of program embedded point refers to: the monitoring method comprises the steps of manually burying points in a frame or a program by development or maintenance personnel, simultaneously enabling the points to be online with monitored applications, simultaneously outputting log data, and obtaining a monitoring report through convergence analysis. For example, a CAT system for commenting on a network needs a program developer to carefully design a frame, select a proper embedded point position and manually write a program record log in the application development process so as to monitor the operation of a website in real time. And recording logs in the application running process, then summarizing the data, and finally analyzing and counting to obtain a result. The non-intrusive monitoring technology is used for modifying a binary execution file of a Java application program by means of instrumentation, so that the monitoring of functions in the JAVA application is realized.
However, the program embedded point mode needs to be developed in advance, embedded point programs and application programs coexist, and developers need to manually write programs with low flexibility and usability; although the non-intrusive monitoring technology can realize monitoring without changing programs, compiling and offline, instrumentation introduces performance overhead, cannot finely monitor functions of Java applications, and is lack of flexibility.
Disclosure of Invention
The application provides a JAVA application monitoring method, a JAVA application monitoring device, a JAVA application monitoring server and a JAVA application monitoring storage medium, and is used for solving the problems that developers need to manually write programs, and the usability is low.
A first aspect of the present application provides a method for monitoring a JAVA application, where the method includes:
pre-compiling the JAVA application to be monitored in combination with DSL to obtain a filter; the filter is used for screening key points needing to be monitored in the program codes of the JAVA application;
when the JAVA application to be monitored runs, performing hash operation filtering on a program code of the JAVA application to be monitored by using the filter to obtain a suspected plug-in point;
performing word and grammar matching processing on the suspected insertion points according to the filter to obtain accurate insertion points and insertion logics;
and performing alternative plugging operation on the accurate plugging points according to the plugging logic to obtain a monitoring result.
In the scheme, the bloom filter is generated by combining DSL precompilation, so that the matching process of the plugged type is accelerated, the performance is improved, and the monitoring can be flexibly controlled.
In a specific implementation manner, pre-compiling a JAVA application to be monitored in combination with a DSL to obtain a filter includes:
and pre-compiling the JAVA application to be monitored by combining the DSL to obtain points needing to be monitored in a program code of the JAVA application to be monitored, and recording a function signature corresponding to the points needing to be monitored into a bloom filter to obtain the filter.
In a specific implementation manner, when the JAVA application to be monitored runs, performing hash operation filtering on a program code of the JAVA application to be monitored by using the filter to obtain a suspected insertion point includes:
and when the codes corresponding to the JAVA applications to be monitored are loaded in the running environment, performing hash operation on the codes in the codes corresponding to the JAVA applications to be monitored respectively, and filtering results obtained after the hash operation by using the filter to obtain the suspected plug-in points in the JAVA applications to be monitored.
In another specific implementation manner, the performing, according to the instrumentation logic, an alternative instrumentation operation on the accurate instrumentation point to obtain a monitoring result includes:
according to the plug-in logic, taking over the input and output of each accurate plug-in point, and replacing the programmer codes corresponding to the accurate plug-in points on line;
and running the program code after each accurate plug-in point replacement, and recording the monitoring result.
The scheme provides an online replacement method based on replacement type plug-in mounting, completely replaces and controls program behaviors, can change program execution logic online, and completes tasks such as online upgrading and accurate regulation.
Optionally, the performing, according to the instrumentation logic, an alternative instrumentation operation on the accurate instrumentation point to obtain a monitoring result includes:
acquiring an original function of each accurate plugging point according to the plugging logic, and modifying and replacing the original function of the accurate plugging point to obtain a replacing function of the plugging point;
alternately executing the original function and the replacement function corresponding to each accurate plug-in point, acquiring call stack information when executing the replacement function, and burying points in each call stack; when the original function is executed, counting and acquiring time information of each call stack node function;
and acquiring the monitoring result according to the call stack information and the time information corresponding to each accurate insertion point.
On the basis of the online replacement, the scheme provides a time division replacement method and realizes a mechanism for acquiring the function accurate execution stack.
Optionally, the performing, according to the instrumentation logic, an alternative instrumentation operation on the accurate instrumentation point to obtain a monitoring result includes:
acquiring an original function of each accurate plugging point according to the plugging logic, and modifying and replacing the original function of the accurate plugging point to obtain a replacing function of the plugging point;
and executing the original function of each accurate plug-in point, simultaneously executing the replacement function by adopting another process, and monitoring and sampling the execution of the original function by the replacement function to obtain the monitoring result.
The scheme is expanded on the basis of the online replacement, provides an air separation replacement method and realizes a mechanism for acquiring a function execution flame diagram.
Further, the original function and the replacement function corresponding to each accurate plug-in point are executed alternately, call stack information is obtained when the replacement function is executed, and the point is buried in each call stack; when the original function is executed, the time information of each call stack node function is obtained through statistics, and the method comprises the following steps:
aiming at each accurate insertion point, when calling for the first time, executing a replacement function, acquiring call stack information and burying points in each call stack; and executing the original function in the subsequent calling process, and counting and acquiring the time information of each calling stack node function.
A second aspect of the present application provides an apparatus for monitoring a JAVA application, the apparatus comprising:
the system comprises a first processing module, a second processing module and a third processing module, wherein the first processing module is used for performing pre-compiling on a JAVA application to be monitored in combination with a DSL to obtain a filter; the filter is used for screening key points needing to be monitored in the program codes of the JAVA application;
the second processing module is used for performing hash operation filtering on the program code of the JAVA application to be monitored by adopting the filter when the JAVA application to be monitored runs to obtain a suspected plug-in point;
the third processing module is used for carrying out word and grammar matching processing on the suspected insertion points according to the filter to obtain accurate insertion points and insertion logics;
and the fourth processing module is used for carrying out alternative plugging operation on the accurate plugging points according to the plugging logic to obtain a monitoring result.
Optionally, the first processing module is specifically configured to:
and pre-compiling the JAVA application to be monitored by combining the DSL to obtain points needing to be monitored in a program code of the JAVA application to be monitored, and recording a function signature corresponding to the points needing to be monitored into a bloom filter to obtain the filter.
Optionally, the second processing module is specifically configured to:
and when the codes corresponding to the JAVA applications to be monitored are loaded in the running environment, performing hash operation on the codes in the codes corresponding to the JAVA applications to be monitored respectively, and filtering results obtained after the hash operation by using the filter to obtain the suspected plug-in points in the JAVA applications to be monitored.
Optionally, the fourth processing module is specifically configured to:
according to the plug-in logic, taking over the input and output of each accurate plug-in point, and replacing the programmer codes corresponding to the accurate plug-in points on line;
and running the program code after each accurate plug-in point replacement, and recording the monitoring result.
Optionally, the fourth processing module is specifically configured to:
acquiring an original function of each accurate plugging point according to the plugging logic, and modifying and replacing the original function of the accurate plugging point to obtain a replacing function of the plugging point;
alternately executing the original function and the replacement function corresponding to each accurate plug-in point, acquiring call stack information when executing the replacement function, and burying points in each call stack; when the original function is executed, counting and acquiring time information of each call stack node function;
and acquiring the monitoring result according to the call stack information and the time information corresponding to each accurate insertion point.
Optionally, the fourth processing module is specifically configured to:
acquiring an original function of each accurate plugging point according to the plugging logic, and modifying and replacing the original function of the accurate plugging point to obtain a replacing function of the plugging point;
and executing the original function of each accurate plug-in point, simultaneously executing the replacement function by adopting another process, and monitoring and sampling the execution of the original function by the replacement function to obtain the monitoring result.
Optionally, the fourth processing module is specifically configured to:
aiming at each accurate insertion point, when calling for the first time, executing a replacement function, acquiring call stack information and burying points in each call stack; and executing the original function in the subsequent calling process, and counting and acquiring the time information of each calling stack node function.
A third aspect of the present application provides a server comprising: a memory, a processor and a computer program, the computer program being stored in the memory, the processor running the computer program to perform the method for monitoring a JAVA application according to any of the first aspect.
In a specific implementation of the above server, the memory may be integrated within the processor. The number of processors is at least one, and is used to execute execution instructions stored in the memory, i.e., the computer program.
A fourth aspect of the present application provides a storage medium comprising: a readable storage medium and a computer program for implementing the method for monitoring a JAVA application according to any one of the first aspect.
A fifth aspect of the present application provides a program product comprising a computer program (i.e. executing instructions), the computer program being stored in a readable storage medium. The computer program may be read from a readable storage medium by at least one processor of the server, and execution of the computer program by the at least one processor causes the server to implement the monitoring method for the JAVA application provided by the first aspect or the various embodiments of the first aspect.
According to the monitoring method, device, server and storage medium of the JAVA application, the JAVA application to be monitored is precompiled in combination with the DSL and is used for screening key points needing to be monitored in program codes of the JAVA application to obtain a filter, when the JAVA application to be monitored runs, the program codes of the JAVA application to be monitored are subjected to Hash operation and filtering by adopting the filter to obtain suspected plug-in points, word and grammar matching processing is carried out on the suspected plug-in points according to the filter to obtain accurate plug-in points and plug-in logic, and replacement type plug-in operation is carried out on the accurate plug-in points according to the plug-in logic to obtain a monitoring result. By combining DSL precompilation and generating a bloom filter, the matching process of the plugged type is accelerated, the performance is improved, and the monitoring can be flexibly controlled.
Drawings
Fig. 1 is a flowchart of a first embodiment of a monitoring method for a JAVA application provided in the present application;
fig. 2 is a flowchart of a second embodiment of a monitoring method for JAVA applications provided in the present application;
fig. 3 is a flowchart of a third embodiment of a monitoring method for a JAVA application provided in the present application;
fig. 4 is a flowchart of a fourth embodiment of a monitoring method for a JAVA application provided in the present application;
fig. 5 is a schematic structural diagram of a monitoring apparatus for JAVA applications according to a first embodiment of the present disclosure.
Detailed Description
Monitoring and fault location of large Java application programs are difficult problems. The Java application is subjected to non-invasive point burying and data extraction, and real-time monitoring can be achieved on the premise that program codes and binary execution files are not modified. Such non-intrusive monitoring technologies are current system exploration tools, such as Jprofiler, and Application Performance Manager (APM) systems, such as appl dynamics, new reic, etc. cornerstones. However, aiming at the defects of high performance loss, poor flexibility and low precision of the current non-invasive monitoring technology, the method firstly provides a performance optimization scheme, and then provides a more flexible and more precise online replaceable insertion scheme based on the replaceable insertion, thereby making up the technical blank.
In a specific embodiment of the present solution, the following concepts are involved:
non-invasive Monitoring (Non-invasive Monitoring): and monitoring the monitored system in a mode of not interfering the monitored system.
Instrumentation (Instrumentation): on the basis of ensuring the original logic integrity of the tested program, some probes are inserted into the program, and the program running characteristic data is thrown out through the execution of the probes. The technology is combined with a data analysis technology, so that the control flow and data flow information of a program, logic coverage and other dynamic information can be obtained, and the test purpose is realized.
Java Virtual Machine (Java Virtual Machine, JVM): there are many different implementations of the Java program running environment, and the Java program running environment is commonly used in Hotspot of oracle corporation.
Application Performance Management (APM): application performance management belongs to the field of network management, and mainly refers to monitoring and optimizing key business applications of enterprises, improving the reliability and quality of the enterprise applications and ensuring that users obtain good services.
Fig. 1 is a flowchart of a first embodiment of a monitoring method for a JAVA application provided in the present application, where as shown in fig. 1, the scheme is implemented on a server running the JAVA application, and the specific steps of the monitoring method for the JAVA application include:
s101: pre-compiling the JAVA application to be monitored in combination with DSL to obtain a filter; the filter is used for screening key points needing to be monitored in the program codes of the JAVA application.
In this step, a domain-specific language (DSL), such as metadata, HTML, and the like, is designed for a large JAVA application that is specific to a specific domain, so that when monitoring the operation of the JAVA application, it is necessary to determine key points that need to be monitored in the JAVA application, and a specific determination manner is to pre-compile JAVA to be monitored in combination with the DSL, analyze possible key points therein, and record function signatures representing the key points into a bloom filter, so as to obtain corresponding filters.
S102: and when the JAVA application to be monitored runs, performing hash operation filtering on the program code of the JAVA application to be monitored by using the filter to obtain suspected plug-in points.
In the specific implementation of this step, the JAVA application to be monitored may be precompiled in combination with the DSL, a point that needs to be monitored in a program code of the JAVA application to be monitored is obtained, and a function signature corresponding to the point that needs to be monitored is entered into the bloom filter, so as to obtain the filter. The meaning is as follows: when the JVM loads the program of the JAVA application to be monitored, that is, when the JVM loads a JAVA class, the filter (i.e., the bloom filter) obtained in the above steps is used to quickly filter the JAVA class, and the filtering mode is to quickly eliminate non-plug-in points from the program of the JAVA application based on one-time Hash operation, so as to obtain suspected plug-in points and improve the performance.
S103: and performing word and grammar matching processing on the suspected insertion points according to the filter to obtain accurate insertion points and insertion logics.
In this step, when the running environment loads the code corresponding to the JAVA application to be monitored, performing a hash operation on the code in the code corresponding to the JAVA application to be monitored, and filtering a result obtained after the hash operation by using the filter to obtain the suspected insertion point in the JAVA application to be monitored. The meaning of this scheme is: and after the hash filtering of the last step, obtaining suspected insertion points, wherein the insertion logic refers to the contents to be replaced at the precise insertion points, namely, indicating that the codes can be subjected to insertion replacement. In order to accurately determine the accurate insertion point in the JAVA application to be monitored, the obtained suspected insertion point needs to be accurately matched again, and specifically, words and grammars of the content of the suspected insertion point can be matched (for example, regular grammar matching), so that the accurate insertion point is obtained, and the insertion logic is determined.
S104: and performing alternative plugging operation on the accurate plugging points according to the plugging logic to obtain a monitoring result.
Through the processing of the two stages, most Java classes can be filtered by the bloom filter generated in the first stage without participating in subsequent lexical and grammar fine matching and plugging processes, accurate plugging points can be determined from the JAVA application to be monitored, and then only plugging monitoring is needed to be carried out on the accurate plugging points.
The insertion operation in the scheme is different from Hook type insertion in which operation is added in the context of an inserted function in the prior art, and the scheme adopts alternate type insertion, namely, a class behavior mode is completely replaced and mastered, so that the monitoring of an accurate insertion point is realized, and a corresponding monitoring result is obtained.
The monitoring method of the JAVA application provided by the embodiment relates to a JAVA application-oriented non-invasive monitoring system, and is characterized in that precompilation, compiling and plugging of a domain-oriented language are linked, so that the accuracy of plugging can be greatly improved, the relevant plugging points of the concerned domain are focused, rapid filtering is carried out according to the relevant plugging points of the domain determined in the previous step during loading, the performance is improved, the plug-in monitoring is completed on the confirmed plugging points, a corresponding monitoring result is obtained, a developer does not need to manually write a program, the flexibility is improved, no additional performance overhead is introduced, and the fine monitoring of a JAVA application function to be monitored is realized.
By combining the above embodiments, the present solution designs and implements a JAVA application-oriented non-intrusive monitoring system, and designs and implements monitoring processes of pre-compiling, loading, weaving, running, storing, and displaying. In the step 1, the precompilation, the compilation and the instrumentation of the domain-oriented language are linked, so that the accuracy of the instrumentation can be greatly improved, and the relevant instrumentation points of the concerned domain can be focused; step 2, rapidly filtering according to the field-related plug-in points determined in the previous step in loading, and improving the performance; step 3, completing the insertion of the confirmed insertion points; fourthly, executing the function and the instrumentation logic of the JAVA class; fifthly, collecting and storing the monitoring data extracted from the plug-in buried points; and sixthly, completing data analysis and displaying.
On the basis of the above embodiment, the alternative instrumentation monitoring scheme in S104 at least includes several implementation manners of online replacement, time-division replacement, and space-division replacement, which are described in detail below.
In a first implementation manner, fig. 2 is a flowchart of a second embodiment of a monitoring method for a JAVA application provided in the present application. As shown in fig. 2, the alternative instrumentation monitoring scheme in S104 specifically includes the following steps:
s201: and taking over the input and output of each accurate plugging point according to the plugging logic, and replacing the programmer codes corresponding to the accurate plugging points on line.
S202: and running the program code after each accurate plug-in point replacement, and recording the monitoring result.
In the scheme, the server obtains an accurate plug-in point and plug-in logic according to the steps, and keeps the capability of dynamically acquiring the class to be executed by plugging the execution right of the function of the complete plug-in point; therefore, through non-invasive plug-in mounting, the execution logic of the accurate plug-in mounting point can be changed on line, upgrading and even complete replacement are completed, and the replaced program code is monitored to obtain a monitoring result.
The traditional method of the alternative instrumentation is to take over the input and output of the instrumented class (taking the Hello World class as an example), and to instrumentation various logics before and after calling the Byte Code of HelloWorld, even to change the input parameters and the output result, and the user sees a black box equivalent to HelloWorld. In the online replacement of the scheme, the execution right of HelloWorld is completely taken over through plug-in mounting, the capability of dynamically acquiring the class to be executed is kept, the execution logic of HelloWorld can be changed online, the upgrade is completed, and even the Hello World class is completely replaced. The specific implementation process is as follows: firstly, intercepting the loading right of Hello World; the cache operation, dynamic read configuration, acquires classes to be executed: new Version; and finally executing the execute operation, loading New Version, and transferring the execution right of Hello World to the New Version.
The monitoring method of the JAVA application provided by the scheme provides an online replacement method based on replacement type plug-in mounting, completely replaces and controls program behaviors, can change program execution logic online, and completes tasks such as online upgrading, accurate regulation and control and the like.
Based on the dynamic characteristics of the Choose operation in the online replacement, the time division effect can be realized, the replacement is immediately carried out, different programs are executed when the operations are called for different times, and complex logic is combined and completed.
In a second implementation manner, fig. 3 is a flowchart of a third embodiment of a monitoring method for a JAVA application provided in the present application. As shown in fig. 3, the alternative instrumentation monitoring scheme in S104 specifically includes the following steps:
s301: and acquiring the original function of each accurate insertion point according to the insertion logic, and modifying and replacing the original function of the accurate insertion point to obtain an insertion point replacement function.
S302: alternately executing the original function and the replacement function corresponding to each accurate plug-in point, acquiring call stack information when executing the replacement function, and burying points in each call stack; and when the original function is executed, counting and acquiring time information at each calling stack node function.
S303: and acquiring the monitoring result according to the call stack information and the time information corresponding to each accurate insertion point.
In the above steps, based on the embodiment shown in fig. 2, based on the dynamic characteristics of the Choose operation in online replacement, a time division effect can be achieved, namely time-division replacement, different programs are executed when different times of calling are carried out, complex logic is combined and completed, a performance point function is obtained according to an accurate insertion point, i.e., the primitive function at that point, may specifically be obtained automatically based on DSL precompilation, or may be specified by the user, the method is not limited, then the logic of the original function is modified to obtain a replacement function, finally the original function and the replacement function are executed in turn by utilizing a time division replacement mode, the call stack information of the replacement function is dynamically tracked and obtained, and each node of the call stack is subjected to point burying, when the original function is called, time statistical information is output at each node function of the call stack, and then an execution time sequence graph SpanTree can be obtained according to the statistical result.
In a specific implementation scheme of the scheme, aiming at each accurate insertion point, when calling for the first time, a replacement function is executed, call stack information is obtained, and a point is buried in each call stack; and executing the original function in the subsequent calling process, and counting and acquiring the time information of each calling stack node function.
Similarly, taking the above Hello World class as an example, the implementation process of the time division alternative scheme is as follows: firstly, obtaining a function Hello World of an accurate plug-in point according to DSL precompilation; replacing Hello World in time division to obtain a replacement function; and when the call is called for the second time, executing a buried point logic in the Hello World and each function of the call stack, outputting time statistical information and obtaining the SpanTree.
The monitoring method for JAVA applications provided in this embodiment is extended based on the above online replacement scheme, proposes a time-division replacement method, and implements a mechanism for obtaining a function accurate execution stack.
In the execution operation of online replacement, space division replacement can be completed, and by dispatching a new JVM process, concurrent multiple processes can be synchronized in communication, and complex logic is completed in a matching manner.
In a third implementation manner, fig. 4 is a flowchart of a fourth embodiment of a monitoring method for a JAVA application provided in the present application. As shown in fig. 4, the alternative instrumentation monitoring scheme in S104 specifically includes the following steps:
s401: and acquiring the original function of each accurate insertion point according to the insertion logic, and modifying and replacing the original function of the accurate insertion point to obtain an insertion point replacement function.
S402: and executing the original function of each accurate plug-in point, simultaneously executing the replacement function by adopting another process, and monitoring and sampling the execution of the original function by the replacement function to obtain the monitoring result.
In the above steps, the operation server obtains a performance point function according to the precise instrumentation point, that is, an original function at the point, which may be obtained automatically based on DSL precompilation specifically, or may be specified by a user, without limitation to this scheme, then modifies the logic of the original function to obtain a replacement function, and then replaces the original function by space division, where space division replacement refers to deriving a new JVM to execute the replacement function before executing the original function, and simultaneously monitors the execution of the original function, that is, monitors the JVM executing the original function, and synchronously operates between two JVM processes (where the two JVM processes communicate with each other through an Inter-Process Communication (IPC) mechanism), and monitors the JVM to sample the operation of the original function in the whole Process, and obtains sampling data, and can draw a flame diagram with the sampling data.
Similarly, taking the original function as Hello World class as an example, the specific implementation process of the space division replacement is as follows: firstly, obtaining a function Hello World of an accurate plug-in point according to DSL precompilation, replacing the Hello World by space division, intercepting the Hello World, deriving a new JVM process, and performing jstack sampling on the process executing the Hello World. And then executing the original function Hello World, initializing a new JVM process, performing attach operation on the JVM of the original function according to the pid, sampling the execution state of the JVM process executing the original function in the whole process, and finally drawing and rendering a flame diagram according to the sampling result.
The monitoring method for the JAVA application provided by the scheme is expanded on the basis of the online replacement, and the execution condition of the primitive function is monitored by executing two processes in parallel, so that the flexibility is higher, and a flame diagram can be obtained.
The technical scheme provided by the application can be used for debugging, performance calling and fault analysis, and the binary execution file of the program can not be off-line because the program does not need to be recompiled, so that the method is particularly suitable for online real-time monitoring of large JAVA application.
Meanwhile, the technical scheme is not limited to JAVA language, and any high-level language with runtime (such as JVM) can complete plug-in acceleration, flexible mode and high-precision function monitoring based on the technology.
Fig. 5 is a schematic structural diagram of a monitoring apparatus for JAVA applications according to a first embodiment of the present disclosure; as shown in fig. 5, the monitoring apparatus 10 for JAVA application includes:
the system comprises a first processing module 11, a second processing module and a third processing module, wherein the first processing module is used for performing pre-compiling on a JAVA application to be monitored in combination with a DSL to obtain a filter; the filter is used for screening key points needing to be monitored in the program codes of the JAVA application;
the second processing module 12 is configured to, when the JAVA application to be monitored runs, perform hash operation filtering on a program code of the JAVA application to be monitored by using the filter to obtain a suspected plug-in point;
a third processing module 13, configured to perform word and syntax matching processing on the suspected insertion points according to the filter, so as to obtain accurate insertion points and insertion logics;
and the fourth processing module 14 is configured to perform an alternative plugging operation on the accurate plugging point according to the plugging logic, and obtain a monitoring result.
The monitoring device for the JAVA application provided in this embodiment is used for executing the technical scheme of the foregoing monitoring method for the JAVA application, and its implementation principle and technical effect are similar, where the JAVA application to be monitored is precompiled in combination with a DSL to obtain a filter, then a key point to be monitored in a program code of the JAVA application is screened by the filter, then the program code of the JAVA application to be monitored is filtered by using the filter through hash operation to obtain a suspected plug-in point, and finally an accurate plug-in point and plug-in logic are obtained from the suspected plug-in point according to word and syntax matching, and finally an alternative plug-in operation is performed on the accurate plug-in point to monitor, thereby accelerating a matching process of plug-in type, improving performance, and flexibly controlling monitoring.
On the basis of the foregoing embodiment, in a second embodiment of the monitoring apparatus for JAVA applications, the first processing module 11 is specifically configured to:
and pre-compiling the JAVA application to be monitored by combining the DSL to obtain points needing to be monitored in a program code of the JAVA application to be monitored, and recording a function signature corresponding to the points needing to be monitored into a bloom filter to obtain the filter.
Optionally, the second processing module 12 is specifically configured to:
and when the codes corresponding to the JAVA applications to be monitored are loaded in the running environment, performing hash operation on the codes in the codes corresponding to the JAVA applications to be monitored respectively, and filtering results obtained after the hash operation by using the filter to obtain the suspected plug-in points in the JAVA applications to be monitored.
Optionally, the fourth processing module 14 is specifically configured to:
according to the plug-in logic, taking over the input and output of each accurate plug-in point, and replacing the programmer codes corresponding to the accurate plug-in points on line;
and running the program code after each accurate plug-in point replacement, and recording the monitoring result.
Optionally, the fourth processing module 11 is specifically configured to:
acquiring an original function of each accurate plugging point according to the plugging logic, and modifying and replacing the original function of the accurate plugging point to obtain a replacing function of the plugging point;
alternately executing the original function and the replacement function corresponding to each accurate plug-in point, acquiring call stack information when executing the replacement function, and burying points in each call stack; when the original function is executed, counting and acquiring time information of each call stack node function;
and acquiring the monitoring result according to the call stack information and the time information corresponding to each accurate insertion point.
Optionally, the fourth processing module 14 is specifically configured to:
acquiring an original function of each accurate plugging point according to the plugging logic, and modifying and replacing the original function of the accurate plugging point to obtain a replacing function of the plugging point;
and executing the original function of each accurate plug-in point, simultaneously executing the replacement function by adopting another process, and monitoring and sampling the execution of the original function by the replacement function to obtain the monitoring result.
Optionally, the fourth processing module 14 is specifically configured to:
aiming at each accurate insertion point, when calling for the first time, executing a replacement function, acquiring call stack information and burying points in each call stack; and executing the original function in the subsequent calling process, and counting and acquiring the time information of each calling stack node function.
The monitoring apparatus for JAVA application provided in this embodiment is used to execute the technical solution of the foregoing monitoring method for JAVA application, and its implementation principle and technical effect are similar, and are not described herein again.
The present application further provides a server, comprising: the monitoring method comprises a memory, a processor and a computer program, wherein the computer program is stored in the memory, and the processor runs the technical scheme of the monitoring method for the JAVA application provided by any one of the foregoing embodiments of the computer program.
In a specific implementation of the above server, the number of processors is at least one, and the processors are used for executing execution instructions stored in the memory, i.e. the computer program. Optionally, the memory may also be integrated within the processor.
The present application also provides a storage medium comprising: a readable storage medium and a computer program for implementing the solution of the method for monitoring JAVA applications provided by any of the preceding method embodiments.
The present application also provides a program product comprising a computer program (i.e. executing instructions), the computer program being stored in a readable storage medium. The computer program can be read from a readable storage medium by at least one processor of the server, and the at least one processor executes the computer program to make the server implement the technical solution of the monitoring method for JAVA applications provided by the foregoing various embodiments.
In the Specific implementation of the server, it should be understood that the Processor may be a Central Processing Unit (CPU), other general-purpose processors, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), etc. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like. The steps of a method disclosed in connection with the present application may be embodied directly in a hardware processor, or in a combination of the hardware and software modules in the processor.
All or a portion of the steps of implementing the above-described method embodiments may be performed by hardware associated with program instructions. The aforementioned program may be stored in a readable memory. When executed, the program performs steps comprising the method embodiments described above; and the aforementioned memory (storage medium) includes: read-only memory (ROM), RAM, flash memory, hard disk, solid state disk, magnetic tape (magnetic tape), floppy disk (flexible disk), optical disk (optical disk), and any combination thereof.

Claims (14)

1. A method for monitoring a JAVA application, the method comprising:
pre-compiling JAVA application to be monitored in combination with a domain specific language DSL to obtain a filter; the filter is used for screening key points needing to be monitored in the program codes of the JAVA application;
when the JAVA application to be monitored runs, performing hash operation filtering on a program code of the JAVA application to be monitored by using the filter to obtain a suspected plug-in point;
performing word and grammar matching processing on the suspected insertion points according to the filter to obtain accurate insertion points and insertion logics;
performing replacement type plugging operation on the accurate plugging point according to the plugging logic to obtain a monitoring result, wherein the replacement type plugging operation comprises online replacement operation, time division replacement operation or space division replacement operation;
the method for pre-compiling the JAVA application to be monitored in combination with the DSL to acquire the filter comprises the following steps:
and pre-compiling the JAVA application to be monitored by combining the DSL to obtain points needing to be monitored in a program code of the JAVA application to be monitored, and recording a function signature corresponding to the points needing to be monitored into a bloom filter to obtain the filter.
2. The method according to claim 1, wherein when the JAVA application to be monitored runs, performing hash operation filtering on a program code of the JAVA application to be monitored by using the filter to obtain suspected plug-in points, comprises:
and when the codes corresponding to the JAVA application to be monitored are loaded in the running environment, performing hash operation on the codes corresponding to the JAVA application to be monitored, and filtering the result obtained after the hash operation by using the filter to obtain the suspected plug-in points in the JAVA application to be monitored.
3. The method of claim 1 or 2, wherein said performing an alternative instrumentation operation on said precise instrumentation points according to said instrumentation logic to obtain a monitoring result comprises:
according to the insertion logic, taking over the input and output execution right of each accurate insertion point, and carrying out online replacement on the program code corresponding to the accurate insertion point;
and running the program code after each accurate plug-in point replacement, and recording the monitoring result.
4. The method according to claim 1 or 2, wherein said performing an alternative insertion operation on said precise insertion points according to said insertion logic to obtain a monitoring result comprises:
acquiring an original function of each accurate plugging point according to the plugging logic, and modifying and replacing the original function of the accurate plugging point to obtain a replacing function of the plugging point;
alternately executing the original function and the replacement function corresponding to each accurate plug-in point, acquiring call stack information when executing the replacement function, and burying points in each call stack; when the original function is executed, counting and acquiring time information of each call stack node function;
and acquiring the monitoring result according to the call stack information and the time information corresponding to each accurate insertion point.
5. The method according to claim 1 or 2, wherein said performing an alternative insertion operation on said precise insertion points according to said insertion logic to obtain a monitoring result comprises:
acquiring an original function of each accurate plugging point according to the plugging logic, and modifying and replacing the original function of the accurate plugging point to obtain a replacing function of the plugging point;
and executing the original function of each accurate plug-in point, simultaneously executing the replacement function by adopting another process, and monitoring and sampling the execution of the original function by the replacement function to obtain the monitoring result.
6. The method according to claim 4, wherein the original function and the replacement function corresponding to each precise plug-in point are executed alternately, call stack information is obtained when the replacement function is executed, and the point is buried in each call stack; when the original function is executed, the time information of each call stack node function is obtained through statistics, and the method comprises the following steps:
aiming at each accurate insertion point, when calling for the first time, executing a replacement function, acquiring call stack information and burying points in each call stack; and executing the original function in the subsequent calling process, and counting and acquiring the time information of each calling stack node function.
7. An apparatus for monitoring a JAVA application, the apparatus comprising:
the system comprises a first processing module, a second processing module and a monitoring module, wherein the first processing module is used for performing pre-compiling on a JAVA application to be monitored in combination with a domain specific language DSL to obtain a filter; the filter is used for screening key points needing to be monitored in the program codes of the JAVA application;
the second processing module is used for performing hash operation filtering on the program code of the JAVA application to be monitored by adopting the filter when the JAVA application to be monitored runs to obtain a suspected plug-in point;
the third processing module is used for carrying out word and grammar matching processing on the suspected insertion points according to the filter to obtain accurate insertion points and insertion logics;
the fourth processing module is used for performing alternative plugging operation on the accurate plugging point according to the plugging logic to obtain a monitoring result, wherein the alternative plugging operation comprises online replacement operation, time division replacement operation or space division replacement operation;
the first processing module is specifically configured to:
and pre-compiling the JAVA application to be monitored by combining the DSL to obtain points needing to be monitored in a program code of the JAVA application to be monitored, and recording a function signature corresponding to the points needing to be monitored into a bloom filter to obtain the filter.
8. The apparatus of claim 7, wherein the second processing module is specifically configured to:
and when the codes corresponding to the JAVA application to be monitored are loaded in the running environment, performing hash operation on the codes corresponding to the JAVA application to be monitored, and filtering the result obtained after the hash operation by using the filter to obtain the suspected plug-in points in the JAVA application to be monitored.
9. The apparatus according to claim 7 or 8, wherein the fourth processing module is specifically configured to:
according to the insertion logic, taking over the input and output execution right of each accurate insertion point, and carrying out online replacement on the program code corresponding to the accurate insertion point;
and running the program code after each accurate plug-in point replacement, and recording the monitoring result.
10. The apparatus according to claim 7 or 8, wherein the fourth processing module is specifically configured to:
acquiring an original function of each accurate plugging point according to the plugging logic, and modifying and replacing the original function of the accurate plugging point to obtain a replacing function of the plugging point;
alternately executing the original function and the replacement function corresponding to each accurate plug-in point, acquiring call stack information when executing the replacement function, and burying points in each call stack; when the original function is executed, counting and acquiring time information of each call stack node function;
and acquiring the monitoring result according to the call stack information and the time information corresponding to each accurate insertion point.
11. The apparatus according to claim 7 or 8, wherein the fourth processing module is specifically configured to:
acquiring an original function of each accurate plugging point according to the plugging logic, and modifying and replacing the original function of the accurate plugging point to obtain a replacing function of the plugging point;
and executing the original function of each accurate plug-in point, simultaneously executing the replacement function by adopting another process, and monitoring and sampling the execution of the original function by the replacement function to obtain the monitoring result.
12. The apparatus according to claim 10, wherein the fourth processing module is specifically configured to:
aiming at each accurate insertion point, when calling for the first time, executing a replacement function, acquiring call stack information and burying points in each call stack; and executing the original function in the subsequent calling process, and counting and acquiring the time information of each calling stack node function.
13. A server, comprising: memory, a processor and a computer program, the computer program being stored in the memory, the processor running the computer program to perform the monitoring method of the JAVA application of any of claims 1 to 6.
14. A storage medium, comprising: a readable storage medium and a computer program for implementing the monitoring method of the JAVA application of any one of claims 1 to 6.
CN201710641288.4A 2017-07-31 2017-07-31 JAVA application monitoring method, device, server and storage medium Active CN109542444B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710641288.4A CN109542444B (en) 2017-07-31 2017-07-31 JAVA application monitoring method, device, server and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710641288.4A CN109542444B (en) 2017-07-31 2017-07-31 JAVA application monitoring method, device, server and storage medium

Publications (2)

Publication Number Publication Date
CN109542444A CN109542444A (en) 2019-03-29
CN109542444B true CN109542444B (en) 2022-03-25

Family

ID=65823529

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710641288.4A Active CN109542444B (en) 2017-07-31 2017-07-31 JAVA application monitoring method, device, server and storage medium

Country Status (1)

Country Link
CN (1) CN109542444B (en)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111338613A (en) * 2020-03-03 2020-06-26 中国工商银行股份有限公司 Front-end point burying method and device based on jsp
CN111580813B (en) * 2020-03-25 2022-09-02 博雅信安科技(北京)有限公司 Automatic management method for Java class hot update
CN113419935B (en) * 2021-06-22 2023-10-20 康键信息技术(深圳)有限公司 Mobile terminal performance monitoring method, device, equipment and storage medium
CN113434399B (en) * 2021-06-23 2023-06-16 青岛海尔科技有限公司 Service node log processing method and device, storage medium and electronic device

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103617705A (en) * 2013-12-10 2014-03-05 北京邮电大学 Rule-based method and system for alarming of Internet of things
CN106664322A (en) * 2014-08-29 2017-05-10 微软技术许可有限责任公司 Event stream transformations

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10127025B2 (en) * 2015-07-22 2018-11-13 Oracle International Corporation Optimization techniques for high-level graph language compilers

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103617705A (en) * 2013-12-10 2014-03-05 北京邮电大学 Rule-based method and system for alarming of Internet of things
CN106664322A (en) * 2014-08-29 2017-05-10 微软技术许可有限责任公司 Event stream transformations

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
可定制的web监控系统的设计与实现;高伟;《中国优秀硕士学位论文全文数据库信息科技辑》;20131115;正文第14-48页 *

Also Published As

Publication number Publication date
CN109542444A (en) 2019-03-29

Similar Documents

Publication Publication Date Title
CN106909510B (en) Method for obtaining test case and server
US6539501B1 (en) Method, system, and program for logging statements to monitor execution of a program
CN109542444B (en) JAVA application monitoring method, device, server and storage medium
US7900198B2 (en) Method and system for parameter profile compiling
US20110191752A1 (en) Method and System for Debugging of Software on Target Devices
US9355003B2 (en) Capturing trace information using annotated trace output
CN106325970A (en) Compiling method and compiling system
KR20090017598A (en) Iterative static and dynamic software analysis
CN102402479B (en) For the intermediate representation structure of static analysis
US20110126179A1 (en) Method and System for Dynamic Patching Software Using Source Code
WO2018204032A1 (en) Conditional debugging of server-side production code
US9117020B2 (en) Determining control flow divergence due to variable value difference
US20080127119A1 (en) Method and system for dynamic debugging of software
US10997055B2 (en) Methods, circuits, apparatus, systems and associated software modules for evaluating code behavior
US20180189167A1 (en) Methods, circuits, apparatus, systems and associated software modules for evaluating code behavior
US10185647B2 (en) Debugging remote vertex code on test machine
US11755458B2 (en) Automatic software behavior identification using execution record
CN108304164B (en) Business logic development method and development system
CN109284222B (en) Software unit, project testing method, device and equipment in data processing system
CN107977304B (en) System debugging method and device
CN115705250A (en) Monitoring stack usage to optimize programs
EP3619612B1 (en) Temporary de-optimization of target functions in a cloud debugger
US9032372B2 (en) Runtime environment and method for non-invasive monitoring of software applications
US20190190981A1 (en) Intelligent trace generation from compact transaction runtime data
CN106155895A (en) Script data processing method and processing device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
TA01 Transfer of patent application right
TA01 Transfer of patent application right

Effective date of registration: 20200217

Address after: 518129 Bantian HUAWEI headquarters office building, Longgang District, Guangdong, Shenzhen

Applicant after: HUAWEI TECHNOLOGIES Co.,Ltd.

Address before: 210012 HUAWEI Nanjing base, 101 software Avenue, Yuhuatai District, Jiangsu, Nanjing

Applicant before: Huawei Technologies Co.,Ltd.

GR01 Patent grant
GR01 Patent grant