Alibaba开源Java诊断工具Arthas简单介绍

简介: Alibaba开源Java诊断工具Arthas简单介绍

640.jpg

Alibaba开源Java诊断工具Arthas

640.png


Arthas 是Alibaba开源的Java诊断工具,深受开发者喜爱。在线排查问题,无需重启;动态跟踪Java代码;实时监控JVM状态。


当你遇到以下类似问题而束手无策时,Arthas可以帮助你解决:

1)这个类从哪个 jar 包加载的?为什么会报各种类相关的 Exception?

2)我改的代码为什么没有执行到?难道是我没 commit?分支搞错了?

3)遇到问题无法在线上 debug,难道只能通过加日志再重新发布吗?

4)线上遇到某个用户的数据处理有问题,但线上同样无法 debug,线下无法重现!

5)是否有一个全局视角来查看系统的运行状况?

6)有什么办法可以监控到JVM的实时运行状态?

7)怎么快速定位应用的热点,生成火焰图?

Arthas支持JDK 6+,支持Linux/Mac/Winodws,采用命令行交互模式,同时提供丰富的 Tab 自动补全功能,进一步方便进行问题的定位和诊断。

Github: https://github.com/alibaba/arthas

文档: https://alibaba.github.io/arthas/


下面介绍arthas的安装以及简单使用


1、下载arthas


在线方式快速安装


curl -O https://alibaba.github.io/arthas/arthas-boot.jar
java -jar arthas-boot.jar


离线的方式


https://github.com/alibaba/arthas/releases/tag/arthas-all-3.3.6


下载arthas-bin.zip
rz上传到服务器某个目录,例如/home
mkdir arthas
unzip arthas-bin.zip -d arthas
cd arthas
sh install-local.sh


640.png

640.png

640.png


2、启动arthas


1)用as.sh启动

./as.sh


640.png

2)用arthas-boot启动  

java -jar arthas-boot.jar

选择应用java进程

例如kafka进程是第1个,输入1回车,Arthas会attach到目标进程上


640.png


3、help命令查看命令帮助



[arthas@10528]$ help
 NAME         DESCRIPTION                                                                                                                                                      
 help         Display Arthas Help                                                                                                                                              
 keymap       Display all the available keymap for the specified connection.                                                                                                   
 sc           Search all the classes loaded by JVM                                                                                                                             
 sm           Search the method of classes loaded by JVM                                                                                                                       
 classloader  Show classloader info                                                                                                                                            
 jad          Decompile class                                                                                                                                                  
 getstatic    Show the static field of a class                                                                                                                                 
 monitor      Monitor method execution statistics, e.g. total/success/failure count, average rt, fail rate, etc.                                                               
 stack        Display the stack trace for the specified class and method                                                                                                       
 thread       Display thread info, thread stack                                                                                                                                
 trace        Trace the execution time of specified method invocation.                                                                                                         
 watch        Display the input/output parameter, return object, and thrown exception of specified method invocation                                                           
 tt           Time Tunnel                                                                                                                                                      
 jvm          Display the target JVM information                                                                                                                               
 perfcounter  Display the perf counter infornation.                                                                                                                            
 ognl         Execute ognl expression.                                                                                                                                         
 mc           Memory compiler, compiles java files into bytecode and class files in memory.                                                                                    
 redefine     Redefine classes. @see Instrumentation#redefineClasses(ClassDefinition...)                                                                                       
 dashboard    Overview of target jvm's thread, memory, gc, vm, tomcat info.                                                                                                    
 dump         Dump class byte array from JVM                                                                                                                                   
 heapdump     Heap dump                                                                                                                                                        
 options      View and change various Arthas options                                                                                                                           
 cls          Clear the screen                                                                                                                                                 
 reset        Reset all the enhanced classes                                                                                                                                   
 version      Display Arthas version                                                                                                                                           
 session      Display current session information                                                                                                                              
 sysprop      Display, and change the system properties.                                                                                                                       
 sysenv       Display the system env.                                                                                                                                          
 vmoption     Display, and update the vm diagnostic options.                                                                                                                   
 logger       Print logger info, and update the logger level                                                                                                                   
 history      Display command history                                                                                                                                          
 cat          Concatenate and print files                                                                                                                                      
 echo         write arguments to the standard output                                                                                                                           
 pwd          Return working directory name                                                                                                                                    
 mbean        Display the mbean information                                                                                                                                    
 grep         grep command for pipes.                                                                                                                                          
 tee          tee command for pipes.                                                                                                                                           
 profiler     Async Profiler. https://github.com/jvm-profiling-tools/async-profiler                                                                                            
 stop         Stop/Shutdown Arthas server and exit the console.                                                                                                                
[arthas@10528]$

640.png


