0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

tWASのdiagnostic plans(診断計画)を用いたトレース取得。指定のメッセージがWASのログファイルに出力されたらトレース・バッファーをダンプして、トレース取得を停止する。

0
Posted at

WebSphere Application Serverのdiagnostic plansを用いて、指定のメッセージがWASのログ・ファイルに出力されたらトレース・バッファーをダンプして、トレース取得を停止する動作を検証しました。

トレース出力をメモリーに保管する場合、診断トレース・サービス設定 - IBM Documentationに記載の手順で、管理コンソールからランタイム・ページにある「ダンプ」ボタンを使用してファイルに書き込む必要があります。
diagnostic plansでは DUMPBUFFERアクションで自動的にファイルに書き込みます。

tWASの以下の文書を参考にしました。

Diagnostic plan action scripts - IBM Documentation
The following example uses the SET_TRACESPEC, MATCH, and DUMPBUFFER actions to collect data when the trace file gets the CWLDD0055I message.
和訳 : 次の例では、SET_TRACESPEC、MATCH、およびDUMPBUFFERアクションを使用して、トレースファイルがCWLDD0055Iメッセージを受信した際にデータを収集します。

SET_TRACESPEC=*=info:com.ibm.ws.*=finer,
MATCH=TRACE:CWLDD0055I*;TRACE:application deployment service is stopped *,
DUMPBUFFER

注: マニュアル記載の CWLDD0055I は、
CWLDD - IBM Documentation
に存在しないメッセージIDです。CWLDD0005I の誤記と思われます(未検証)。

CWLDD0005I: Monitored directory application deployment service is stopped.

検証の手順と結果

1. トレース出力をメモリー・バッファに設定します

メモリー・バッファ・サイズは環境に応じて値を設定してください。
image.png

2. トレース仕様は未設定(*=infoのまま)とします

RESTORE_TRACESPECではこのトレース仕様にリストアされることになります。
image.png

3. Diagnostic plan action scriptsの実行

以下のように指定しています

  • SET_TRACESPEC トレース仕様 *=info:HTTPChannel=all:TCPChannel=all:GenericBNF=all
  • MATCH=TRACE:SRVE0242I* : SRVE0242I*が出力されたら
  • DUMPBUFFER : トレース・バッファー・ダンプを要求する
  • RESTORE_TRACESPEC : ランタイム・トレース仕様を、デバッグ計画の開始時に存在していた値に変更する
$ ./wsadmin.sh -lang jython -username wsadmin -password .........
WASX7209I: Connected to process "server1" on node DefaultNode01 using SOAP connector;  The type of process is: UnManagedProcess
WASX7031I: For help, enter: "print Help.help()"
wsadmin>AdminControl.invoke_jmx(AdminControl.makeObjectName(AdminControl.queryNames("WebSphere:type=DiagPlanManager,process=server1,*")),"setDiagPlan",["SET_TRACESPEC=*=info:HTTPChannel=all:TCPChannel=all:GenericBNF=all,MATCH=TRACE:SRVE0242I*,DUMPBUFFER,RESTORE_TRACESPEC"], ["java.lang.String"])

4. SystemOut.logに以下が出力されます

トレース仕様が変更されて、トレース出力が循環メモリー・バッファーに保管されます。

[7/28/26 5:33:24:540 UTC] 000000b7 ManagerAdmin  I   TRAS0018I: The trace state has changed. The new trace state is *=info:HTTPChannel=all:TCPChannel=all:GenericBNF=all.
[7/28/26 5:33:24:556 UTC] 000000b7 ManagerAdmin  I   TRAS0028I: The trace output is stored in the circular memory buffer, holding 102400 message objects.

5. 意図的に SRVE0242I のメッセージが出る処理を実行します

JSPを実行

[7/28/26 5:34:22:920 UTC] 0000007f ServletWrappe I com.ibm.ws.webcontainer.servlet.ServletWrapper init SRVE0242I: [db_connections] [/db.connections] [/sessionId.jsp]: Initialization successful.

6. SystemOut.logに以下が出力されます

トレース・バッファーがダンプされて、トレース仕様が元に戻ります。

