Arthas monitors jvm_ray_my's blog in docker-CSDN blog
what is arthas
Arthas is Alibaba's open source Java diagnostic tool, which can help developers quickly and easily locate and solve Java application problems.
Arthas mainly includes the following functions:
Diagnose performance problems in Java applications, such as memory leaks, thread blocking, etc.;
Diagnose abnormal problems in Java applications, such as null pointer exceptions, database connection exceptions, etc.;
Diagnose code problems in Java applications, such as code logic errors and code security vulnerabilities. etc.;
monitor the running status of Java applications, such as memory usage, thread status, etc.;
provide a variety of Java application performance optimization solutions, such as memory optimization, thread optimization, etc.
Using Arthas requires some basic knowledge of Java. You can refer to Arthas official documentation or related tutorials to learn how to use it.
Start the test jar
curl -O https://arthas.aliyun.com/math-game.jar
java -jar math-game.jar
This is a jar file for testing
Linux starts arthas
curl -O https://arthas.aliyun.com/arthas-boot.jar
java -jar arthas-boot.jar
报错Can not find tools.jar under java home: /uinnova/jre1.8, please try to start arthas-boot with full path java.
solve:
Follow the prompts and execute java with the full path to java.
java process inside the container
docker exec -it 2f794c05c40c /bin/bash -c "java -jar /home/arthas-boot.jar"
Place arthas-boot.jar in the container mounting directory, otherwise it will not be found.
View dashboard
Directly enter the command dashboard and press Enter to display the information of the current process. The results will be refreshed and displayed. Press ctrl+C to exit.
You can see the usage of each memory area.
gc.ps_scavenge.count represents the number of young gc
gc.ps_marksweep.count represents the number of fullgc
View the mainclass of the process
thread 1 | grep 'main('
Use jad command to decompile mainclass
jad demo.MathGame
watch method returns object
watch demo.MathGame primeFactors returnObj
Exit arthas
Use the quit or exit command to disconnect the current process. The Arthas instance connected to the target process will continue to remain inside the target process, waiting for the next connection. (Don't use this, it will occupy the port and not release it)
Using the stop command allows Arthas to completely disconnect from the target process. (use this)
command list
User case
can learn