Program running state diagnosis method, electronic equipment and computer readable storage medium
Through the collaborative work of the transit agent and the diagnostic agent, the Java Agent program is used to simplify the program's running state diagnosis process, solving the problems of high diagnostic complexity and high resource consumption in the existing technology, and achieving an efficient and simplified diagnostic experience.
Patent Information
- Application Number
- CN202411717294.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-27
- Publication Date
- 2025-03-18
AI Technical Summary
The existing technology is difficult to diagnose program running status, and requires entering the program deployment environment, which is complex in operation, and the existing solutions have problems with high resource consumption, lack of management functions and high availability.
The diagnostic instructions of the user interface are obtained through the transit agent and forwarded to the diagnostic agent. The Java Agent program is used to realize the command transmission between the user interface and the diagnostic agent, reducing network resource usage and CPU and memory overhead, and providing the user interface to simplify the diagnostic process.
It reduces the complexity of program running state diagnosis, reduces the overhead of network resources, CPU and memory, and provides a user-friendly interface, which is convenient and fast diagnosis without the need for complex container command operations and diagnostic programs download and installation.
Smart Images

Figure CN119645780A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a method for diagnosing program running status, an electronic device, and a computer-readable storage medium. Background Art
[0002] Interactive analysis is currently implemented using Alibaba Arthas. When using Alibaba Arthas, you generally need to enter the program deployment environment, which makes implementation relatively complex. Summary of the invention
[0003] The purpose of the present application is to provide a method for diagnosing program running status, an electronic device and a computer-readable storage medium, which can reduce the difficulty of diagnosing program running status.
[0004] In a first aspect, the present invention provides a method for diagnosing the running status of a program, comprising: obtaining a diagnostic instruction of a user interface through a relay agent; forwarding the diagnostic instruction to a diagnostic agent through the relay agent; wherein the relay agent and the diagnostic agent are Java Agent programs; diagnosing an instance in a target program based on the diagnostic instruction to obtain a diagnostic result through the diagnostic agent; and transmitting the diagnostic result to the user interface through the relay agent.
[0005] In the above implementation, a relay agent is used to realize the transmission of commands between the user interface and the diagnostic agent. The use of the relay agent can reduce the use of network resources and reduce the corresponding CPU and memory overhead. In addition, a user interface is provided to facilitate users to quickly find the instance that needs to be diagnosed and start diagnosis immediately, without the need for complex container command operations and diagnostic program download and installation operations, thereby reducing the complexity of program running status diagnosis.
[0006] In an optional embodiment, obtaining the diagnostic instructions of the user interface through the relay agent includes: communicating with the control plane through the relay agent to obtain the diagnostic instructions of the user interface from the control plane; wherein the control plane is used to monitor the user interface to obtain the diagnostic instructions in the user interface.
[0007] In an optional embodiment, the method also includes: the user interface establishing a connection with the control plane through the WebSocket protocol to transmit the diagnostic instructions to the control plane; subscribing to connection data information associated with the connection between the user interface and the control plane; wherein the connection data information is used to mark the application instance required to be diagnosed by the diagnostic agent and the channel used for communication.
[0008] In an optional implementation, the method further includes: the transit agent establishing a connection with the control plane through a gRPC channel; subscribing to process data information of the diagnostic process; wherein the process data information is used to mark the diagnostic command execution strategy of the diagnostic process.
[0009] In an optional implementation, forwarding the diagnostic instruction to the diagnostic agent through the transit agent includes: calling a first native function through the transit agent to issue the diagnostic instruction to the diagnostic agent through the first native function.
[0010] In an optional implementation, before transmitting the diagnosis result to the user interface through the relay agent, the method further includes: calling a second local function through the diagnosis agent to send the diagnosis result to the relay agent through the second local function.
[0011] In the above implementation, command forwarding can be achieved by calling a local function instead of a remote call, which can reduce the difficulty of implementing the diagnosis process, reduce the processing resources required for diagnosis, and reduce the complexity of diagnosis implementation.
[0012] In an optional embodiment, before forwarding the diagnostic instruction to the diagnostic agent through the relay agent, it also includes: injecting the first application programming interface of the relay agent and the second application programming interface of the diagnostic agent into the startup class loader; forwarding the diagnostic instruction to the diagnostic agent through the relay agent includes: based on the startup class loader, forwarding the diagnostic instruction to the diagnostic agent through the relay agent.
[0013] In a second aspect, the present invention provides an electronic device, comprising: a processor and a memory, wherein the memory stores machine-readable instructions executable by the processor, and when the electronic device is running, the machine-readable instructions are executed by the processor to perform the steps of the method described in any one of the aforementioned implementations.
[0014] In a third aspect, the present invention provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the steps of the method described in any one of the aforementioned embodiments are executed.
[0015] In a fourth aspect, the present invention provides a computer program product, wherein the computer program product comprises a computer program, and when the computer program is executed by a processor, the method described in any one of the aforementioned embodiments is implemented. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.
[0017] Figure 1 A block diagram of an electronic device provided in an embodiment of the present application;
[0018] Figure 2 A schematic diagram of the system architecture involved in the program running status diagnosis method provided in an embodiment of the present application;
[0019] Figure 3 A flowchart of a method for diagnosing program running status provided in an embodiment of the present application;
[0020] Figure 4 A schematic diagram of a module of a virtual machine provided in an embodiment of the present application;
[0021] Figure 5 A schematic diagram of the program running status diagnosis logic flow provided in an embodiment of the present application. DETAILED DESCRIPTION
[0022] The technical solutions in the embodiments of the present application will be described below in conjunction with the accompanying drawings in the embodiments of the present application.
[0023] It should be noted that similar reference numerals and letters represent similar items in the following drawings, so once an item is defined in one drawing, it does not need to be further defined and explained in subsequent drawings. At the same time, in the description of this application, the terms "first", "second", etc. are only used to distinguish the description and cannot be understood as indicating or implying relative importance.
[0024] Interactive analysis mainly refers to a method of interacting with the runtime system (usually referred to as Runtime) of a running program at the command line level to detect the program's running status. Interactive analysis is a way to diagnose the real-time running status of a program. General application performance analysis systems can usually only analyze the running status of a program according to established logic, which is limited by the fact that the performance is generally coarse-grained and has delays of seconds or minutes. Interactive analysis can provide real-time (e.g., milliseconds), fine-grained, and highly flexible analysis, and can directly call the runtime methods of the program.
[0025] Interactive analysis is implemented differently in different languages and frameworks. Generally, in the Java field, the industry mainly uses Alibaba Arthas. In the Ruby on Rails framework, the framework provides the Rails Console function, which can directly interact with the running program through the command line.
[0026] If you use Alibaba Arthas to detect the running status of the program, you need to enter the environment where the program is deployed. For example, if the program is deployed in a Docker container, you need to enter the corresponding Docker container and download the corresponding Arthas package, and then execute the relevant commands to load it into the running Java process to diagnose the service. If you use a distributed container orchestration tool, such as Kubernetes, you need to first know the host machine where the program is running, or use the kubectl tool to enter the container and repeat the above download, installation, and running steps.
[0027] As mentioned above, the existing technology requires locating the application instance and the host machine and cluster where it is located before interactive diagnosis, and then entering the corresponding operating system environment to perform tedious download and installation operations. However, the demand for interactive analysis often comes from sudden situations of microservices in the production environment, such as CPU increase, sudden business abnormalities, OOM, etc. The time given to business R&D to respond is very limited. If a lot of time is spent on locating instances and installation operations, it will obviously affect the efficiency of diagnosis.
[0028] In order to improve the above shortcomings, the Tunnel Server / Client solution can also be used to implement the use of Arthas. In the interactive analysis scenario, it can achieve remote fast connection. However, the Tunnel Server / Client solution requires users to actively download the Arthas program and start connecting to the Tunnel Server as a Tunnel Client mode. This solution has the following shortcomings: Lack of integrity: It relies significantly on external download and installation logic; Lack of management functions: In terms of technical implementation, the Tunnel Server simply forwards the connection and does not have enterprise-level functions such as security auditing and command interception; Large resource consumption: Arthas Agent needs to use a large amount of additional network-related resources to enable the Tunnel Client function, such as loading Netty Jar packages, establishing TCP connections, etc. For a microservice system that already has insufficient resources, the cost is relatively high; Tunnel Server is a single point and cannot achieve high availability.
[0029] Based on the above research, the embodiments of the present application may provide a program running status diagnosis method, an electronic device, and a computer-readable storage medium, which can reduce the difficulty of implementing interactive analysis and the computing and communication resource requirements of the computer.
[0030] To facilitate understanding of this embodiment, first, an electronic device that executes the program running status diagnosis method disclosed in the embodiment of the present application is introduced in detail.
[0031] like Figure 1 , which is a block diagram of an electronic device. The electronic device 100 may include a memory 111, a storage controller 112, a processor 113, a peripheral interface 114, an input and output unit 115, and a display unit 116. A person skilled in the art may understand that Figure 1 The structure shown is only for illustration and does not limit the structure of the electronic device 100. For example, the electronic device 100 may further include Figure 1 More or fewer components as shown, or with Figure 1 Different configurations shown.
[0032] The memory 111, storage controller 112, processor 113, peripheral interface 114, input / output unit 115 and display unit 116 are electrically connected to each other directly or indirectly to achieve data transmission or interaction. For example, these components can be electrically connected to each other via one or more communication buses or signal lines. The processor 113 is used to execute the executable module stored in the memory.
[0033] The memory 111 may be, but not limited to, a random access memory (RAM), a read only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable read-only memory (EEPROM), etc. The memory 111 is used to store programs, and the processor 113 executes the program after receiving the execution instruction. The method executed by the electronic device 100 defined by the process disclosed in any embodiment of the present application can be applied to the processor 113, or implemented by the processor 113.
[0034] The processor 113 may be an integrated circuit chip with signal processing capability. The processor 113 may be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it may also be a digital signal processor (DSP), a dedicated integrated circuit.
[0035] (Application Specific Integrated Circuit, referred to as ASIC), Field Programmable Gate Array (Field Programmable Gate Array, referred to as FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components. The methods, steps and logic block diagrams disclosed in the embodiments of the present application can be implemented or executed. The general processor can be a microprocessor or the processor can also be any conventional processor, etc.
[0036] The peripheral interface 114 couples various input / output devices to the processor 113 and the memory 111. In some embodiments, the peripheral interface 114, the processor 113 and the memory controller 112 can be implemented in a single chip. In other embodiments, they can be implemented by separate chips.
[0037] The input and output unit 115 is used to provide input data to the user. The input and output unit 115 can be, but is not limited to, a mouse and a keyboard.
[0038] The display unit 116 provides an interactive interface (e.g., a user operation interface) between the electronic device 100 and the user or is used to display image data for the user's reference. In this embodiment, the display unit may be a liquid crystal display or a touch display. If it is a touch display, it may be a capacitive touch screen or a resistive touch screen that supports single-point and multi-point touch operations. Supporting single-point and multi-point touch operations means that the touch display can sense touch operations generated simultaneously from one or more positions on the touch display, and the sensed touch operations are handed over to the processor for calculation and processing.
[0039] In this embodiment, the display unit 116 may display a user interface, which may provide operations related to program running status diagnosis. For example, the user interface may provide a diagnosis range and diagnosis means required for program running status diagnosis.
[0040] Optionally, the user interface may be a web user interface (Web User Interface, Web UI for short). A browser may be running in the electronic device 100, and the user interface is accessed through the browser.
[0041] like Figure 2 As shown, Figure 2 A schematic diagram of the system architecture involved in the program running status diagnosis method provided in an embodiment of the present application is shown. The user can perform interactive operations on the user interface to determine the target application to be diagnosed and the instance corresponding to the target application. The user interface determines the diagnostic instructions based on the user operation. The user interface can be connected to the control plane through the WebSocket protocol to transmit the diagnostic instructions to the control plane. The control plane can transmit the diagnostic instructions through the gRPC channel and the transit agent. The transit agent can send the diagnostic instructions to the diagnostic agent by calling a local function.
[0042] exist Figure 2 In the example shown, the relay agent and the diagnostic agent run in a Java Virtual Machine (JVM), and an application program also runs in the Java Virtual Machine. The Java Virtual Machine runs in a container, and the container runs in a deployable computing unit (Pod).
[0043] The electronic device 100 in this embodiment can be used to execute each step in each method provided in the embodiments of the present application. The implementation process of the program running status diagnosis method is described in detail below through several embodiments.
[0044] See also Figure 3 , is a flowchart of a program running status diagnosis method provided in an embodiment of the present application. The program running status diagnosis method provided in an embodiment of the present application can be applied to an electronic device, and the steps in the program running status diagnosis method are performed by the electronic device. Figure 3 The specific process shown is described in detail.
[0045] Step 210: Obtain the diagnostic instruction of the user interface through the transfer agent.
[0046] The transfer agent can serve as an intermediate link to transmit the diagnostic instruction obtained in the user interface to the diagnostic agent that executes the diagnostic instruction.
[0047] Exemplarily, the program running status diagnosis can be applied in the Java field, and the transfer agent can be a JavaAgent program. For example, the transfer agent can be an APM Agent (Application Performance Management Agent).
[0048] The user interface can be used as an interactive interface with the user. The user interface is used to obtain the user's input information and can also display the execution result of the diagnostic instruction. Exemplarily, the user interface can be a self-developed and designed web page, including a simulated command line interface that can interact with the user input.
[0049] Exemplarily, the transit agent may not directly obtain the diagnostic instruction obtained by the user interface, but may obtain it through a control plane in the background of the user interface.
[0050] The diagnostic instruction may be different based on different user selections. Exemplarily, the diagnostic instruction may be one or more of dynamic tracking, hot update, memory analysis, thread analysis, and the like.
[0051] Step 220: forward the diagnostic instruction to the diagnostic agent via the transit agent.
[0052] In this embodiment, both the transit agent and the diagnosis agent can run in a Java virtual machine, and the transit agent can send a diagnosis instruction to the diagnosis agent through a local call.
[0053] Exemplarily, the diagnostic agent may be a Java Agent program.
[0054] Exemplarily, the above step 220 may include: calling the first native function through the transit agent, so as to send the diagnosis instruction to the diagnosis agent through the first native function.
[0055] After the diagnosis agent obtains the diagnosis result, the second native function may be called by the diagnosis agent to send the diagnosis result to the transit agent through the second native function.
[0056] Step 230 , diagnose the instance in the target program based on the diagnostic instruction through the diagnostic agent to obtain a diagnostic result.
[0057] In this embodiment, the diagnostic agent can be a diagnostic tool for implementing interactive analysis of the target program. The diagnostic tool is different in different languages and frameworks. Taking the Java field as an example, the diagnostic agent can be an Arthas agent. The diagnostic instruction can be a command supported by the Arthas agent. Based on the difference of the target program, the corresponding diagnostic instruction can also be different. The diagnostic instruction can be an instruction that adapts to the diagnostic needs of the target program.
[0058] Step 240: Transmit the diagnosis result to the user interface via the relay agent.
[0059] In this embodiment, the transit agent may not communicate directly with the user interface, but may implement transmission through the control panel.
[0060] After the user interface obtains the diagnosis result, it can display it.
[0061] Take the logger instruction, in which the diagnostic instruction is used to output the log output related information of the instance, as an example:
[0062] The transit agent can send RemoteCommandTaskCommand to the diagnosis agent:
[0063] RemoteCommandTaskCommand(remoteCommand=logger, action=API_ACTION_EXEC, sessionId=53a6410c-ee65-4c48-bfe3-258cf277a0f8, consumerId=d890c988a7784f498fd5505d4e149fb8_1, execTimeout=0)
[0064] The result of the diagnostic agent executing the diagnostic instruction (AgentAPI.AgentResponse):
[0065] AgentAPI.AgentResponse(requestId=091e2b2e-e258-4598-a630-98dcf7ff914e,state=SUCCEEDED,message=null,jobId=null,sessionId=53a6410c-ee65-4c48-bfe3-258cf277a0f8,consumerId=null,body={\"command\":\"logger\",\"jobId\":1,\"job Status\":\"TERMINATED\",\"results\":[{\"jobId\":1,\"loggerInfoMap\":{\"ROO T\":{\"name\":\"ROOT\",\"class\":\"com.alibaba.arthas.deps.ch.qos.logback.clas sic.Logger\",\"codeSource\":\"file: / Users / megrez / Code / shouqianba / hera / target / hera-agent / arthas / hera-arthas-core.jar\",\"additivity\":true,\"level\":\"DEBUG\",\"effectiveLevel\":\"DEBUG\",\"appenders\":[{\"name\":\"console\",\"class\":\"com.alibaba.arthas.deps.ch.qos.logback.core.ConsoleAppender\",\"target\":\"System.out\",\"classLoader\":\"co m.wosai.middleware.hera.agent.attach.AttachArthasClassloader@61cab58d\",\"classLoaderHash\":\"61cab58d\"}],\"classLoader\":\"com.wosai.middleware.her a.agent.attach.AttachArthasClassloader@61cab58d\",\"classLoaderHash\":\"61cab58d\"}},\"type\":\"logger\"},{\"jobId\":1,\"statusCode\":0,\"type\":\"status\"}],\"timeExpired\":false}).
[0066] Specifically, when the diagnosis instructions are different, the results of the diagnosis instructions. The above body field is used to distinguish the content and format of the diagnosis result, and the content in the above body field is different when the diagnosis instructions are different.
[0067] Based on the user interface, diagnostic instructions are obtained, which allows users to quickly find the instance that needs to be diagnosed and start diagnosis immediately, without the need for complex container command operations and diagnostic program download and installation operations, thus reducing the complexity of program running status diagnosis. By using a transit agent to transmit commands between the user interface and the diagnostic agent, the use of a transit agent can reduce the use of network resources and the corresponding CPU and memory overhead.
[0068] In this embodiment, the user interface is an interface for interacting with the user, which provides an intuitive interface for the user, and the implementation of the functions of the user interface can rely on the control plane of the background. The user interface can simplify the operations of the complex control plane into operations on the interface that are easy for the user to understand and execute. Based on this, the above step 210 may include: communicating with the control plane through the transit agent to obtain the diagnostic instructions of the user interface from the control plane.
[0069] The control plane is used to monitor the user interface to obtain the diagnostic instructions in the user interface.
[0070] In this embodiment, before obtaining the diagnostic instruction based on the user interface, a connection may be established first. Based on this, before step 210, it may include: the user interface establishes a connection with the control plane through the WebSocket protocol to transmit the diagnostic instruction to the control plane.
[0071] Exemplarily, the connection between the user interface and the control plane may be bidirectional, the control plane may feed back results to the user interface, and the user interface may transmit instructions to the control plane.
[0072] When the WebSocket connection is established, you can also subscribe to the connection data information associated with the connection between the user interface and the control plane.
[0073] The connection data information is used to mark the application instance that the diagnosis agent needs to diagnose and the communication channel. The diagnosis result from the diagnosis agent is accurately received based on the connection data information.
[0074] Exemplarily, the connection data information of the connection association between the subscription user interface and the control plane may be implemented based on a distributed subscription publishing component.
[0075] Optionally, the connection data information may include instance identification information of the connection, the type of data transmitted, and data. The instance identification information of the connection may represent a unique ID of the WebSocket.
[0076] Exemplarily, each item of data information may include a field name and a data type. Taking the following Table 1 as an example, the connection data information may include the following contents:
[0077] Table 1
[0078]
[0079] By subscribing to the above data information, after obtaining the diagnostic result, when the diagnostic result needs to be transmitted, the data used to feedback the diagnostic result will carry the WebSocket unique ID for sending the diagnostic instruction. Based on the WebSocket unique ID, the diagnostic result can be sent to the specified WebSocket channel, and the user interface will then display based on the received diagnostic result.
[0080] Before step 210, a connection between the transit agent and the control plane may also be established.
[0081] Optionally, the transit agent establishes a connection with the control plane through a gRPC channel. After the connection is established, the process data information of the diagnostic process can also be subscribed.
[0082] The connection between the relay agent and the control plane may be bidirectional. The control plane may transmit a diagnostic instruction to the relay agent, and the relay agent may also feed back a diagnostic result to the control plane.
[0083] The process data information is used to mark the diagnostic command execution strategy of the diagnostic process.
[0084] Exemplarily, the process data information may include synchronous execution, asynchronous execution, interrupting tasks, pulling task execution results, initializing sessions, etc.
[0085] The process data information may further include a presentation form of the agreed command, for example, a command that may be represented in a string form.
[0086] Optionally, the process data information may be described using the Protobuf protocol. In one example, the process data information described by the Protobuf protocol may be:
[0087] message CommandResponse{
[0088] / / Command types: including synchronous execution, asynchronous execution, interrupting tasks, pulling task execution results, initializing sessions, etc.
[0089] ApiAction action = 1;
[0090] / / Commands expressed as strings
[0091] string command=2;
[0092] / / Request ID, generated by the control plane
[0093] string request_id = 3;
[0094] / / Session ID, generated during the initialization session
[0095] string session_id = 4;
[0096] / / Consumer ID, generated during the initialization session
[0097] string consumer_id = 5;
[0098] / / Client ID, because it identifies users of different user interfaces
[0099] string client_id = 6;
[0100] / / Command execution timeout
[0101] int32 exec_timeout = 7;
[0102] It is understandable that the process data information described in the Protobuf protocol is merely exemplary. In actual situations, the values of the above-mentioned character strings may be different, and the number of information items included may be more or less.
[0103] After receiving the feedback from the diagnostic agent, the relay agent feeds back the diagnostic results to the control plane through the gRPC bidirectional channel. In this embodiment, the data fed back by the relay agent may include a WebSocket unique ID in addition to the diagnostic results. The WebSocket unique ID can be used to send the diagnostic results to the specified WebSocket channel, and the user interface can finally display the results of the diagnostic instructions.
[0104] If the user interface is accessed through a browser, the WebSocket unique ID may be the browser WebSocket unique ID.
[0105] In this embodiment, the data delivery between the transit agent and the diagnosis agent can rely on the upper layer startup class loader in the virtual machine. Before the above step 220, it can also include: injecting the first application programming interface of the transit agent and the second application programming interface of the diagnosis agent into the startup class loader.
[0106] Step 220 may include forwarding the diagnostic instruction to the diagnostic agent through the transit agent based on the startup class loader.
[0107] Combine the following Figure 4 The example shown is used to describe the interaction between the agents in the virtual machine.
[0108] exist Figure 4 In the example shown, the virtual machine runs an enabling class loader (BootstrapClassLoader), an extension class loader (ExtClassLoader), an application class loader (App ClassLoader), and a custom class loader.
[0109] Among them, the transit agent and the diagnosis agent run in the application class loader.
[0110] The startup class loader is mainly responsible for loading basic classes related to the internal implementation of JDK. The extension class loader is used to load classes in the ext directory.
[0111] All Java Agent codes are loaded by the application class loader by default. If two Java Agents need to communicate at the function level, they must use the upper-level startup class loader.
[0112] Custom class loaders are usually used to load application code, such as Spring Boot's LaunchedURLClassLoader or Tomcat's WebappClassLoader.
[0113] In this example, before the relay agent communicates with the diagnosis agent, an agent application programming interface (Agent API) that can be used for the relay agent to communicate with the diagnosis agent is injected into the activation class loader.
[0114] When the transit agent sends a diagnostic instruction to the diagnostic agent, the agent application programming interface can be called through a local function to send the diagnostic instruction to the diagnostic agent.
[0115] After the diagnostic agent completes the diagnosis of the instance of the target program, it can discover the diagnostic results to the transit agent and can call the agent application programming interface through a local function to send the diagnostic results to the transit agent.
[0116] Through the above method, the communication between the transit agent and the diagnosis agent can be realized based on the existing virtual machine architecture, which can reduce the computing resources and memory resources required for interactive analysis.
[0117] In order to better meet the needs of a larger number of program running status diagnosis, the distributed subscription and publishing function can be used to solve the single point failure problem and achieve high availability deployment. Figure 5 The process is used to describe the diagnosis based on distributed subscription and publishing components.
[0118] After the browser accesses the user interface, a WebSocket connection can be established between the user interface and the control plane. If it is the first time to establish a WebSocket connection, the connection data information can be subscribed to from the distributed subscription and publishing component, which includes the WebSocket's unique ID, timestamp, and other information associated with the connection.
[0119] The distributed subscription and publishing component may be a DistributedPubSub component.
[0120] Create an Http TtyConnection instance, and transmit the diagnostic instruction to the relay agent based on the Http TtyConnection instance. After creating the Http TtyConnection instance, it can be written into the user data.
[0121] Then determine whether the received data needs to be sent to the transit agent.
[0122] Exemplarily, if the received data is a diagnostic instruction, it needs to be sent to the transit agent.
[0123] When it needs to be sent to the transit agent, it can be further determined whether it is a synchronous instruction or an asynchronous instruction. If it is a synchronous instruction, the synchronous instruction can be sent to the DistributedPubSub component; if it is an asynchronous instruction, the asynchronous instruction can be sent to the DistributedPubSub component, and a pull instruction can be sent to pull the diagnosis execution result.
[0124] The transit agent and diagnostic agent that need to communicate can establish a gRPC bidirectional connection and subscribe to communication-related process data information based on the DistributedPubSub component.
[0125] After receiving the diagnostic instructions, the transit agent and the diagnostic agent feed back the diagnostic results to the control plane through the DistributedPubSub component, and then further feed back to the user interface for display by the user interface.
[0126] Through the above process, the asynchronous instructions of Arthas agent can be better supported, such as TimeTunnel, Watch, Trace, etc.; the instructions can also be audited, and the auditing and management of commands can be realized.
[0127] In the embodiment of the present application, since a user interface is provided, it is more convenient for users to quickly find instances of target programs that need to be diagnosed and to implement diagnosis more quickly. With the help of the user interface, there is no need to perform complex container command operations and Arthas program download and installation operations.
[0128] In the above implementation process, the diagnosis obtained by the user interface can be audited and managed. For example, the execution of some high-risk commands (such as heapdump, etc.) can be prohibited, or the use of some parameters of some commands can be prohibited. This can increase the flexibility of diagnosis and improve the security of diagnosis.
[0129] In an embodiment of the present application, the transit agent (APM Agent) in the computer can be fully utilized, and the network channel (gRPC) established by it can be used for network interaction, and duplicate functions can be merged, thereby reducing the use of network resources and reducing the corresponding CPU and memory overhead.
[0130] In addition, an embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the program running status diagnosis method described in the above method embodiment are executed.
[0131] The computer program product of the program running status diagnosis method provided in the embodiment of the present application includes a computer-readable storage medium storing program code, and the instructions included in the program code can be used to execute the steps of the program running status diagnosis method described in the above method embodiment. Please refer to the above method embodiment for details, which will not be repeated here.
[0132] In several embodiments provided in the present application, it should be understood that the disclosed method can also be implemented in other ways. The method embodiments described above are merely schematic, for example, the flowcharts and block diagrams in the accompanying drawings show the possible implementation architecture, functions and operations of the methods and computer program products according to multiple embodiments of the present application. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of a code, and the module, a program segment or a part of a code contains one or more executable instructions for implementing 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 consecutive boxes 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 and / or the flowchart, and the combination of boxes in the block diagram and / or the flowchart can be implemented with a dedicated hardware-based system that performs a specified function or action, or can be implemented with a combination of dedicated hardware and computer instructions.
[0133] In addition, the functional modules in the various embodiments of the present application may be integrated together to form an independent part, or each module may exist separately, or two or more modules may be integrated to form an independent part.
[0134] If the function is implemented in the form of a software function module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or the part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), a disk or an optical disk. It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply that there is any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprises" or any other variation thereof are intended to cover non-exclusive inclusion, so that a process, method, article or apparatus that includes a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, method, article or apparatus. In the absence of more restrictions, the elements defined by the sentence "includes..." do not exclude the presence of other identical elements in the process, method, article or apparatus that includes the elements.
[0135] The above description is only a preferred embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application shall be included in the protection scope of the present application. It should be noted that similar numbers and letters represent similar items in the following drawings, so once an item is defined in one drawing, it does not need to be further defined and explained in the subsequent drawings.
[0136] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A method for diagnosing program running status, characterized in that: include: Obtain diagnostic instructions from the user interface through a relay agent; The diagnostic instruction is forwarded to the diagnostic agent through the transfer agent; wherein the transfer agent and the diagnostic agent are Java Agent programs; By means of the diagnostic agent, diagnosing the instance in the target program based on the diagnostic instruction to obtain a diagnostic result; The diagnosis result is transmitted to the user interface through the relay agent.
2. The method according to claim 1, characterized in that The step of obtaining the diagnostic instruction of the user interface through the transfer agent includes: Communicate with the control plane through a transit agent to obtain a diagnostic instruction of the user interface from the control plane; wherein the control plane is used to monitor the user interface to obtain the diagnostic instruction in the user interface.
3. The method according to claim 2, characterized in that The method further comprises: The user interface establishes a connection with the control plane through the WebSocket protocol to transmit the diagnostic instruction to the control plane; Subscribe to the connection data information associated with the connection between the user interface and the control plane; wherein the connection data information is used to mark the application instance required to be diagnosed by the diagnosis agent and the communication channel used.
4. The method according to claim 2, characterized in that: The method further comprises: The transit agent establishes a connection with the control plane through a gRPC channel; Subscribe to process data information of a diagnostic process; wherein the process data information is used to mark a diagnostic command execution strategy of the diagnostic process.
5. The method according to claim 1, characterized in that The step of forwarding the diagnostic instruction to the diagnostic agent through the transit agent includes: The first native function is called through the transit agent, so as to send the diagnosis instruction to the diagnosis agent through the first native function.
6. The method according to claim 1, characterized in that Before transmitting the diagnosis result to the user interface through the relay agent, the method further includes: The second native function is called through the diagnosis agent to send the diagnosis result to the transit agent through the second native function.
7. The method according to claim 1, characterized in that Before forwarding the diagnostic instruction to the diagnostic agent through the transit agent, the method further includes: injecting the first application programming interface of the transit agent and the second application programming interface of the diagnostic agent into a startup class loader; The forwarding the diagnostic instruction to the diagnostic agent through the transit agent includes: forwarding the diagnostic instruction to the diagnostic agent through the transit agent based on the startup class loader.
8. An electronic device, characterized in that: include: A processor and a memory, wherein the memory stores machine-readable instructions executable by the processor, and when the electronic device is running, the machine-readable instructions are executed by the processor to perform the steps of the method according to any one of claims 1 to 7.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, which, when executed by a processor, executes the steps of the method according to any one of claims 1 to 7.
10. A computer program product, characterized in that The computer program product comprises a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.