[7/28/26 5:34:22:922 UTC] 0000007f MatchAction   I   TRAS1100I: A match was found for the following MATCH action trace string: SRVE0242I*
[7/28/26 5:34:23:008 UTC] 000000b7 DumpBufferAct I   TRAS1106I: DUMPBUFFER action completed. The generated trace buffer dump file is at /opt/IBM/WebSphere/AppServer/profiles/AppSrv01/logs/server1/traceDump_26.07.28_05.34.22.log.
[7/28/26 5:34:23:028 UTC] 000000b7 ManagerAdmin  I   TRAS0018I: The trace state has changed. The new trace state is *=info.
[7/28/26 5:34:23:030 UTC] 000000b7 ManagerAdmin  I   TRAS0028I: The trace output is stored in the circular memory buffer, holding 102400 message objects.

7. TRAS1106Iにあるファイルにトレースが出力されています

$ tail -f /opt/IBM/WebSphere/AppServer/profiles/AppSrv01/logs/server1/traceDump_26.07.28_05.34.22.log
...
[7/28/26 5:34:22:946 UTC] 000000b7 HttpRequestMe 3   getAllCookies: Found 12 instances
[7/28/26 5:34:22:947 UTC] 000000b7 BNFHeadersImp 3   getHeaderAsString(b,i): Content-Type [text/html; charset=UTF-8]

補足

  • SRVE0242Iを指定したのはあくまでテスト目的です。調査する事象のメッセージに置き換えて実行してください。なお、事象以外でも頻繁に出力されるメッセージを指定しても無意味です。
  • setDiagPlan.pyというファイル名に保管して実行してみました。検証で1行にまとめていたのと、やってることは同じです。
plan = ",".join([
    "SET_TRACESPEC=*=info:HTTPChannel=all:TCPChannel=all:GenericBNF=all",
    "MATCH=TRACE:SRVE0242I*",
    "DUMPBUFFER",
    "RESTORE_TRACESPEC"
])
AdminControl.invoke_jmx(
    AdminControl.makeObjectName(AdminControl.queryNames("WebSphere:type=DiagPlanManager,process=server1,*")),
    "setDiagPlan",
    [plan],
    ["java.lang.String"]
)
$ /opt/IBM/WebSphere/AppServer/profiles/AppSrv01/bin/wsadmin.sh -lang jython -username wsadmin -password ....... -f /tmp/setDiagPlan.py
  • ダンプして以下の出力になっていたら、Ring Buffer tracingが無効になっています。手順に間違いがないか、ご確認ください。
[7/28/26 4:30:45:067 UTC] 000000b2 ManagerAdmin  1   Ring Buffer tracing has been disabled. Nothing to dump.
  • 上記の検証では、SRVE0242Iが出力されてすぐにトレース仕様が *=infoに設定されて、トレース取得が停止してます。トレース取得停止が早すぎる(メッセージ出力後も資料収集が必要)という場合はDELAYを設定するとよいでしょう。
wsadmin>AdminControl.invoke_jmx(AdminControl.makeObjectName(AdminControl.queryNames("WebSphere:type=DiagPlanManager,process=server1,*")),"setDiagPlan",["SET_TRACESPEC=*=info:HTTPChannel=all:TCPChannel=all:GenericBNF=all,MATCH=TRACE:SRVE0242I*,DELAY=10,DUMPBUFFER,RESTORE_TRACESPEC"], ["java.lang.String"])

DELAY=10を設定すると、10秒後にトレース仕様がリストアされます。
SystemOut.log

[7/28/26 5:52:59:601 UTC] 00000082 ServletWrappe I com.ibm.ws.webcontainer.servlet.ServletWrapper init SRVE0242I: [ds-injection-test_war] [/ds-injection-test] [/testJndi.jsp]: Initialization successful.
[7/28/26 5:52:59:603 UTC] 00000082 MatchAction   I   TRAS1100I: A match was found for the following MATCH action trace string: SRVE0242I*
<-- 10秒後にトレース仕様が元に戻る -->
[7/28/26 5:53:09:784 UTC] 000000b8 DumpBufferAct I   TRAS1106I: DUMPBUFFER action completed. The generated trace buffer dump file is at /opt/IBM/WebSphere/AppServer/profiles/AppSrv01/logs/server1/traceDump_26.07.28_05.53.09.log.
[7/28/26 5:53:09:798 UTC] 000000b8 ManagerAdmin  I   TRAS0018I: The trace state has changed. The new trace state is *=info.
[7/28/26 5:53:09:802 UTC] 000000b8 ManagerAdmin  I   TRAS0028I: The trace output is stored in the circular memory buffer, holding 102400 message objects.
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?