Arthas 3.1.2 increase logger / heapdump command, support tunnel server

Arthas

ArthasJava is a diagnostic tool Alibaba open source, Arthas 3.1.2 version continued to add new features, focusing on the following:

  • logger/heapdump/vmoption/stopcommand
  • Connected to different networks by tunnel server arthas, to facilitate uniform control
  • Continue to improve ease of use: prompt changes to  arthas@pidthe form, to support  ctrl+kclear screen shortcuts

logger / heapdump / vmoption / stop command

logger command

View logger information, updates logger level

  • https://alibaba.github.io/arthas/logger.html

View all logger information

In the following logback.xmlexample:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <appender name="APPLICATION" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <file>app.log</file>
        <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
            <fileNamePattern>mylog-%d{yyyy-MM-dd}.%i.txt</fileNamePattern>
            <maxFileSize>100MB</maxFileSize>
            <maxHistory>60</maxHistory>
            <totalSizeCap>2GB</totalSizeCap>
        </rollingPolicy>
        <encoder>
            <pattern>%logger{35} - %msg%n</pattern>
        </encoder>
    </appender>

    <appender name="ASYNC" class="ch.qos.logback.classic.AsyncAppender">
        <appender-ref ref="APPLICATION" />
    </appender>

    <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
        <encoder>
            <pattern>%-4relative [%thread] %-5level %logger{35} - %msg %n
            </pattern>
            <charset>utf8</charset>
        </encoder>
    </appender>

    <root level="INFO">
        <appender-ref ref="CONSOLE" />
        <appender-ref ref="ASYNC" />
    </root>
</configuration>

Use loggerthe command print result:

[arthas@2062]$ logger
 name                                   ROOT
 class                                  ch.qos.logback.classic.Logger
 classLoader                            sun.misc.Launcher$AppClassLoader@2a139a55
 classLoaderHash                        2a139a55
 level                                  INFO
 effectiveLevel                         INFO
 additivity                             true
 codeSource                             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
                                        appenderRef     [APPLICATION]

From appendersinformation, we can see

  • CONSOLE The target is a logger System.out
  • APPLICATION logger is  RollingFileAppenderthat it is the file app.log
  • ASYNCIt's  appenderRefShi  APPLICATION, that is asynchronous output to a file

Check specify the name of the logger information

[arthas@2062]$ logger -n org.springframework.web
 name                                   org.springframework.web
 class                                  ch.qos.logback.classic.Logger
 classLoader                            sun.misc.Launcher$AppClassLoader@2a139a55
 classLoaderHash                        2a139a55
 level                                  null
 effectiveLevel                         INFO
 additivity                             true
 codeSource                             file:/Users/hengyunabc/.m2/repository/ch/qos/logback/logback-classic/1.2.3/logback-classic-1.2.3.jar

Update logger level

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

heapdump command

dump java heap, a heap dump command jmap similar function.

  • https://alibaba.github.io/arthas/heapdump.html

dump to the specified file

[arthas@58205]$ heapdump /tmp/dump.hprof
Dumping heap to /tmp/dump.hprof...
Heap dump file created

Just dump live objects

[arthas@58205]$ heapdump --live /tmp/dump.hprof
Dumping heap to /tmp/dump.hprof...
Heap dump file created

vmoption command

View, update-related diagnostic parameters VM

  • https://alibaba.github.io/arthas/vmoption.html

See all option

[arthas@56963]$ vmoption
 KEY                    VALUE                   ORIGIN                 WRITEABLE
---------------------------------------------------------------------------------------------
 HeapDumpBeforeFullGC   false                   DEFAULT                true
 HeapDumpAfterFullGC    false                   DEFAULT                true
 HeapDumpOnOutOfMemory  false                   DEFAULT                true
 Error
 HeapDumpPath                                   DEFAULT                true
 CMSAbortablePrecleanW  100                     DEFAULT                true
 aitMillis
 CMSWaitDuration        2000                    DEFAULT                true
 CMSTriggerInterval     -1                      DEFAULT                true
 PrintGC                false                   DEFAULT                true
 PrintGCDetails         true                    MANAGEMENT             true
 PrintGCDateStamps      false                   DEFAULT                true
 PrintGCTimeStamps      false                   DEFAULT                true
 PrintGCID              false                   DEFAULT                true
 PrintClassHistogramBe  false                   DEFAULT                true
 foreFullGC
 PrintClassHistogramAf  false                   DEFAULT                true
 terFullGC
 PrintClassHistogram    false                   DEFAULT                true
 MinHeapFreeRatio       0                       DEFAULT                true
 MaxHeapFreeRatio       100                     DEFAULT                true
 PrintConcurrentLocks   false                   DEFAULT                true

