In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
In this issue, the editor will bring you about how to use the Arthas online java process diagnosis tool. The article is rich in content and analyzes and describes for you from a professional point of view. I hope you can get something after reading this article.
`diagnoas` is an open source Java diagnostic tool provided by Alibaba, which is loved by developers.
When you are at a loss when you encounter similar problems like the following, `roomas` can help you solve the problem:
1. From which jar package was this class loaded? Why are all kinds of related Exception reported?
two。 Why didn't the code I changed be executed? Is it because I don't have commit? Is the branch wrong?
3. If you can't debug online if you encounter a problem, can you only republish it by adding a log?
4. Online encounter a user's data processing problems, but online also can not debug, offline can not be reproduced!
5. Is there a global perspective to view the health of the system?
6. Is there any way to monitor the real-time running status of JVM?
7. How to quickly locate the hot spots of the application and generate a flame map?
8. How can I find an instance of a class directly from within JVM?
`roomas` supports JDK 6slave and Linux/Mac/Windows, adopts command line interaction mode, and provides rich automatic completion features of `Tab` to further facilitate problem location and diagnosis.
Arthas (Alsace)
Arthas is Alibaba's open source Java diagnostic tool, which is loved by developers.
Official website document: https://arthas.aliyun.com/doc/
Arthas can help you solve problems like the following when you are at a loss as to what to do:
From which jar package was this class loaded? Why are all kinds of related Exception reported? Why didn't the code I changed be executed? Is it because I don't have commit? Is the branch wrong? If you can't debug online if you encounter a problem, can you only republish it by adding a log? Online encounter a user's data processing problems, but online also can not debug, offline can not be reproduced! Is there a global perspective to view the health of the system? Is there any way to monitor the real-time running status of JVM? How to quickly locate the hot spots of the application and generate a flame map? How can I find an instance of a class directly from within JVM?
Arthas supports JDK 6 layers, supports Linux/Mac/Windows, adopts command line interaction mode, and provides rich automatic completion functions of Tab, which further facilitates the location and diagnosis of problems.
Install Express installation 1.1.1 using arthas-boot (recommended)
Download arthas-boot.jar and start it with java-jar:
Curl-O https://arthas.aliyun.com/arthas-boot.jarjava-jar arthas-boot.jar
Print help information:
Java-jar arthas-boot.jar-h
If the download speed is slow, you can use the image of aliyun:
Java-jar arthas-boot.jar-repo-mirror aliyun-use-http
Install using as.sh
Arthas supports one-click installation on platforms such as Linux/Unix/Mac. Please copy the following, paste it into the command line, and press enter to execute it:
Curl-L https://arthas.aliyun.com/install.sh | sh
The above command downloads the startup script file as.sh to the current directory, and you can put it anywhere or add it to $PATH.
Execute. / as.sh directly under shell and you will enter the interactive interface.
You can also execute. / as.sh-h to get more parameter information.
Full installation (online environment has no access to public network)
# java-jar arthas-boot.jar
[INFO] arthas-boot version: 3.5.3
[INFO] Found existing java process, please choose one and input the serial number of the process, eg: 1. Then hit ENTER.
* [1]: 24438 org.elasticsearch.bootstrap.Elasticsearch
one
[ERROR] Can not read arthas version from: https://arthas.aliyun.com/api/latest_version
[ERROR] Can not find Arthas under local: / root/.arthas/lib and remote repo mirror: aliyun
[ERROR] Unable to download arthas from remote server, please download the full package according to wiki: https://github.com/alibaba/arthas
When using the online environment of quick installation to connect to Java services, it is very likely that Arthas cannot get jar packages such as arthas-core and cannot run because the online environment does not have external network access.
At this point, you need to install the Arthas package in full.
Installation method: (package size 13MB)
# get the arthas full package curl-Lo arthas-packaging-latest-bin.zip 'https://arthas.aliyun.com/download/latest_version?mirror=aliyun'unzip-d arthas-latest-bin arthas-packaging-latest-bin.zip#### and start running java-jar ahthas-boot.jar [INFO] arthas-boot version: 3.5.4 [INFO] Found existing java process, please choose one and input the serial number of the process Eg: 1. Then hit ENTER.* [1]: 27878 / data/tsf/tsf-oss/tsf-ratelimit/tsf-ratelimit-1.29.1/lib/tsf-ratelimit-1.29.1.jar1 [INFO] arthas home: / root [INFO] Try to attach process 27878 [INFO] Attach process 27878 success. [INFO] arthas-client connect 127.0.0.1 3658. . . ,. ,. ,. / O\ |. .--'|'|'-'| / O\'. -'|. | |'-. |. -. | |.. | `. `-. |\ |. -'| `- -'|`--'`--'wiki https://arthas.aliyun.com/doctutorials https://arthas .aliyun.com/doc/arthas-tutorials.htmlversion 3.5.4main_classpid 27878time 2021-09-07 19:31:47
Install via rpm/deb
See the official documentation for this section.
Getting started
Arthas needs to use the jps command, so make sure that the openjdk-devel package is installed.
Jps | | yum-y install java-1.8.0-openjdk-devel
Run arthas:
# java-jar arthas-boot.jar
[INFO] arthas-boot version: 3.5.3
[INFO] Process 5201 already using port 3658
[INFO] Process 5201 already using port 8563
[INFO] Found existing java process, please choose one and input the serial number of the process, eg: 1. Then hit ENTER.
* [1]: 5201 cloud-access-auth-1.18.1.jar
[2]: 14419 tsf-stack-base-1.0.0.jar
[3]: 27862 cloud-access-gateway-1.18.1.jar
[4]: 6550 tsfmanager-operation-1.29.1.jar
Tip 1: when the process list given by arthas cannot determine the process information, we can determine the java process number we want to view by typing jps-lmv on the command line to view the detailed java process information.
Tip 2: when prompted with the following information:
Arthas script version: 3.0.4
Calculating attach execution time...
Attaching to 24110 using version 3.0.4...
Start arthas failed, exception stack trace:
Java.lang.InternalError: instrument library is missing in target VM
At sun.tools.attach.HotSpotVirtualMachine.loadAgent (HotSpotVirtualMachine.java:105)
At com.taobao.arthas.core.Arthas.attachAgent (Arthas.java:84)
At com.taobao.arthas.core.Arthas. (Arthas.java:25)
At com.taobao.arthas.core.Arthas.main (Arthas.java:96)
Caused by: com.sun.tools.attach.AgentLoadException: Failed to load agent library
At sun.tools.attach.LinuxVirtualMachine.execute (LinuxVirtualMachine.java:224)
At sun.tools.attach.HotSpotVirtualMachine.loadAgentLibrary (HotSpotVirtualMachine.java:58)
At sun.tools.attach.HotSpotVirtualMachine.loadAgentLibrary (HotSpotVirtualMachine.java:79)
At sun.tools.attach.HotSpotVirtualMachine.loadAgent (HotSpotVirtualMachine.java:103)
... 3 more
Attach to target jvm (24110) failed, check / root/logs/arthas/arthas.log or stderr of target jvm for any exceptions.
We need to restart the process and then run arthas to connect to the background java process.
The following java process number is the java service that the current host is already running. Enter the number to enter the interactive interface of arthas.
[INFO] Found existing java process, please choose one and input the serial number of the process, eg: 1. Then hit ENTER.* [1]: 5201 cloud-access-auth-1.18.1.jar [2]: 14419 tsf-stack-base-1.0.0.jar [3]: 27862 cloud-access-gateway-1.18.1.jar [4]: 6550 tsfmanager-operation-1.29.1.jar1 [INFO] local lastest version: 3.5.3, remote lastest version: 3.5.4 Try to download from remote. [INFO] Start download arthas from remote server: https://arthas.aliyun.com/download/3.5.4?mirror=aliyun[INFO] Download arthas success. [INFO] arthas home: / root/.arthas/lib/3.5.4/arthas [INFO] The target process already listen port 3658, skip attach. [INFO] arthas-client connect 127.0.0.1 3658, -. . . ,. ,. ,. / O\ |. .--'|'|'-'| / O\'. -'|. | |'-. |. -. | |.. | `. `-. |\ |. -'| `- -'|`--'`--'wiki https://arthas.aliyun.com/doctutorials https://arthas .aliyun.com/doc/arthas-tutorials.htmlversion 3.5.3main_classpid 5201time 2021-09-03 09:55:42 [arthas@5201] $
When the above color bar ARTHAS character prompt appears, it indicates that you have connected to the specified Java process normally, and then go to the following arthas@PID command prompt.
Function usage
Dashboard instruction-Overview of JVM information
Typing dashboard enter at the arthas command prompt will display the information about the current process and press Q to exit.
Dashboard outputs the JVM information of the java process in real time, including thread, process, memory, stack, and current system runtime information.
[arthas@5201] $dashboard-h USAGE: dashboard [- h] [- I] [- n] SUMMARY: Overview of target jvm's thread, memory, gc, vm, tomcat info. EXAMPLES: dashboard dashboard-n 10 dashboard-I 2000 WIKI: https://arthas.aliyun.com/doc/dashboard OPTIONS:-h,-- help this help-I,-- interval The interval (in ms) between two executions, default is 5000 ms. -n,-- number-of-execution The number of times this command will be executed.help instruction
This directive is used to list all the subcommands supported by the arthas interactive interface.
[arthas@5201] $help NAME DESCRIPTION help Display Arthas Help auth Authenticates the current session keymap Display all the available keymap for the specified connection. Sc Search all the classes loaded by JVM sm Search the method of classes loaded by JVM classloader Show classloader info jad Decompile class getstatic Show the static field of a class monitor Monitor method execution statistics, e.g. Total/success/failure count, average rt, fail rate, etc. Stack Display the stack trace for the specified class and method thread Display thread info, thread stack trace Trace the execution time of specified method invocation. Watch Display the input/output parameter, return object, and thrown exception of specified method invocation tt Time Tunnel jvm Display the target JVM information perfcounter Display the perfcounter information. Ognl Execute ognl expression. Mc Memory compiler, compiles java files into bytecode and class files in memory. Redefine Redefine classes. @ see Instrumentation#redefineClasses (ClassDefinition...) Retransform Retransform classes. @ see Instrumentation#retransformClasses (Class...) Dashboard Overview of target jvm's thread, memory, gc, vm, tomcat info. Dump Dump class byte array from JVM heapdump Heap dump options View and change various Arthas options cls Clear the screen reset Reset all the enhanced classes version Display Arthas version session Display current session information sysprop Display, and change the system properties. Sysenv Display the system env. Vmoption Display, and update the vm diagnostic options. Logger Print logger info, and update the logger level history Display command history cat Concatenate and print files base64 Encode and decode using Base64 representation echo write arguments to the standard output pwd Return working directory name mbean Display the mbean information grep grep command for pipes. Tee tee command for pipes. Profiler Async Profiler. Https://github.com/jvm-profiling-tools/async-profiler vmtool jvm tool stop Stop/Shutdown Arthas server and exit the console.
For each subcommand, you can follow-h for further help usage information.
Thread instruction [arthas@5201] $thread-h USAGE: thread [--all] [- h] [- b] [--lockedMonitors] [--lockedSynchronizers] [- I] [--state] [- n] [id] SUMMARY: Display thread info Thread stack EXAMPLES: thread thread 51 thread-n-1 thread-n 5 thread-b thread-I 2000 thread-- state BLOCKED WIKI: https://arthas.aliyun.com/doc/thread OPTIONS:-- all Display all thread results instead of the first page-h -- help this help-b,-- include-blocking-thread Find the thread who is holding a lock that blocks the most number of threads. -- lockedMonitors Find the thread info with lockedMonitors flag, default value is false. -- lockedSynchronizers Find the thread info with lockedSynchronizers flag, default value is false. -I,-sample-interval Specify the sampling interval (in ms) when calculating cpu usage. -- state Display the thead filter by the state. NEW, RUNNABLE, TIMED_WAITING, WAITING, BLOCKED, TERMINATED is optional. -n,-- top-n-threads The number of thread (s) to show, ordered by cpu utilization,-1 to show all. Show thread stack$ thread-I 5000 threads # get computed summary data with a time span of 5s $thread-n 3 threads # sort according to CPU usage, get stack information of 3 threads from high to low $thread-baked # View only stack information of deadlock threads $thread-lockedSynchronizers## only view synchronizer deadlock thread stack information stop / exit stop and leave
Stop: stop and exit Arthas consol, and exit the steps normally.
Exit: only leaves the Arthas consol, but the arthas task bound to the Java process does not exit.
[SHELL] # java-jar arthas-boot.jar [INFO] arthas-boot version: 3.5.3 [INFO] Found existing java process, please choose one and input the serial number of the process Eg: 1. Then hit ENTER.* [1]: 5201 cloud-access-auth-1.18.1.jar [2]: 14419 tsf-stack-base-1.0.0.jar [3]: 27862 cloud-access-gateway-1.18.1.jar [4]: 6550 tsfmanager-operation-1.29.1.jar1 [INFO] arthas home: / root/.arthas/lib/3.5.4/arthas [INFO] Try to attach process 5201 [INFO] Attach process 5201 success . [INFO] arthas-client connect 127.0.0.1 3658 -. . . ,. ,. ,. / O\ |. .--'|'|'-'| / O\'. -'|. | |'-. |. -. | |.. | `. `-. |\ |. -'|. -'| `-'`--'`- -'- -'`--'--'wiki https://arthas.aliyun.com/doctutorials https://arthas.aliyun.com/doc/arthas-tutorials.htmlversion 3.5.4main_classpid 5201time 2021 -09-03 13:05:51 [arthas@5201] $exit [SHELL] # java-jar arthas-boot.jar [INFO] arthas-boot version: 3.5.3 [INFO] Process 5201 already using port 3658 # # because there was no shutdown to close the binding of arthas to the java process last time So when Arthas restarts, it detects that it is still bound to the 5201 process. [INFO] Process 5201 already using port 8563 [INFO] Found existing java process, please choose one and input the serial number of the process, eg: 1. Then hit ENTER.* [1]: 5201 cloud-access-auth-1.18.1.jar [2]: 14419 tsf-stack-base-1.0.0.jar [3]: 27862 cloud-access-gateway-1.18.1.jar [4]: 6550 tsfmanager-operation-1.29.1.jar
We proved this through jstack-l 5201.
[root@VM-0-4-centos ~] # jstack-l 5201 | more2021-09-03 13:08:16Full thread dump OpenJDK 64-Bit Server VM (25.302-b08 mixed mode): "arthas-NettyHttpTelnetBootstrap-3-3" # 169 daemon prio=5 os_prio=0 tid=0x00007f314000b800 nid=0x5632 runnable [0x00007f30cb51a000] java.lang.Thread.State: RUNNABLE at sun.nio.ch.EPollArrayWrapper.epollWait (Native Method) at sun.nio.ch.EPollArrayWrapper.poll (EPollArrayWrapper.java:269) At sun.nio.ch.EPollSelectorImpl.doSelect (EPollSelectorImpl.java:93) at sun.nio.ch.SelectorImpl.lockAndDoSelect (SelectorImpl.java:86)-locked (a com.alibaba.arthas.deps.io.netty.channel.nio.SelectedSelectionKeySet)-locked (a java.util.Collections$UnmodifiableSet)-locked (a sun.nio.ch.EPollSelectorImpl) at sun.nio.ch.SelectorImpl.select (SelectorImpl.java:97) At sun.nio.ch.SelectorImpl.select (SelectorImpl.java:101) at com.alibaba.arthas.deps.io.netty.channel.nio.SelectedSelectionKeySetSelector.select (SelectedSelectionKeySetSelector.java:68) at com.alibaba.arthas.deps.io.netty.channel.nio.NioEventLoop.select (NioEventLoop.java:810) at com.alibaba.arthas.deps.io.netty.channel.nio.NioEventLoop.run (NioEventLoop.java:457) at com. Alibaba.arthas.deps.io.netty.util.concurrent.SingleThreadEventExecutor$4.run (SingleThreadEventExecutor.java:989) at com.alibaba.arthas.deps.io.netty.util.internal.ThreadExecutorMap$2.run (ThreadExecutorMap.java:74) at com.alibaba.arthas.deps.io.netty.util.concurrent.FastThreadLocalRunnable.run (FastThreadLocalRunnable.java:30) at java.lang.Thread.run (Thread.java:748) Locked ownable synchronizers:-None "arthas-NettyHttpTelnetBootstrap -3-2 "# 168 daemon prio=5 os_prio=0 tid=0x00007f314000a000 nid=0x51ce runnable [0x00007f30d09f9000] java.lang.Thread.State: RUNNABLE at sun.nio.ch.EPollArrayWrapper.epollWait (Native Method) at sun.nio.ch.EPollArrayWrapper.poll (EPollArrayWrapper.java:269) at sun.nio.ch.EPollSelectorImpl.doSelect (EPollSelectorImpl.java:93) at sun.nio.ch.SelectorImpl.lockAndDoSelect (SelectorImpl.java:86)-locked (a com. Alibaba.arthas.deps.io.netty.channel.nio.SelectedSelectionKeySet)-locked (a java.util.Collections$UnmodifiableSet)-locked (a sun.nio.ch.EPollSelectorImpl) at sun.nio.ch.SelectorImpl.select (SelectorImpl.java:97) at sun.nio.ch.SelectorImpl.select (SelectorImpl.java:101) at com.alibaba.arthas.deps.io.netty.channel.nio.SelectedSelectionKeySetSelector.select (SelectedSelectionKeySetSelector.java:68)
We can see the java stack information for 5201 processes, and the thread with arthas is running.
Normal exit steps:
[arthas@5201] $stopResetting all enhanced classes... Affect (class count: 0, method count: 0) cost in 0 ms ListenerId: 0Arthas Server is going to shutdown... [arthas@5201] $session (f0151617-7fd2-4b4b-b79f-31d366a72fc5) is closed because server is going to shutdown. [SHELL] # jstack-l 5201 | more2021-09-03 13:10:16Full thread dump OpenJDK 64-Bit Server VM (25.302-b08 mixed mode): "Abandoned connection cleanup thread" # 51 daemon prio=5 os_prio=0 tid=0x00007f30e0246000 nid=0x1d86 in Object.wait () [0x00007f3120393000] java.lang.Thread.State: TIMED_WAITING (on object monitor) At java.lang.Object.wait (Native Method) at java.lang.ref.ReferenceQueue.remove (ReferenceQueue.java:144)-locked (a java.lang.ref.ReferenceQueue$Lock) at com.mysql.jdbc.AbandonedConnectionCleanupThread.run (AbandonedConnectionCleanupThread.java:64) at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:624) at Java.lang.Thread.run (Thread.java:748) Locked ownable synchronizers:-(a java.util.concurrent.ThreadPoolExecutor$Worker) "Tomcat JDBC Pool Cleaner [1450495309 java.util.concurrent.ThreadPoolExecutor$Worker 1630634377161]" # 50 daemon prio=5 os_prio=0 tid=0x00007f30e01e4800 nid=0x1d85 in Object.wait () [0x00007f3120494000] java.lang.Thread.State: TIMED_WAITING (on object monitor) at java.lang.Object.wait (Native Method) at java.util.TimerThread.mainLoop (Timer.java:552) -locked (a java.util.TaskQueue) at java.util.TimerThread.run (Timer.java:505) Locked ownable synchronizers:-None
You can see that after closing the arthas diagnostics using the stop directive, the Arthas thread binding on the java process also exits.
Watch instruction ⭐-- method performs data observation
Watch instruction is one of the most commonly used instructions in Arthas, it can get the specified package. Class. The input parameter of the method, the internal object of the self-class method body, and the value of the returned object.
[arthas@5201] $watch-h USAGE: watch [- b] [- e] [--exclude-class-pattern] [- x] [- f] [- h] [- n] [--listenerId] [- E] [- M] [- s] [- v] class-pattern method-pattern [express] [condition-express] SUMMARY: Display the input/output parameter, return object And thrown exception of specified method invocation The express may be one of the following _ expression (evaluated dynamically): target: the object clazz: the object's class method: the constructor or method params: the parameters array of method params [0.n]: the element of parameters array returnObj: the returned object of method throwExp: the throw exception of method isReturn: the method ended by return isThrow : the method ended by throwing exception # cost: the execution time in ms of method invocation Examples: watch org.apache.commons.lang.StringUtils isBlank watch org.apache.commons.lang.StringUtils isBlank'{params Target, returnObj ThrowExp}'- x 2 watch * StringUtils isBlank params [0] params [0] .length = = 1 watch * StringUtils isBlank params'# cost > 100' watch-f * StringUtils isBlank params watch * StringUtils isBlank params [0] watch-E-b org\ .Apache\ .Commons\ .lang\ .StringUtils isBlank params [0] watch javax.servlet.Filter *-- exclude-class-pattern com.demo.TestFilter WIKI: https://arthas.aliyun.com/doc/watch OPTIONS:-b -- before Watch before invocation-e,-- exception Watch after throw exception-- exclude-class-pattern exclude class name pattern, use either'. Or'/'as separator-x,-- expand Expand level of object (1 by default)-f,-- finish Watch after invocation, enable by default-h,-- help this help-n Limits Threshold of execution times-- listenerId The special listenerId-E,-- regex Enable regular expression to match (wildcard matching by default)-M -sizeLimit Upper size limit in bytes for the result (10 * 1024 * 1024 by default)-s,-- success Watch after successful invocation-v,-- verbose Enables print verbose information, default value false. The full qualified class name you want to watch The method name you want to watch The content you want to watch, written by ognl. Default value is'{params, target ReturnObj} 'Examples: params params [0] 'params [0] + params [1]' {params [0] Target ReturnObj} 'returnObj throwExp target Clazz method Conditional expression in ognl style For example: TRUE: 1 TRUE: true FALSE : false TRUE: 'params.length > = 0' FALSE: 1 collect 2'# cost > 100'
Parameter description
Parameter name parameter description class-pattern class name expression matches method-pattern method name expression matches express observation expression, default value: {params, target, returnObj} condition-express conditional expression [b] observe [e] before method call, observe [s] after method exception, observe [f] after method return, observe [E] turn on regular expression matching after method end (normal return and exception return) The default is wildcard match [x:], which specifies the attribute traversal depth of the output, and defaults to 1.
The key point here is the observation expression, which is mainly composed of # OGNL expressions, so you can write "{params,returnObj}" like this, as long as it is a legal ognl expression, it can be supported normally.
There are also many dimensions of observation, mainly reflected in the data structure of the parameter advice. The Advice parameter encapsulates all the information of the notification node. Refer to the description of this node in the core variable of the expression.
Examples of use:
I need to observe the login method information of the cloud-access-auth-1.18.1.jar process when processing login information. The log is as follows:
13 Access Auth 42 INFO [http-nio-7001-exec-4] c.t.c.access.sso.service.impl.AuthenticateService-[Access Auth] account login parameter. AccountName:qcloudAdmin, password:*
Get the specified class name as AuthenticateService.
We take it to Arthas for watch:
# Registration is abbreviated in the log file, so I use wildcards to match the class name here. I also use * to replace the second parameter method name, all of which match [arthas@5201] $watch * AuthenticateService * Press Q or Ctrl+C to abort.Affect (class count: 2, method count: 6) cost in 130class, listenerId: 16 classes # know from the output information that there are two classes matched in all the code of this Java process, a total of six methods
Let's click the login button on the page to see what actions can be observed in watch:
[arthas@5201] $watch * AuthenticateService * Press Q or Ctrl+C to abort.Affect (class count: 2, method count: 6) cost in 130 ms, listenerId: 16 # the first method starts to execute Beginmethod=com.tencent.cloud.access.sso.service.impl.AuthenticateService.login location=AtExitts=2021-09-03 13 AuthenticateService 51 result=@ArrayList 25; [cost=2.217281ms] result=@ArrayList [@ Object [] [isEmpty=false Size=3], @ authenticateService [com.tencent.cloud.access.sso.service.impl.authenticateService @ f5cadbf], @ AccessAuthPrincipal [com.tencent.cloud.access.sso.model.AccessAuthPrincipal @ 72f71bf6],] # the first method ends End # the second method starts to execute Beginmethod=com.tencent.cloud.access.sso.service.impl.AuthenticateService.updateSession location=AtExitts=2021-09-03 131End 25; [AccessAuthPrincipal] [@ Object [] [AccessAuthPrincipal] [AccessAuthPrincipal] Size=2], @ authenticateService [com.tencent.cloud.access.sso.service.impl.authenticateService @ f5cadbf], @ authenticationResponse [com.tencent.cloud.access.sso.model.authenticationResponse @ 6b2bae10],] # the second method executes to exit End.
In the output, we can see that the first line has the complete method path and the location of the exit status obtained.
AtExit: indicates a normal exit.
AtExceptionExit: indicates an abnormal exit.
The second line has the start timestamp of the method execution and the cost cost, and the last one is the result of watch.
Here result's ArrayList array is the power of the watch instruction, which contains three objects by default:
Params: input parameter, usually an array, in this case @ Object object
Target: the current running this object, which is the class object itself, here is the @ AuthenticateService entity class object
ReturnObj: returns the object value, in this case the returned @ AccessAuthPrincipal object
Let's re-execute the watch instruction, this time we specify exactly the class name and method name, and add a-x parsing depth parameter:
[arthas@5201] $watch com.tencent.cloud.access.sso.service.impl.AuthenticateService login-x 2Press Q or Ctrl+C to abort.Affect (class count: 1, method count: 2) cost in 74 ms, listenerId: 17method=com.tencent.cloud.access.sso.service.impl.AuthenticateService.login location=AtExitts=2021-09-03 14:10:15 [cost=3.289679ms] result=@ArrayList [@ Object [] [@ string [qcloudAdmin], @ string [Bgi8c0yC + IAvRLkuQRy6kLQ6T2J/9PNrL6G/+KX9ppE=], @ string [127.0.0.1],], @ AuthenticateService [log=@ [com.tencent.cloud.access.sso.service.impl.authenticateService]], sessionDAO=@RedisSessionDAO [com.tencent.cloud.access.sso.shiro.RedisSessionDAO@61813e98] AccountSessionService=@AccountSessionService [com.tencent.cloud.access.account.service.impl.AccountSessionService@30e815ac], accessAuthRealm=@AccessAuthRealm [com.tencent.cloud.access.sso.shiro.AccessAuthRealm@1faea5], accountService=@AccountService [com.tencent.cloud.access.account.service.impl.AccountService@197459d8], ssoProperties=@SsoProperties [com.tencent.cloud.access.sso.config.SsoProperties@461879b2], securityManager=@DefaultSecurityManager [org.apache.shiro.mgt.DefaultSecurityManager@3b0f92f0] SsoService=@QCloudSsoService [com.tencent.cloud.access.sso.service.impl.QCloudSsoService@4f8704f5], userService=@UserService [com.tencent.cloud.access.user.service.impl.UserService@5e69da74],], @ AccessAuthPrincipal [serialVersionUID=@Long [- 2856270666386831504], accountName=@String [qcloudAdmin], userId=null, accountId=@String [account-96a79v5b], password=@String [VYUQeJrC5EJq21t/f9rb1Djm+4+eanqXY3ZkW2oiiwA=], serviceCode=null, isAdmin=null LoginName=null, serialVersionUID=@Long [8229738167949958388], token=@String [54158a08d8104de57a855249eb6ffe06], serialVersionUID=@Long [- 4556824360581761962], appId=null, subAccountUin=null, uin=null, requestId=null, region=null, kv=null,],] method=com.tencent.cloud.access.sso.service.impl.AuthenticateService.login location=AtExitts=2021-09-03 14:10:15 [cost=9.571541ms] result=@ArrayList [@ Object [] [@ sessionDAO=@RedisSessionDAO [com.tencent.cloud.access.sso.model.LoginRequest @ 3dd2bbb0],], @ AuthenticateService [Logger [com.tencent.cloud.access.sso.service.impl.authenticateService], sessionDAO=@RedisSessionDAO [com.tencent.cloud.access.sso.shiro.RedisSessionDAO@61813e98], LoginRequest [com.tencent.cloud.access.account.service.impl.AccountSessionService@30e815ac] AccessAuthRealm=@AccessAuthRealm [com.tencent.cloud.access.sso.shiro.AccessAuthRealm@1faea5], accountService=@AccountService [com.tencent.cloud.access.account.service.impl.AccountService@197459d8], ssoProperties=@SsoProperties [com.tencent.cloud.access.sso.config.SsoProperties@461879b2], securityManager=@DefaultSecurityManager [org.apache.shiro.mgt.DefaultSecurityManager@3b0f92f0], ssoService=@QCloudSsoService [com.tencent.cloud.access.sso.service.impl.QCloudSsoService@4f8704f5] UserService=@UserService [com.tencent.cloud.access.user.service.impl.UserService@5e69da74],], @ AuthenticationResponse [serialVersionUID=@Long [- 6134589862066278677], token=@String [54158a08d8104de57a855249eb6ffe06], accountId=@String [account-96a79v5b], changePwd=@String [N], users=@ArrayList [isEmpty=false] Size=1],],].
The-x option of the watch instruction indicates the depth of the object in the three stages of parsing, with a default value of 1, that is, only parsing to the object layer, not parsing the object's next-level attributes and other information.
Through the above instruction, we have obtained more detailed information about the input parameter, this object and return value, which are parsed as follows:
Input parameters of params method:
@ string [qcloudAdmin]: parameter 1, user name
@ string [Bgi8c0yC + IAvRLkuQRy6kLQ6T2J/9PNrL6G/+KX9ppE=]: password encrypted string
@ string [127.0.0.1]: source host information
This method body internal object:
Log=@Logger: defining Logger object
SessionDAO=@RedisSessionDAO: session session data entry, which is a RedisSessionDAO object
AccountSessionService=@AccountSessionService: private object.
ReturnObj returns a value object, in this case @ AccessAuthPrincipal object:
SerialVersionUID: user
UIDaccountName: login user name
Password: user password encryption string token: token string
.
Conditional expression filtering
[arthas@5201] $watch com.tencent.cloud.access.sso.service.impl.AuthenticateService login'{params [0] = qcloudAdmin,returnObj}'- x 2
The diagnostic return information contains params [0] and returnObj objects, and only gets the method call of the input parameter params [0] = = "qcloudAdmin", and the final parsing depth is 2.
Only calls that meet the conditions are captured by Arthas.
Observe abnormal information
[arthas@5201] $watch com.tencent.cloud.access.sso.service.impl.AuthenticateService login'{params [0], throwExp}'- e-x 2
-e: indicates that you observe after an exception is thrown
The second parameter of the express observation expression is throwExp: the variable that represents the exception information is throwExp
It takes time to filter by method
[arthas@5201] $watch com.tencent.cloud.access.sso.service.impl.AuthenticateService login'{params [0], returnObj}'# cost > 200'-x 2
The fourth parameter of the watch instruction, condition-express, is # cost > 200, which means that the diagnostic processing takes longer than 200ms before the output is captured.
-x 2: the resolution depth is 2.
Observe only the properties of the current object
[arthas@5201] $watch com.tencent.cloud.access.sso.service.impl.AuthenticateService login 'target'-x 3Press Q or Ctrl+C to abort.Affect (class count: 1, method count: 2) cost in 76 ms, listenerId: 23method=com.tencent.cloud.access.sso.service.impl.AuthenticateService.login location=AtExitts=2021-09-03 14:48:33 [cost=3.189525ms] result=@AuthenticateService [log=@Logger [serialVersionUID=@Long [5454405123156820674], FQCN=@String [ch.qos.logback.classic.Logger], name=@String [com.tencent.cloud.access.sso.service.impl.AuthenticateService], level=null, effectiveLevelInt=@Integer [20000], parent=@Logger [serialVersionUID=@Long [5454405123156820674], FQCN=@String [ch.qos.logback.classic.Logger] Name=@String [com.tencent.cloud.access.sso.service.impl], level=null, effectiveLevelInt=@Integer [20000], parent=@ Logger[Logger[com.tencent.cloud.access.sso.service]], childrenList=@CopyOnWriteArrayList [isEmpty=false Size=2], aai=null, additive=@Boolean [true], loggerContext=@ LoggerContext[ch.qos.logback.classic.LoggerContext[default]],], childrenList=null, aai=null, additive=@Boolean [true], loggerContext=@LoggerContext [DEFAULT_PACKAGING_DATA=@Boolean [false], root=@ Logger[Logger[ROOT]], size=@Integer [501] NoAppenderWarning=@Integer [0], loggerContextListenerList=@ArrayList [isEmpty=false Size=1], loggerCache=@ConcurrentHashMap [isEmpty=false;size=501], loggerContextRemoteView=@LoggerContextVO [LoggerContextVO {name='default', propertyMap= {}, birthTime=1630634095948}], turboFilterList=@TurboFilterList [isEmpty=true;size=0], packagingDataEnabled=@Boolean [false], maxCallerDataDepth=@Integer [8], resetCount=@Integer [2], frameworkPackages=@ArrayList [isEmpty=true Size=0], birthTime=@Long [1630634095948], name=@String [default], sm=@BasicStatusManager [ch.qos.logback.core.BasicStatusManager@612c57fb], propertyMap=@HashMap [isEmpty=true;size=0], objectMap=@HashMap [isEmpty=false;size=6], configurationLock=@LogbackLock [ch.qos.logback.core.spi.LogbackLock@36566db5], scheduledExecutorService=null, scheduledFutures=@ArrayList [isEmpty=true Size=0], lifeCycleManager=@LifeCycleManager [ch.qos.logback.core.LifeCycleManager@44477e6], started=@Boolean [false], sessionDAO=@RedisSessionDAO [.
By expanding our thinking, we can observe the information of the underlying connection jdbc directly through a single call:
[arthas@5201] $watch com.tencent.cloud.access.sso.service.impl.AuthenticateService login 'target.userService.userDao.jdbcTemplate.dataSource.pool.poolProperties.url'-x 2
Press Q or Ctrl+C to abort.
Affect (class count: 1, method count: 2) cost in 69 ms, listenerId: 34
Method=com.tencent.cloud.access.sso.service.impl.AuthenticateService.login location=AtExit
Ts=2021-09-03 15 result=@ 0955; [cost=2.682966ms] result=@ string [JDBC: mysql://*.*:3306/access_auth?useSSL=false&characterEncoding=utf8]
Method=com.tencent.cloud.access.sso.service.impl.AuthenticateService.login location=AtExit
Ts=2021-09-03 15 result=@ 0955; [cost=21.373065ms] result=@ string [JDBC: mysql://*.*:3306/access_auth?useSSL=false&characterEncoding=utf8]
Here, from the top level down, the call is obtained, which involves the jdbc dataSource connection configuration information of the query library.
Result returns an object of type String with a value of jdbc:mysql://*.*:3306/access_auth?useSSL=false&characterEncoding=utf8.
Exclude specified classes
[arthas@5201] $watch com.tencent.cloud.access.sso.service.impl.* * 'target'-x 1-- exclude-class-pattern AuthorizeService | grep-- color AuthorizeServicePress Q or Ctrl+C to abort.
-- exclude-class-pattern: excludes specified classes
Trace instruction ⭐
Method internal call path and output time on each node on the method path
The trace command can actively search the method call path corresponding to class-pattern/method-pattern, render and count all the performance overhead on the entire call link and track the call link.
Parameter description
Parameter name parameter description class-pattern class name expression matching method-pattern method name expression matching condition-express conditional expression [E] turn on regular expression matching, default is wildcard matching [n:] command execution times # cost method execution time
The key point here is the observation expression, which is mainly composed of # OGNL expressions, so you can write "{params,returnObj}" like this, as long as it is a legal ognl expression, it can be supported normally.
There are also many dimensions of observation, mainly reflected in the data structure of the parameter advice. The Advice parameter encapsulates all the information of the notification node.
Refer to the description of this node in the core variable of the expression.
For special usage, please refer to: https://github.com/alibaba/arthas/issues/71
OGNL expression official website: https://commons.apache.org/proper/commons-ognl/language-guide.html
In many cases, we only want to see the rt of a method greater than the trace result after a certain time. Now Arthas can filter by the time it takes to execute the method. For example, trace * StringUtils isBlank'# cost > 100' means that the trace result will be output only when the execution time exceeds 100ms.
All three commands of watch/stack/trace support # cost
Examples of use:
[arthas@5201] $trace com.tencent.cloud.access.sso.service.impl.AuthenticateService loginPress Q or Ctrl+C to abort.Affect (class count: 1, method count: 2) cost in TCCL=org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedWebappClassLoader@1cfd053 `- [6.69059ms] com.tencent.cloud.access.sso.service.impl.AuthenticateService:login () +-[0.045058ms] com.tencent.cloud.access.sso.model.LoginRequest:getOpt () # 87 +-[0.011503ms] com.tencent.cloud.access.sso.constant.LoginType:getType () # 88 +-- [0.004858ms ] com.tencent.cloud.access.sso.constant.LoginType:getType () # 89 +-- [0.005082ms] com.tencent.cloud.access.sso.model.LoginRequest:getAccountName () # 93 +-- [0.005074ms] com.tencent.cloud.access.sso.model.LoginRequest:getPassword () # 94 +-- [min=0.002257ms Max=0.010395ms,total=0.012652ms Count=2] org.springframework.util.StringUtils:isEmpty () # 95 +-- [0.008128ms] com.tencent.cloud.access.sso.config.SsoProperties:isPasswordTextPrintable () # 100 +-- [0.084201ms] org.slf4j.Logger:info () # 99 +-- [0.00653ms] com.tencent.cloud.access.sso.model.AuthenticationResponse: () # 101 +-- [0.004871ms] com.tencent.cloud .access.sso.model.LoginRequest: getRemoteHost () # 102 +-- [3.317607ms] com.tencent.cloud.access.sso.service.impl.AuthenticateService:login () # 102 | `--[3.285177ms] com.tencent.cloud.access.sso.service.impl.AuthenticateService:login () | +-- [0.008045ms] org.apache.shiro.authc.UsernamePasswordToken: () # 139 | +-- [0.011232ms] org.apache.shiro.subject.SimplePrincipalCollection: () # 141 | +-- [0.00843ms] org.apache.shiro.subject.support.DelegatingSubject: () # 142 | +-- [0.015667ms] org.apache.shiro.util.ThreadContext:bind () # 143| +-- [1.051658ms] org.apache.shiro.subject.support.DelegatingSubject:login ( ) # 144 | +-- [0.988623ms] org.apache.shiro.subject.support.DelegatingSubject:getSession () # 145 | +-- [0.015629ms] org.apache.shiro.session.Session:getId () # 146 | +-- [0.323618ms] org.apache.shiro.subject.support.DelegatingSubject:getPrincipal () # 147 | +-- [0.009258ms] Com.tencent.cloud.access.sso.model.AccessAuthPrincipal:setToken () # 149 | +-- [0.007608ms] com.tencent.cloud.access.sso.model.AccessAuthPrincipal:setAccountName () # 150 | +-- [0.429798ms] org.apache.shiro.session.Session:setAttribute () # 151 | `- [0.207347ms] com.tencent.cloud.access.account.service.IAccountSessionService:bind ( ) # 152 +-- [0.010654ms] com.tencent.cloud.access.account.Account: () # 103 +-- [0.824315ms] com.tencent.cloud.access.account.service.IAccountService:find () # 103 +-- [0.006474ms] com.tencent.cloud.access.account.Account:getLock () # 104 +-- [0.004144ms] com.tencent.cloud.access.account.Account:getChangePassword () # 107 +-- [0.005663ms] com.tencent.cloud.access.sso.model.AuthenticationResponse:setChangePwd () # 107 +-- [0.004683ms] com.tencent.cloud.access.sso.model.AccessAuthPrincipal:getToken () # 108 +-- [0.00414ms] com.tencent.cloud.access.sso.model.AuthenticationResponse:setToken () # 108 +-- [0.003733ms] com.tencent.cloud.access .account.account: getAccountId () # 109 +-[0.005164ms] com.tencent.cloud.access.sso.model.AuthenticationResponse:setAccountId () # 109 +-- [0.002866ms] com.tencent.cloud.access.sso.model.AccessAuthPrincipal:setAccountName () # 110 +-- [0.00399ms] com.tencent.cloud.access.sso.model.AccessAuthPrincipal:getAccountId () # 112 +-- [0.014922ms] com .tencent.cloud.access.user.User: () # 112 +-- [0.004781ms] com.tencent.cloud.access.user.User:setAppIsolate () # 113 +-- [0.83272ms] com.tencent.cloud.access.user.service.IUserService:findAccountList () # 114 +-- [0.006398ms] com.tencent.cloud.access.user.User:getUserId () # 116 +-- [0.005214ms] Com.tencent.cloud.access.sso.model.AccessAuthPrincipal:setUserId () # 116 +-- [0.00349ms] com.tencent.cloud.access.sso.model.AccessAuthPrincipal:getToken () # 118 +-- [0.002987ms] com.tencent.cloud.access.user.User:getUserId () # 118 +-- [0.887095ms] com.tencent.cloud.access.sso.service.impl.AuthenticateService:updateSession () # 118` -[0.004734ms] com.tencent.cloud.access.sso.model.AuthenticationResponse:setUsers () # 120`-ts=2021-09-03 15:37:52 Thread_name=http-nio-7001-exec-1;id=14;is_daemon=true;priority=5 TCCL=org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedWebappClassLoader@1cfd053 `- [1.28437ms] com.tencent.cloud.access.sso.service.impl.AuthenticateService:login () +-[0.003596ms] com.tencent.cloud.access.sso.model.LoginRequest:getOpt () # 87 +-[0.006076ms] com.tencent.cloud.access.sso.constant.LoginType:getType () # 88 +-- [0.002865ms ] com.tencent.cloud.access.sso.constant.LoginType:getType () # 89 +-[0.010558ms] com.tencent.cloud.access.sso.model.LoginRequest:getAccessToken () # 123 +-- [0.003959ms] com.tencent.cloud.access.sso.model.LoginRequest:getUid () # 124 +-- [0.003368ms] org.springframework.util.StringUtils:isEmpty () # 125 +-- [0 .002671ms] org.springframework.util.StringUtils:isEmpty () # 128`-[1.166953ms] com.tencent.cloud.access.sso.service.impl.AuthenticateService:updateSession () # 131
Time-consuming filtering diagnosis
[arthas@5201] $trace com.tencent.cloud.access.sso.service.impl.AuthenticateService login'# cost > 2000'
# cost > 2000: only capture paths whose overhead time is greater than 2000ms.
Filter method is called only once
[arthas@5201] $trace com.tencent.cloud.access.sso.service.impl.AuthenticateService login-n 1
Capture only one call to the specified method, and then exit the task.
Sysprop directive-- get / set process system properties
Sysprop is mainly used to view and set the system property information of the current process.
Use examples
View the system properties of the current java process
[arthas@27878] $sysprop KEY VALUE---- awt.toolkit Sun.awt.X11.XToolkit file.encoding.pkg sun.io java.specification.version 1.8 sun.cpu.isalist sun.jnu.encoding UTF-8 java.class.path / data/tsf/tsf-oss/tsf-ratelimit/tsf-ratelimit-1.29.1/lib/tsf-ratelimit-1.29.1.jar java.vm.vendor Tencent sun.arch.data.model 64 java.vendor.url http://jdk.oa.com/ Catalina.useNaming false user.timezone Asia/Shanghai org.jboss.logging.provider slf4j os.name Linux java.vm.specification.version 1.8 @ appId Tsf-ratelimit user.country US sun.java.launcher SUN_STANDARD sun.boot.library.path / data/TencentKona-8.0.2-252/jre/lib/amd64 sun.java. Command / data/tsf/tsf-oss/tsf-ratelimit/tsf-ratelimit-1.29.1/lib/tsf-ratelimit-1.29.1.jar sun.cpu.endian little user.home / root user.language En java.specification.vendor Oracle Corporation java.home / data/TencentKona-8.0.2-252/jre file.separator / line.separator java.vm.specification.vendor Oracle Corporation Java.specification.name Java Platform API Specification java.awt.graphicsenv sun.awt.X11GraphicsEnvironment java.awt.headless true LOG_LEVEL_PATTERN 5p [bootstrap % X {XmurB3Mutual TraceIdVAND -},% X {XMYB3murSpanIdVAND -} Sun.boot.class.path / data/TencentKona-8.0.2-252/jre/lib/resources.jar:/data/TencentKona-8.0.2-252/jre/lib/rt.jar:/data/TencentKona-8.0.2-252/jre/lib/sunrsasign.jar:/data/TencentKona-8.0.2-252/jre/lib/jsse.jar: / data/TencentKona-8.0.2-252/jre/lib/ jce.jar:/data/TencentKona-8.0.2-252/jre/lib/charsets.jar:/data/TencentKona-8.0.2-252/jre/lib/jfr.jar:/data/TencentKona-8.0.2-252/jre/classes java.protocol.handler.pkgs Org.springframework.boot.loader sun.management.compiler HotSpot 64-Bit Tiered Compilers java.runtime.version 1.8.0_252-b1 java.net.preferIPv4Stack true user.name root path.separator : os.version 3.10.0-1127.19.1.el7.x86_64 java.endorsed.dirs / data/TencentKona-8.0.2-252/jre/lib/endorsed java.runtime.name OpenJDK Runtime Environment file.encoding UTF-8 spring.beaninfo.ignore true sun.nio.ch.bugLevel java.vm.name OpenJDK 64-Bit Server VM LOG_FILE / Var/log/tsf-oss/tsf-ratelimit/tsf-ratelimit java.vendor.url.bug http://ce.oa.com/bia java.io.tmpdir / tmp catalina.home / tmp/tomcat.8220305148167761737.23000 java.version 1.8.0_252 user.dir / data/tsf/tsf-oss/tsf-ratelimit/tsf-ratelimit-1.29.1 os.arch amd64 PID 27878 Java.vm.specification.name Java Virtual Machine Specification java.awt.printerjob sun.print.PSPrinterJob sun.os.patch.level unknown catalina.base / tmp/tomcat.8220305148167761737.23000 loader.path / data/tsf/tsf-oss/tsf-ratelimit/tsf-ratelimit-1.29.1/config java.library.path / data/tsf/tsf-oss/tsf-ratelimit/tsf-ratelimit-1.29.1/lib::/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib java.vm.info Mixed mode Sharing java.vendor Tencent java.vm.version 25.252-b1 java.ext.dirs / data/TencentKona-8.0.2-252/jre/lib/ext:/usr/java/packages/lib/ext sun.io.unicode.encoding UnicodeLittle java.class.version 52.0
Temporarily set the system properties of the current process
[arthas@29749] $sysprop java.class.path / data/jdk/latestSuccessfully changed the system property. KEY VALUE---- java.class.path / data/jdk/latestlogger directive-- * View or settings logger
Parameter description
[arthas@29749] $logger-h USAGE: logger [- c] [--classLoaderClass] [- h] [--include-no-appender] [- l] [- n] SUMMARY: Print logger info And update the logger level Examples: logger logger-c 327a647b logger-c 327a647b-name ROOT-- level debug logger-- include-no-appender WIKI: https://arthas.aliyun.com/doc/logger OPTIONS:-c Classloader classLoader hashcode, if no value is set, default value is SystemClassLoader-- classLoaderClass The class name of the special class's classLoader. -h,-- help this help-- include-no-appender include the loggers which don't have appenders, default value false-l,-- level set logger level-n,-- name logger name
Use examples
Set the log level of logger's ROOT appender
# get logger class information [arthas@29749] $logger name ROOT class ch.qos.logback.classic.Logger classLoader org.springframework.boot.loader.LaunchedURLClassLoader@5674cd4d classLoaderHash 5674cd4d level INFO effectiveLevel INFO. # set the ROOT name log level to DEBUG [arthas@29749] $logger-c 5674cd4d-n ROOT-l DEBUG
Heapdump instruction-heap dump
Parameter description
[arthas@29749] $heapdump-h USAGE: heapdump [- h] [- l] [file] SUMMARY: Heap dump Examples: heapdump # # hprof file is saved to the current directory heapdump-- live # # active object heapdump-- live / tmp/dump.hprof WIKI: https://arthas.aliyun.com/doc/heapdump OPTIONS:-h -- help this help-l,-- live Dump only live objects If not specified, all objects in the heap are dumped. Output filesc directive-- get a list of loaded classes
Parameter description
[arthas@29749] $sc-h USAGE: sc [- c] [--classLoaderClass] [- d] [- x] [- f] [- h] [- n] [- E] class-pattern SUMMARY: Search all the classes loaded by JVM EXAMPLES: sc-d org.apache.commons.lang.StringUtils sc-d org/apache/commons/lang/StringUtils sc-d * StringUtils Sc-d-f org.apache.commons.lang.StringUtils sc-E org\\ .apache\\ .commons\ .lang\\ .StringUtils WIKI: https://arthas.aliyun.com/doc/sc OPTIONS:-c -classloader The hash code of the special class's classLoader-classLoaderClass The class name of the special class's classLoader. -d,-- details Display the details of class-x,-- expand Expand level of object (0 by default)-f,-- field Display all the member variables-h,-- help this help-n -- limits Maximum number of matching classes with details (100by default)-E,-- regex Enable regular expression to match (wildcard matching by default) Class name pattern, use either'. Or'/'as separator
Use examples
# get the loaded package name class name list [arthas@29749] $sc com.tencent.tsf.*com.sun.proxy.$Proxy132com.sun.proxy.$Proxy143com.tencent.tsf.TsfApplicationStartercom.tencent.tsf.TsfApplicationStarter$$EnhancerBySpringCGLIB$$e6e6d3dccom.tencent.tsf.common.TsfBaseEntitycom.tencent.tsf.common.TsfPagecom.tencent.tsf.common.TsfPageQuerycom.tencent.tsf.common.aop.ControllerCommonLog.
The-d parameter gets the basic information of a specific class:
[arthas@29749] $sc com.tencent.tsf.TsfApplicationStarter-d class-info com.tencent.tsf.TsfApplicationStarter code-source fileGetWord [sc com.tencent.tsf.TsfApplicationStarter]-d _ TSF _ color _ ossqt _ TSF _ r _ r False isAnonymousClass false isArray false isLocalClass false isMemberClass false isPrimitive false isSynthetic false simple-name TsfApplicationStarter modifier public annotation org.springframework.boot.autoconfigure.SpringBootApplication Org.springframework.cloud.client.discovery.EnableDiscoveryClient,org.springframework.cloud.netflix.feign.EnableFeignClients,org.springframework.transaction.annotation.EnableTransactionManag ement,org.springframework.scheduling.annotation.EnableScheduling Org.springframework.context.annotation.EnableAspectJAutoProxy interfaces super-class +-java.lang.Object class-loader +-org.springframework.boot.loader.LaunchedURLClassLoader@5674cd4d +-sun.misc.Launcher$AppClassLoader@70dea4e +-sun.misc.Launcher$ExtClassLoader@65e2dbf3 classLoaderHash 5674cd4d class-info com.tencent.tsf.TsfApplicationStarter$$EnhancerBySpringCGLIB$$e6e6d3dc code-source file:/data/tsf/tsf-oss/tsf-ratelimit/tsf-ratelimit -1.29.1 LBUBUR TFRATERACTUR 1.29.1.JARTMAXINFUBERBUBUBUBUBUBUBUBUBUBUBUBUR Context.annotation.ConfigurationClassEnhancer$EnhancedConfiguration super-class +-com.tencent.tsf.TsfApplicationStarter +-java.lang.Object class-loader +-org.springframework.boot.loader.LaunchedURLClassLoader@5674cd4d +-sun.misc.Launcher$AppClassLoader@70dea4e +-sun.misc.Launcher$ExtClassLoader@65e2dbf3 classLoaderHash 5674cd4dAffect (row-cnt:2) cost in 17 ms.sm instruction-- get the method information of the specified class
This instruction parameter is similar to the sc instruction parameter.
Examples of use:
# # get the list of all methods of com.tencent.tsf.common.TsfPageQuery class [arthas@29749] $sm com.tencent.tsf.common.TsfPageQuery * com.tencent.tsf.ratelimit.domain.Ratelimit (Lcom/tencent/tsf/ratelimit/domain/Ratelimit;) Vcom.tencent.tsf.ratelimit.domain.Ratelimit () Vcom.tencent.tsf.ratelimit.domain.Ratelimit toString () Ljava/lang/String;com.tencent.tsf.ratelimit.domain.Ratelimit getRules () Ljava/util/List Com.tencent.tsf.ratelimit.domain.Ratelimit lambda$containsIn$0 (Lcom/tencent/tsf/ratelimit/domain/Ratelimit$Rule;Lcom/tencent/tsf/ratelimit/domain/Ratelimit$Rule;) Zcom.tencent.tsf.ratelimit.domain.Ratelimit setRules (Ljava/util/List;) Vcom.tencent.tsf.ratelimit.domain.Ratelimit isValidRequest (Z) Zcom.tencent.tsf.ratelimit.domain.Ratelimit getRequestIdentity () Ljava/lang/String;com.tencent.tsf.ratelimit.domain.Ratelimit setNamespaceId (Ljava/lang/String;) Vcom.tencent.tsf.ratelimit.domain.Ratelimit containsIn (Ljava/util/List ) Zcom.tencent.tsf.ratelimit.domain.Ratelimit isDimensionConflict (Ljava/util/List;) Zcom.tencent.tsf.ratelimit.domain.Ratelimit getNamespaceId () Ljava/lang/String;com.tencent.tsf.ratelimit.domain.Ratelimit getServiceName () Ljava/lang/String;com.tencent.tsf.ratelimit.domain.Ratelimit setServiceName (Ljava/lang/String;) Vcom.tencent.tsf.common.proxy.Application () Vcom.tencent.tsf.common.proxy.Application setApplicationId (Ljava/lang/String ) Vcom.tencent.tsf.common.proxy.Application getMicroserviceType () Ljava/lang/String;com.tencent.tsf.common.proxy.Application setMicroserviceType (Ljava/lang/String;) Vcom.tencent.tsf.common.proxy.Application getApplicationId () Ljava/lang/String;com.tencent.tsf.ratelimit.proxy.Microservice () Vcom.tencent.tsf.ratelimit.proxy.Microservice setMicroserviceName (Ljava/lang/String;) Vcom.tencent.tsf.ratelimit.proxy.Microservice setNamespaceId (Ljava/lang/String ) Vcom.tencent.tsf.ratelimit.proxy.Microservice getMicroserviceName () Ljava/lang/String;com.tencent.tsf.ratelimit.proxy.Microservice getNamespaceId () Ljava/lang/String;com.tencent.tsf.ratelimit.proxy.Microservice getMicroserviceId () Ljava/lang/String;com.tencent.tsf.ratelimit.proxy.Microservice setMicroserviceId (Ljava/lang/String;) Vcom.tencent.tsf.common.TsfPageQuery () Vcom.tencent.tsf.common.TsfPageQuery clear () Vcom.tencent.tsf.common.TsfPageQuery getOffset () Ljava/lang/Integer Com.tencent.tsf.common.TsfPageQuery setOffset (Ljava/lang/Integer;) Vcom.tencent.tsf.common.TsfPageQuery initDefault () Vcom.tencent.tsf.common.TsfPageQuery setSearchWord (Ljava/lang/String;) Vcom.tencent.tsf.common.TsfPageQuery getOrderType () Ljava/lang/Integer;com.tencent.tsf.common.TsfPageQuery getOrderTypeStr () Ljava/lang/String;com.tencent.tsf.common.TsfPageQuery setOrderType (Ljava/lang/Integer;) Vcom.tencent.tsf.common.TsfPageQuery getOrderBy () Ljava/lang/String Com.tencent.tsf.common.TsfPageQuery setOrderBy (Ljava/lang/String;) Vcom.tencent.tsf.common.TsfPageQuery getRealPage () Icom.tencent.tsf.common.TsfPageQuery transerPageQuery (Lcom/tencent/tsf/common/TsfPageQuery;) Vcom.tencent.tsf.common.TsfPageQuery getSearchWordLikeStr () Ljava/lang/String;com.tencent.tsf.common.TsfPageQuery getLimit () Ljava/lang/Integer;com.tencent.tsf.common.TsfPageQuery setLimit (Ljava/lang/Integer;) Vcom.tencent.tsf.common.TsfPageQuery getSearchWord () Ljava/lang/String Affect (row-cnt:43) cost in 12 ms.monitor instruction-method execution monitoring
This instruction is a non-real-time return instruction, and the default is 120s to return a statistical value.
Statistics interval, the total number of method execution, the number of successes, the number of failures, the average execution rate, the proportion of failures and other information.
Parameter description
[arthas@8738] $monitor-h USAGE: monitor [- b] [- c] [--exclude-class-pattern] [- h] [- n] [--listenerId] [- E] [- v] class-pattern method-pattern [condition-express] SUMMARY: Monitor method execution statistics, e.g. Total/success/failure count, average rt, fail rate Etc. Examples: monitor org.apache.commons.lang.StringUtils isBlank monitor org.apache.commons.lang.StringUtils isBlank-c 5 monitor org.apache.commons.lang.StringUtils isBlank params [0]! = null monitor-b org.apache.commons.lang.StringUtils isBlank params [0]! = null monitor-E org\ .Apache\ .Commons\ .lang\ .StringUtils isBlank WIKI: https://arthas.aliyun.com/doc/monitor OPTIONS:-b -- before Evaluate the condition-express before method invoke-c,-- cycle The monitor interval (in seconds), 60 seconds by default-- exclude-class-pattern exclude class name pattern, use either'. Or'/'as separator-h,-- help this help-n,-- limits Threshold of execution times-- listenerId The special listenerId-E,-- regex Enable regular expression to match (wildcard matching by default)-v -- verbose Enables print verbose information, default value false. Path and classname of Pattern Matching Method of Pattern Matching Conditional expression in ognl style For example: TRUE: 1 TRUE: true FALSE: false TRUE: 'params.length > = 0' FALSE: 1 collect 2'# cost > 100'
Use examples
[arthas@8738] $monitor com.tencent.tsf.resource.ns.dao.NamespaceDao * Press Q or Ctrl+C to abort.Affect (class count: 1, method count: 15) cost in 104 ms ListenerId: 6 timestamp class method total success fail avg-rt (ms) fail-rate- -2021-09-09 18:26:58 com.tencent.tsf.resource.ns.dao.NamespaceDao countList 12 12 0 1.08 0.00% 2021-09-09 18:26:58 com.tencent.tsf.resource.ns.dao.NamespaceDao getAuthWhereClause 28 28 0 0.18 0.00% 2021-09-09 18:26:58 com.tencent.tsf.resource.ns.dao.NamespaceDao findList 2 20 1.09 0.005% answers to questions about how to use the Arthas online java process diagnostic tool are shared here. I hope the above content can help you to a certain extent, if you still have a lot of doubts to be solved, you can follow the industry information channel to learn more related knowledge. This is how the Arthas online java process diagnosis tool shared by Xiaobian is used. If you happen to have similar doubts, you might as well refer to the above analysis to understand. If you want to know more about it, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.