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

image

常用命令

  1. trace命令追踪程序消耗时间
# 调用耗时大于1ms的调用记录
trace demo.MathGame run '#cost > 1'

image

  1. monitor命令监控方法的成功失败统计
# 监控统计primeFactors方法调用情况
monitor demo.MathGame primeFactors -c 5

image

  1. jad命令反编译代码
# 反编译primeFactors方法
jad demo.MathGame primeFactors

image

  1. watch命令检测方法入参和返回值
    watch 命令定义了4个观察事件点,即 -b 方法调用前,-e 方法异常后,-s 方法返回后,-f 方法结束后
# -b 方法执行前的参数
watch demo.MathGame primeFactors "{params, returnObj}" -x 2 -b

image

总结:

  • trace 查找最耗时的方法
  • monitor 统计方法的成功失败情况
  • jad 检查反编译代码
  • watch 查看方法的入参和返回值

最后,要完全退出arthas服务,请使用stop命令。

参考网址:

posted @ 2025-08-28 16:12  Andy_lu020  阅读(5)  评论(0)    收藏  举报