LinuxCommandLibrary

arthas

Diagnose and troubleshoot Java applications in real-time

TLDR

Start Arthas

$ java -jar [path/to/arthas-boot.jar]
copy

Reconnect Arthas (default port used by Arthas is 3658)
$ telnet localhost [port_number]
copy

Exit the current Arthas client without affecting other clients. equals exit、logout、q command
$ [exit|quit|logout|q]
copy

Terminate the Arthas server, all the Arthas clients connecting to this server will be disconnected
$ stop
copy

SYNOPSIS

as.sh [pid] [-h | --help] [-v | --version] [-c command] [--telnet-port port] [--http-port port] [--session-name name] [--async]

PARAMETERS

-h, --help
    Display usage help and exit

-v, --version
    Print Arthas version information

-c, --command <command>
    Execute command non-interactively and exit

--telnet-port <port>
    Telnet server port (default: random)

--http-port <port>
    HTTP server port (default: random)

--session-name <name>
    Custom session name

--async
    Execute command asynchronously

--input-arg <arg>
    Pass arguments to input stream

-Dkey=value
    Set Java system properties

<pid>
    Target Java process ID (optional; lists processes if omitted)

DESCRIPTION

Arthas is an open-source Java diagnostic framework designed for production environments, allowing developers to monitor, diagnose, and troubleshoot Java applications without code modification or service restarts.

It attaches to running JVM processes, providing an interactive shell with powerful commands for tasks like viewing thread dumps, tracing method calls, decompiling classes, monitoring heap memory, and watching variables. Key features include dashboard for real-time metrics, thread for deadlock detection, trace for method execution paths, watch for variable monitoring, jad for bytecode decompilation, and mc for hot-compiling code changes.

Arthas supports both interactive and batch modes, telnet/HTTP access, and scripting. It's widely used in microservices, containers, and cloud-native setups for quick issue resolution, reducing MTTR (Mean Time to Repair). Developed for high-traffic systems, it handles complex scenarios like slow queries or memory leaks efficiently.

CAVEATS

Requires JDK 8+ and attach permissions (may need sudo); attaching to many processes can consume resources; not for JDK 17+ without agent tweaks; production use may impact performance if overused.

INSTALLATION

Download arthas-boot.jar from GitHub releases:
java -jar arthas-boot.jar
Or install script: wget https://arthas.aliyun.com/arthas-bootstrap.jar

KEY SUBCOMMANDS

dashboard: JVM metrics overview
thread: Thread list and analysis
trace: Method call tracing
watch: Monitor expressions
jad: Decompile class

HISTORY

Developed by Alibaba's middleware team, first released in September 2018 on GitHub (apache/arthas). Inspired by grep/awk for JVMs, it evolved from internal tools handling Taobao's massive Java ecosystem. Now Apache Incubating project with 30k+ stars, regular updates for new JDKs and cloud support.

SEE ALSO

jcmd(1), jstack(1), jmap(1), jinfo(1), strace(1)

Copied to clipboard