Check the specified option

[arthas@56963]$ vmoption PrintGCDetails
 KEY                    VALUE                   ORIGIN                 WRITEABLE
---------------------------------------------------------------------------------------------
 PrintGCDetails         false                   MANAGEMENT             true

Updates the specified option

[arthas@56963]$ vmoption PrintGCDetails true
Successfully updated the vm option.
PrintGCDetails=true

stop command

Before users Tucao, accidentally quit after Arthas console, shutdownwill shut down the system, because some increase in the stopcommand to exit arthas, function and shutdownuse the same command.

Connected to different networks by tunnel server arthas

  • https://alibaba.github.io/arthas/web-console.html

In the new version, it adds arthas tunnel server functionality, users can easily connect different networks in arthas agent through the tunnel server, suitable for unified management and control.

Start arthas when connected to a tunnel server

In the start arthas, you can pass --tunnel-serverparameters, such as:

as.sh --tunnel-server 'ws://47.75.156.201:7777/ws'
  1. as.sh --tunnel-server 'ws://47.75.156.201:7777/ws'

Currently 47.75.156.201is a test server, users can own? Build arthas tunnel server

  • If you have special needs, you can  --agent-idspecify parameters in agentId. By default, it will generate a random ID.

After successfully attach, it will print out agentId, such as:

  ,---.  ,------. ,--------.,--.  ,--.  ,---.   ,---.
 /  O  \ |  .--. ''--.  .--'|  '--'  | /  O  \ '   .-'
|  .-.  ||  '--'.'   |  |   |  .--.  ||  .-.  |`.  `-.
|  | |  ||  |\  \    |  |   |  |  |  ||  | |  |.-'    |
`--' `--'`--' '--'   `--'   `--'  `--'`--' `--'`-----'


wiki      https://alibaba.github.io/arthas
tutorials https://alibaba.github.io/arthas/arthas-tutorials
version   3.1.2
pid       86183
time      2019-08-30 15:40:53
id        URJZ5L48RPBR2ALI5K4V

If it is not connected to the tunnel server at startup, you may automatically reconnect after a subsequent successful, acquires agentId session command by: 

[arthas@86183]$ session
 Name           Value
-----------------------------------------------------
 JAVA_PID       86183
 SESSION_ID     f7273eb5-e7b0-4a00-bc5b-3fe55d741882
 AGENT_ID       URJZ5L48RPBR2ALI5K4V
 TUNNEL_SERVER  ws://47.75.156.201:7777/ws

To the above example, access in the browser http://47.75.156.201:8080/ , inputs agentId, you can connect to arthas on this machine.

Works of Arthas tunnel server 

browser <-> arthas tunnel server <-> arthas tunnel client <-> arthas agent

https://github.com/alibaba/arthas/blob/master/tunnel-server/README.md

Ease of use continue to improve

  • Prompt changes to  arthas@pidmisuse the form, the user can determine the current process ID, avoid multiple processes
[arthas@86183]$ help
  • Increasing the  ctrl+kclear screen shortcuts

to sum up

In short, the 3.1.2version of Arthas adds new logger/heapdump/vmoption/stoporders to increase the tunnel server, to facilitate unified management and control. There are also a number of bug fixes, etc., can refer to

  • Release Note: https://github.com/alibaba/arthas/releases/tag/3.1.2

Finally, Arthas online tutorials consider re-organization, we welcome participation, suggestions:

  • https://github.com/alibaba/arthas/issues/847

Guess you like

Origin www.oschina.net/news/109728/arthas-3-1-2-released