Arthas: what is
You think it’s like this
Actually Arthas here is shown below
In fact Arthas:
- Is a command line tool
- It is usually a JAR package launched through Java
- A large number of bytecode and other black technology directly read and control the corresponding Java process tools
Arthas addresses major issues
- From which JAR is this class loaded? Why are all kinds of class-related exceptions reported?
- Why didn’t the code I changed execute? Did I not commit? Got the branch wrong?
- If you encounter a problem, you cannot debug it online. Can you only re-publish it by logging?
- There is a problem with a user’s data processing online, but it cannot be debugged online, and it cannot be reproduced offline!
- Is there a global view of the health of the system?
- Is there any way to monitor the real-time health of the JVM?
- How to quickly locate application hot spots, generate flame map?
Generally speaking, it fits perfectly
Troubleshooting online/performance/offline BUG that is difficult to reproduceCopy the code
A typical scenario
The phenomenon of
The software CPU usage is abnormally high
operation
1. Log in to the production server 2. Copy arthas-boot.jar to the production server 3. See the big picture
dashboard
Copy the code
5. Find hot threads
Thread -i 3000 - n 5Copy the code
You can also find the entry via the following script
thread 1 | grep 'main'
Copy the code
6. Decompile to view the source code for further positioning,
jad --source-only com.wangji92.arthas.plugin.demo.controller.CommonController
Copy the code
7. Use monitor to count the available lines of code
monitor com.wangji92.arthas.plugin.demo.controller.CommonController add -n 10 --cycle 10
Copy the code
8. Check if it is called, parameter and return value, exception
watch com.wangji92.arthas.plugin.demo.controller.CommonController * '{params,returnObj,throwExp}' -n 5 -x 3
Copy the code
9. View the call chain
trace com.wangji92.arthas.plugin.demo.controller.CommonController getRandomInteger -n 10
Copy the code
- Stack analysis if necessary
heapdump 1.hprof
Copy the code
Mat analysis dump
Some issues with Arthas
- The bar is high, you need to use more complex parameters or syntax sugar, and you really need a small book of commonly used syntax
- Arthas is risky because it runs directly on production servers and is based on bytecodes and other technologies, bypassing security mechanisms and manipulating internal software parameters and methods, making it difficult to handle errors that are not visible from the outside
- Arthas is still supposed to be a great tool for saving your sales, you don’t want to have to guess what’s wrong with the software logs in an emergency.
reference
- Github.com/alibaba/art…
- alibaba.github.io/arthas/