Arthas 工具实战(1)
日期:2025.08.28
简介
Arthas 是阿里开源的一款线上监控诊断工具。
官方网址: https://arthas.aliyun.com/
码云地址: http://arthas.gitee.io/
GitHub地址:https://github.com/alibaba/arthas
安装
下载地址:https://github.com/alibaba/arthas/releases
我下载的是 arthas-all-4.0.5
版本
解压arthas-bin压缩包,启动math-game.jar和arthas-boot.jar
常用命令
trace
命令追踪程序消耗时间
# 调用耗时大于1ms的调用记录
trace demo.MathGame run '#cost > 1'
monitor
命令监控方法的成功失败统计
# 监控统计primeFactors方法调用情况
monitor demo.MathGame primeFactors -c 5
jad
命令反编译代码
# 反编译primeFactors方法
jad demo.MathGame primeFactors
watch
命令检测方法入参和返回值
watch 命令定义了4个观察事件点,即 -b 方法调用前,-e 方法异常后,-s 方法返回后,-f 方法结束后
# -b 方法执行前的参数
watch demo.MathGame primeFactors "{params, returnObj}" -x 2 -b
总结:
- trace 查找最耗时的方法
- monitor 统计方法的成功失败情况
- jad 检查反编译代码
- watch 查看方法的入参和返回值
最后,要完全退出arthas服务,请使用stop
命令。
参考网址:
生生不息