开源诊断工具Arthas

说明:

1、需要先要安装配置好jdk。

2、你的虚拟机得有网,没有网就按照压缩包上传解压。然后直接看三

一、官网

https://arthas.aliyun.com/doc/quick-start.html#_1-启动-math-game

二、下载和卸载

powershell 复制代码
# 下载
curl -O https://arthas.aliyun.com/arthas-boot.jar

# 卸载
rm -rf ~/.arthas/
rm -rf ~/logs/arthas

三、启动

powershell 复制代码
# 这个命令在要在有java进程的时候执行,作用是启动Arthas
java -jar arthas-boot.jar

这样就启动成功了

启动成功后,会生成两个文件夹

powershell 复制代码
~/.arthas/
~/logs/arthas


在.arthas里面,还可以找到官方演示用的例子,java -jar启动这个,后面用这个做说明

powershell 复制代码
ls ~/.arthas/lib/4.0.4/arthas//

4、快速启动跟进一个进程

启动一个进程,如官方的演示进程后,在启动arthas,选择需要跟进的进程,这块选演示进程了

注意:如果保存,可以杀死那个占用端口的进程,或者换一个端口

powershell 复制代码
# 这里 --telnet-port 9998 指定了一个新的 Telnet 端口号,
# 而 --http-port -1 表示禁用 HTTP 服务(如果不需要的话)。
# 你可以选择任何未被使用的端口号。
java -jar arthas-boot.jar --telnet-port 9998 --http-port -1

5、常用命令

  1. dashboard 仪表盘
    作用是展示一个仪表盘,按q退出
powershell 复制代码
dashboard
  1. cls

清屏

powershell 复制代码
cls
  1. thread
    查看所有线程,后面可以跟一个数字,表示要看哪一个线程
powershell 复制代码
thread
# 比如这里要看主线程相关状态可以写
thread 1


  1. jad

可以进行反编译你需要的类

powershell 复制代码
# 这里是反编译demo包下的MathGame类
jad demo.MathGame

5.watch

监视方法

powershell 复制代码
# 监视demo包下,MathGame类 primeFactors方法的返回值
watch demo.MathGame primeFactors returnObj
# 观察函数调用返回时的参数、this 对象和返回值
watch demo.MathGame primeFactors -x 2
# 观察函数调用入口的参数和返回值
$ watch demo.MathGame primeFactors "{params,returnObj}" -x 2 -b
# 同时观察函数调用前和函数返回后 
# 参数里-n 2,表示只执行两次-n 2
watch demo.MathGame primeFactors "{params,target,returnObj}" -x 2 -b -s -n 2
  1. 退出
powershell 复制代码
# 退了但是没有完全退,下次用可以直接连上
quit
# 这个是真退了,下次就是重现链接
stop
相关推荐
DolphinScheduler社区9 分钟前
# 3.1.8<3.2.0<3.3.1,Apache DolphinScheduler集群升级避坑指南
java·大数据·开源·apache·任务调度·海豚调度
CoderJia程序员甲36 分钟前
GitHub 热榜项目 - 日榜(2025-10-06)
ai·开源·llm·github·ai编程·github热榜
小小前端_我自坚强38 分钟前
Tailwind CSS 详解
css·程序员·开源
kalvin_y_liu3 小时前
DeploySharp开源发布:让C#部署深度学习模型更加简单
深度学习·开源·c#
猫头虎4 小时前
如何解决 pip install -r requirements.txt extras 语法 ‘package[extra’ 缺少 ‘]’ 解析失败问题
开发语言·python·开源·beautifulsoup·virtualenv·pandas·pip
序属秋秋秋6 小时前
《Linux系统编程之入门基础》【Linux的前世今生】
linux·运维·服务器·开源·unix·gnu
晚风予星16 小时前
Repository Contribution Count Action:开源贡献者的专属统计神器
开源·github
24K纯帅ll19 小时前
神经网络与人脑的联结JS如何模拟意识流动
开源
法欧特斯卡雷特19 小时前
从 Kotlin 编译器 API 的变化开始: 2.2.2X -> 2.3.0-Beta1
后端·架构·开源