4、jvm——查看当前 JVM 的信息

640.png

640.png

5、thread——查看当前 JVM 的线程堆栈信息

640.png

例如thread -n 3 查看占CPU资源最多的前3个线程

640.png

6、dashboard 当前系统的实时数据面板

640.png

更多用法就不一一介绍,具体可以参考https://alibaba.github.io/arthas/官方文档


7、一图掌握Arthas—常用命令汇总


若图片不清晰,请后台联系作者索要高清大图

或者如下地址下载高清大图

https://user-images.githubusercontent.com/31468811/71954111-3010be00-321f-11ea-9900-e88195c2a570.png

640.png

640.png

相关文章
|
5月前
|
人工智能 缓存 监控
使用LangChain4j构建Java AI智能体:让大模型学会使用工具
AI智能体是大模型技术的重要演进方向,它使模型能够主动使用工具、与环境交互,以完成复杂任务。本文详细介绍如何在Java应用中,借助LangChain4j框架构建一个具备工具使用能力的AI智能体。我们将创建一个能够进行数学计算和实时信息查询的智能体,涵盖工具定义、智能体组装、记忆管理以及Spring Boot集成等关键步骤,并展示如何通过简单的对话界面与智能体交互。
1814 1
|
4月前
|
人工智能 监控 Java
Java与AI智能体:构建自主决策与工具调用的智能系统
随着AI智能体技术的快速发展,构建能够自主理解任务、制定计划并执行复杂操作的智能系统已成为新的技术前沿。本文深入探讨如何在Java生态中构建具备工具调用、记忆管理和自主决策能力的AI智能体系统。我们将完整展示从智能体架构设计、工具生态系统、记忆机制到多智能体协作的全流程,为Java开发者提供构建下一代自主智能系统的完整技术方案。
673 4
|
5月前
|
人工智能 Java API
Java AI智能体实战:使用LangChain4j构建能使用工具的AI助手
随着AI技术的发展,AI智能体(Agent)能够通过使用工具来执行复杂任务,从而大幅扩展其能力边界。本文介绍如何在Java中使用LangChain4j框架构建一个能够使用外部工具的AI智能体。我们将通过一个具体示例——一个能获取天气信息和执行数学计算的AI助手,详细讲解如何定义工具、创建智能体并处理执行流程。本文包含完整的代码示例和架构说明,帮助Java开发者快速上手AI智能体的开发。
1906 8
|
8月前
|
Java 数据安全/隐私保护 计算机视觉
银行转账虚拟生成器app,银行卡转账截图制作软件,java实现截图生成工具【仅供装逼娱乐用途】
本内容提供Java生成自定义图片的示例代码,涵盖基础图像创建、文本添加及保存功能,适合学习2D图形编程。包括教学示例图片生成、文本图层处理和数字水印技术实现方案。
|
8月前
|
安全 Java 编译器
JD-GUI,java反编译工具及原理: JavaDecompiler一个Java反编译器
Java Decompiler (JD-GUI) 是一款由 Pavel Kouznetsov 开发的图形化 Java 反编译工具,支持 Windows、Linux 和 Mac Os。它能将 `.class` 文件反编译为 Java 源代码,支持多文件标签浏览、高亮显示,并兼容 Java 5 及以上版本。JD-GUI 支持对整个 Jar 文件进行反编译,可跳转源码,适用于多种 JDK 和编译器。其原理基于将字节码转换为抽象语法树 (AST),再通过反编译生成代码。尽管程序可能带来安全风险,但可通过代码混淆降低可读性。最新版修复了多项识别错误并优化了内存管理。
6318 1
|
9月前
|
Arthas 存储 监控
Arthas heapdump(dump java heap, 类似 jmap 命令的 heap dump 功能)
Arthas heapdump(dump java heap, 类似 jmap 命令的 heap dump 功能)
707 8
|
8月前
|
Java 数据安全/隐私保护
银行转账虚拟生成器app,银行卡转账截图制作软件,java实现截图生成工具【仅供装逼娱乐用途】
本项目提供了一套基于Java的图片处理教学方案,包含自定义图片生成、图像水印添加及合法电子凭证生成技术示例。
|
Arthas 监控 Java
Java 诊断利器 Arthas使用
Java 诊断利器 Arthas使用
4467 0
|
Arthas 监控 Java
Arthas 可以用于监控和诊断在 Windows 系统下部署的 Tomcat 服务
Arthas 可以用于监控和诊断在 Windows 系统下部署的 Tomcat 服务
1605 2
|
Arthas 监控 Java
开源Java诊断工具Arthas:开篇之watch实战
还在为排查Java程序线上问题头痛吗,看我们用阿里开源的诊断神器 Arthas 来帮您
1353 1