Arthas (reading: Arthas) is a Java diagnostic tool released as open source by Alibaba. In the development environment, test environment, and production environment, you can monitor the status of the JVM and easily diagnose when a failure occurs without dropping the JVM. It is more powerful and easier to use than JDK tools such as jconsole jmap jstack.
・ I want to check which Jar this class is loaded from! Why did the exception occur? I feel like the code I committed wasn't running. .. .. Forgot to commit? Did you make a mistake in the branch? -I can't debug online, so I have to prepare logs and redeploy. -There was a problem with the data processing of a user who has a production, but it cannot be debugged in the production and cannot be reproduced locally! What should I do? ・ What is the current situation of the JVM? ・ I want to know the status of the JVM in real time! ・ I want to draw a Flame Graph to find a bottleneck! I think it can be used in various situations.
Apache-2.0
JDK 6 or above Linux/Mac/Windows
Linux environment:
wget https://alibaba.github.io/arthas/arthas-boot.jar
java -jar arthas-boot.jar
If there is a running Java process, it can be started. If you want to monitor a specific Java process Check the currently running process with jps and pass the PID as a parameter. Example:
jps
341 Bootstrap
java -jar arthas-boot.jar 341
The following screen will be displayed, and you can execute various commands of arthas like a shell.
On the official site, it seems that the following command will install it in the current path and automatically generate the executable file as.sh. This is recommended if you usually use it as a diagnostic tool.
curl -L https://alibaba.github.io/arthas/install.sh | sh
./as.sh
dashboard
To be honest, I'm a little impressed if such a screen can be displayed in a shell environment. The top is a list of threads currently in the JVM instance, the left side in the middle is the memory status, the right side is GC information, the bottom is the OS, JVM version information, etc. For Tomcat, you can see an overview of performance.
thread
You can view the list of threads in the current JVM process and their status.
Furthermore, if you specify the thread number, the stack trace can be displayed and you can see which method is stopped.
jad
You can decompile the currently running class. I've fixed the code to fix a bug, but you can see if the fixed version is really working. Also, if you make a mistake and both different versions of the same Jar module get into the classpath, you can see which one is actually loaded.
redefine
You can load an external .class file and replace the class in the currently running JVM. Restrictions: You cannot create new class fields or new methods. Can be changed. Without restarting the JVM, in the case of Tomcat, it is possible to change the logic of the class without restarting and reloading. Oh ~
redefine /tmp/Test.class
redefine -c 327a647b /tmp/Test.class /tmp/Test\$Inner.class
sc
Shows information about the classes currently loaded in the JVM.
stack
Check for stacked traces
When checking the stack trace of test.arthas.TestStack # doGet below
trace
Which method is slower? It seems that it can be used for bottlenecks and performance surveys.
It has a web console function and can execute arthas commands on the Web, so it seems to be useful when diagnosing multiple servers. There are many other commands that can be used, so please see for details. Please refer to here. https://github.com/alibaba/arthas