Arthas的火焰图生成

之前说过用idea自带的工具生成火焰图,但是idea是在本地的,在机器上如何生成呢?
我觉得方法有很多,这里用arthas工具简单搞一搞
Arthas官网地址

下载Arthas

如果在机器上要下载整个包,arthas-boot.jar需要依赖其他的jar包

操作

进入到jvm进程中

 ~/software/arthas/ java -jar arthas-boot.jar
[INFO] JAVA_HOME: /Library/Java/JavaVirtualMachines/zulu-8.jdk/Contents/Home/jre
[INFO] arthas-boot version: 3.6.9
[INFO] Found existing java process, please choose one and input the serial number of the process, eg : 1. Then hit ENTER.
* [1]: 2033 
  [2]: 2070 org.jetbrains.idea.maven.server.RemoteMavenServer36
  [3]: 2118 math-game.jar
  [4]: 2072 org.jetbrains.jps.cmdline.Launcher
3
[INFO] Try to attach process 2118
Picked up JAVA_TOOL_OPTIONS: 
[INFO] Attach process 2118 success.
[INFO] arthas-client connect 127.0.0.1 3658
  ,---.  ,------. ,--------.,--.  ,--.  ,---.   ,---.                           
 /  O  \ |  .--. ''--.  .--'|  '--'  | /  O  \ '   .-'                          
|  .-.  ||  '--'.'   |  |   |  .--.  ||  .-.  |`.  `-.                          
|  | |  ||  |\  \    |  |   |  |  |  ||  | |  |.-'    |                         
`--' `--'`--' '--'   `--'   `--'  `--'`--' `--'`-----'                          

wiki       https://arthas.aliyun.com/doc                                        
tutorials  https://arthas.aliyun.com/doc/arthas-tutorials.html                  
version    3.6.9                                                                
main_class demo.MathGame                                                        
pid        2118                                                                 
time       2023-07-15 12:55:44                                                  

[arthas@2118]$ 

开始采集

[arthas@2118]$ profiler start
Profiling started
[arthas@2118]$ 
[arthas@2118]$ 
[arthas@2118]$ profiler getSamples
22
[arthas@2118]$ 
[arthas@2118]$ profiler status
Profiling is running for 52 seconds
[arthas@2118]$ 
[arthas@2118]$ profiler stop --format html
OK
profiler output file: /Users/lixi/software/arthas/arthas-output/20230715-125705.html
[arthas@2118]$ 
[arthas@2118]$ 

查看

open /Users/lixi/software/arthas/arthas-output/20230715-125705.html

选择 main 方法

总结

方法很简单,主要用到的命令

profiler start
profiler status
profiler stop --format html

你可能感兴趣的:(杂记,运维)