Arthasは3.1.2増加ロガー/ heapdumpコマンド、支援トンネルサーバー

Arthasは

ArthasJavaは、診断ツールアリババオープンソースであり、Arthasは3.1.2バージョンでは、以下に焦点を当て、新しい機能を追加し続けて:

  • logger/heapdump/vmoption/stopコマンド
  • 均一な制御を容易にするために、トンネルサーバArthasはによって異なるネットワークに接続されています
  • 使いやすさを向上させるために続行:プロンプトが  arthas@pidフォーム、サポートするための  ctrl+k明確なスクリーンのショートカットを

ロガー/ heapdump /のVMOption /停止命令

loggerコマンド

ビューロガー情報は、ロガーのレベルを更新します

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

すべてのロガーの情報を見ます

以下にlogback.xml例を示します。

<?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>

使用するloggerコマンドは、印刷結果を:

[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]

以下からappendersの情報は、我々は見ることができます

  • CONSOLE ターゲットはロガーです System.out
  • APPLICATION ロガーは、  RollingFileAppenderそれがファイルであること app.log
  • ASYNCそれはだ  appenderRef石  APPLICATION、それがファイルに非同期で出力されます

ロガー情報の名前を指定するチェック

[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

更新ロガーレベル

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

heapdumpコマンド

Javaヒープ、ヒープ・ダンプコマンドjmapの同様の機能をダンプします。

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

指定されたファイルにダンプ

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

ただ、ライブオブジェクトをダンプ

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

VMOptionコマンド

ビュー、アップデート関連の診断パラメータVM

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

すべてのオプションを参照してください

[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

指定されたオプションをチェック

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

指定されたオプションを更新します

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

コマンドを停止

ユーザーTucaoする前に、誤ってArthasはコンソールの後に終了し、shutdown中にいくつかの増加があるため、システムをシャットダウンしますstopコマンドがArthasはを終了し、機能とshutdown同じコマンドを使用します。

トンネルサーバArthasはによって異なるネットワークに接続されています

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

新しいバージョンでは、それはトンネルサーバ機能Arthasは追加し、ユーザが容易に一元管理し、制御するのに適した、トンネルサーバーを介してArthasはエージェントに異なるネットワークを接続することができます。

トンネルサーバに接続したときにArthasはを開始します

スタートArthasはでは、あなたが渡すことができます--tunnel-server次のようなパラメータを、

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

現在、47.75.156.201テストサーバーは、ユーザーが所有することができますか?Arthasはトンネルサーバーを構築します

  • あなたは特別なニーズを持っている場合は、次のことができ  --agent-idagentIdがでパラメータを指定します。デフォルトでは、ランダムなIDが生成されます。

:首尾よく取り付けた後、それはのような、agentIdがプリントアウトされます

  ,---.  ,------. ,--------.,--.  ,--.  ,---.   ,---.
 /  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

それは、起動時にトンネルサーバに接続されていない場合は、自動的に、その後の成功の後に再接続することにより、agentIdがsessionコマンドを取得: 

[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

上記の例には、ブラウザでアクセスhttp://47.75.156.201:8080/は、入力はagentId、あなたがこのマシン上Arthasはに接続することができます。

Arthasはトンネルサーバの作品 

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

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

使いやすさを改善し続けます

  • プロンプトが変化するため  arthas@pid、フォームを誤用、ユーザが現在のプロセスIDを決定することができ、複数のプロセスを避けます
[arthas@86183]$ help
  • 増加  ctrl+k明確な画面のショートカットを

概要

要するに、3.1.2Arthasはのバージョンは、新しい追加logger/heapdump/vmoption/stop一元管理と制御を容易にするため、トンネルサーバーを高めるために注文を。等のバグ修正の数が参照することができ、もあります

  • リリースノート:https://github.com/alibaba/arthas/releases/tag/3.1.2

最後に、Arthasはオンラインチュートリアルは、私たちが参加、提案を歓迎し、再編成を検討してください。

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

おすすめ

転載: www.oschina.net/news/109728/arthas-3-1-2-released