origin

Recently see a very popular title, “open source XX years, star XXX, I am how to adhere to”. It’s been a year since Arthas opened its doors in September 2018, and it’s a good time to wrap up and review.


Arthas is an open source Java diagnostic tool for Alibaba that developers love.

Arthas Star number has been growing rapidly and has now exceeded 16 K.

Arthas Github Star History curve

Thank users for their support, which is both pressure and motivation. Arthas has released seven releases in the past year of open source, and we’ve been sticking to three things:

  • Continuous improvement of ease of use
  • Keep adding useful commands
  • Take power from the open source community and give back to the community

Continuous improvement of ease of use

Arthas has always put ease of use first, and since open source we have made the following improvements:

  • Arthas Boot was developed to support a unified Windows/Linux/Mac experience
  • Smooth automatic completion, reference jshell experience
  • Efficient history command matching, Up/Down direct
  • Improved class search and match functionality to better support lambdas and inner classes
  • Improve the redirection mechanism
  • Support the JDK 9/10/11
  • Support the Docker
  • RPM/DEB package installation is supported

Although we put a lot of effort into ease of use, we found that it was often difficult for users to get started, so we introduced Arthas online tutorials by referring to K8S ‘Interactive Tutorial:

  • Arthas Basic Tutorial [3]
  • Arthas Advanced Tutorial [4]

The basic tutorial provides a step-by-step introduction to the interactive terminal, and the advanced tutorial provides an in-depth understanding of Arthas troubleshooting cases.

In addition, to facilitate large-scale deployment, the tunnel Server and user data return functions are implemented. The tunnel Server is added to centrally manage Agent connections. The user data return function is added to facilitate security control

Keep adding useful commands

Arthas claims to be a diagnostic tool for Java applications, so we have to live up to that claim. Arthas has continued to add more than 10 commands since open source.

  • Ognl command arbitrary code execution
  • MC online memory compiler
  • Re-define hot update code on the command line
  • The logger command displays all logger configurations in the application with one click
  • Sysprop View update System Properties
  • Sysenv Displays environment variables
  • Vmoption View updated VM options
  • Logger View logger configuration and update the level
  • Mbean views JMX information
  • Heapdump Heap memory snapshot

Two features are highlighted below.

Jad/MC/RE-define a dragon hot update online code

For example, UserController in the Arthas online tutorial: 1. Decomcompile the code using JAD

jad --source-only com.example.demo.arthas.user.UserController > /tmp/UserController.javaCopy the code

2. Compile code using VIm

If the user ID is less than 1, the system returns the same value without raising an exception:

@GetMapping("/user/{id}")
    public User findUserById(@PathVariable Integer id) {
        logger.info("id: {}" , id);

        if(id ! = null && id < 1) {return new User(id, "name" + id);
            // throw new IllegalArgumentException("id < 1");
        } else {
            return new User(id, "name"+ id); }}Copy the code

3, use MC command to compile the modified userController.java

$ mc /tmp/UserController.java -d /tmp
Memory compiler output:
/tmp/com/example/demo/arthas/user/UserController.class
Affect(row-cnt:1) cost in 346 msCopy the code

4. Use re-define because you can hot update your code

$ redefine /tmp/com/example/demo/arthas/user/UserController.class
redefine success, size: 1Copy the code

View the configuration and change the level by using logger command

When the site is under a lot of pressure (such as Double 11), a relief measure is to change the application log level to ERROR. So there are two questions:

  • Complex applications can have multiple logging systems, so which logging system configuration actually takes effect?
  • How to dynamically change logger level online? Using logger command, you can view detailed logger configuration information in the application, such as FileAppender output file, AsyncAppender blocking or not.
[arthas@2062]$ logger
 name                                   ROOT
 class                                  ch.qos.logback.classic.Logger
 classLoader                            sun.misc.Launcher$AppClassLoader@2a139a55
 classLoaderHash                        2a139a55
 level                                  INFO
 effectiveLevel                         INFO
 additivity                             trueCodeSource file: / Users/hengyunabc/m2 / repository/ch/qos/logback/logback - classic / 1.2.3 / logback - classic - 1.2.3. Jar appenders name CONSOLE class ch.qos.logback.core.ConsoleAppender classLoader sun.misc.Launcher$AppClassLoader@2a139a55
                                        classLoaderHash 2a139a55
                                        target          System.out
                                        name            APPLICATION
                                        class           ch.qos.logback.core.rolling.RollingFileAppender
                                        classLoader     sun.misc.Launcher$AppClassLoader@2a139a55
                                        classLoaderHash 2a139a55
                                        file            app.log
                                        name            ASYNC
                                        class           ch.qos.logback.classic.AsyncAppender
                                        classLoader     sun.misc.Launcher$AppClassLoader@2a139a55
                                        classLoaderHash 2a139a55
                                        blocking        false
                                        appenderRef     [APPLICATION]Copy the code

Logger level can also be changed online:

[arthas@2062]$ logger --name ROOT --level debug
update logger level success.Copy the code

Take power from the open source community and give back to the community

Thanks to 67 molecules

Since Arthas opened source, there have been 67 ficolin-3 thanks for their contributions to improvements:

The Arthas Polymorphism community submitted a range of improvements, with some points listed below (incomplete) :

  • Translated most of the English documents
  • The trace command supports line numbers
  • The packaging format supports RPM/DEB
  • Improved command line prompt to arthas@pid
  • Improved support for Windows
  • Add the mbean command
  • Improve the WebConsole experience

In addition, 83 companies/organizations have registered their usage information, and more users are welcome to register:



Non-ergot-derived dopamine agonists project

Several spinoff projects were derived from Arthas, two of which are listed below:

  • Bistoury: Qunar’s open source integrated Arthas project
  • Arthas-mvel: a fork that uses the mVEL script

User Case Sharing

Arthas users have shared a lot of information about how to troubleshoot problems with Arthas.



Giving back to the open source

Arthas itself uses a lot of open source code, and in the open source process we have contributed improvements to Netty, OGNL, CFR, and others to feed back upstream.

Afterword.

At the time of the Arthas brochure, Arthas had the following tagline:

“Hand of rose, lingering fragrance.”

Hopefully Arthas will be able to help more users solve problems in the future, and hopefully developers will be able to make improvements and suggestions to Arthas.

The original link

This article is the original content of the cloud habitat community, shall not be reproduced without permission.