1. Arthas What is that?
Excerpt from Arthas's Github description:
Arthas is a Java Diagnostic tool open sourced by Alibaba.
Arthas allows developers to troubleshoot production issues for Java applications without modifying code or restarting servers.
The effect that: Arthas Ali is an open-source Java diagnostic tool that can help developers to modify the code without restarting the server or online to quickly locate the problem.
It sounds really is a great benefit to our programmers. For example, we encountered a situation, Spring Boot applications have a cron cron job every day for the 1:00 start the execution, but very easy to test, we can not always make time to modify cron QC test, right? Although this is a convenient test sister, but inviting our development time and the number of iterations ah! ! ! Arthas in the end that is able to meet our needs? Go on ...
2. Turn on Arthas tour
2.1 Installation Arthas
- Embodiment 1: Download arthas-boot.jar packet mode
wget https://alibaba.github.io/arthas/arthas-boot.jar
复制代码
At this point in your current directory will have a arthas-boot.jar
package.
Try the next arthas:
# 启动arthas,会进入命令行交互状态
java -jar arthas-boot.jar
# 查看arthas命令手册
java -jar arthas-boot.jar -h
复制代码
- Option 2: (by as.sh installation Arthas strongly recommended )
# 该命令会下载 as.sh 到当前目录下
curl -L https://alibaba.github.io/arthas/install.sh | sh
复制代码
Try the next arthas:
# 启动arthas,会进入命令行交互状态
./as.sh
# 查看arthas命令手册
./as.sh -h
复制代码
2.2 started
The following shows our as.sh
main.
First, we start arthas, we will see to the application currently deployed on the server has been detected, on my current server only one application, simply enter the number 1, and the application can interact with:
2.2.1 basic commands
- By
dashboard
can view real-time application monitoring data command
- By
thread
viewing application threads in all cases command
-
By
thread threadId
viewing the specified thread status information command- For example, we want to see the thread ID for the thread state 506 information:
- Of course, because it is a command line interaction, also supports streaming pipeline operations:
-
By
watch
command to view the method parameters, return values, and exception information -
By
sc
command to view the type of information- by
sc yourFullClassName
- By
sc -d yourFullClassName*
going to see loads of JVM class information
- By
sc *yourClassName*
going to see loads of JVM class information
- by
-
By
sm
viewing the class information command method- case 1:
sm java.math.RoundingMode
- case 2:
sm -d java.math.RoundingMode
- case 3:
sm java.math.RoundingMode <init>
- case 1:
2.2.2 highlight command
-
By
jad yourFullClassName
going to see the complete code information decompiling -
By
jad --source-only yourFullClassName > /tmp/yourClassName.java
exporting decompile the code to a temporary directory -
By
vim /tmp/yourClassName.java
editing modify the code -
By
sc -d *yourClassName | grep classLoaderHash
acquiring loading yourClassName class loader -
By
mc -c classLoaderHash /tmp/yourClassName.java -d /tmp
re-using the same class loader class (mc: Memory Compiler) recompile the modified -
By
redefine /tmp/yourFullClassName.class
reload the new compiled class files
2.2.3 More Actions Case
Please refer to the official manual for more operational cases and usage.