Sosreport 工具

您目前查看的是 Apigee Edge 說明文件。
前往 Apigee X 說明文件
info

Sosreport 是系統層級的診斷和資料收集工具,以開放原始碼軟體 SoS 為基礎。您可以使用 Sosreport 工具收集資訊,協助您在執行 Apigee 元件的節點中偵錯。這項工具會收集資訊,並儲存在節點的檔案系統本機。

Sosreport 工具會從系統收集設定詳細資料、系統資訊和診斷資訊,並將資料儲存在封存檔中。針對 Apigee 元件,Sosreport 會收集下列資料:

  • 正在執行的核心版本
  • 已載入的模組
  • 系統和服務設定檔

Sosreport 也會執行外部程式來蒐集更多資訊,包括:

  • 所有元件的 Apigee 記錄。
  • 執行階段診斷
  • 使用 nodetool 指令收集的 Cassandra 診斷資訊。

Sosreport 工具包含兩個主要指令:

  • sosreport:收集資料及建立報表的主要指令。
  • apigee-sosreport:輔助工具,用於安裝及管理 Apigee 元件專用的 sosreport 外掛程式。sosreport

安裝

本節說明如何安裝 sosreport

如果已安裝 SoS 版本的 sosreport

如果系統已安裝原始的 SoSsosreport,請不要設定 Apigee 版本,因為安裝路徑可能會衝突。請改為使用下列指令,將 Apigee 專屬外掛程式從 /opt/apigee/apigee-sosreport/source/plugin 目錄複製到適當的 Python site-packages 目錄。舉例來說,如要複製 agigee-mgmt.py,請按照下列步驟操作:

  • 如果您使用 Python 2,請輸入:
    sudo cp apigee-mgmt.py /usr/lib/python2.7/site-packages/sos/plugins/
  • 如果您使用 Python 3,請輸入:
    sudo cp apigee-mgmt.py /usr/local/lib/python3.6/site-packages/sos/plugins/

如要確認外掛程式是否已安裝,請輸入

sudo sosreport --list-plugins

如有任何問題,請與 Apigee 支援團隊聯絡。

安裝 Apigee 版本的 sosreport

如果系統尚未安裝 SoS 版本的 sosreport,您可以在安裝 Edge for Private Cloud 的所有節點上輸入下列指令,安裝 Apigee 版本:

/opt/apigee/apigee-service/bin/apigee-service apigee-sosreport install
/opt/apigee/apigee-service/bin/apigee-service apigee-sosreport setup

如要測試 sosreport 是否已安裝,請確認與 Apigee 相關的外掛程式位於下列目錄:

/usr/lib/pythonx.x/site-packages/sos/plugins

其中 pythonx.x 是您安裝的 Python 版本。

或者,您也可以執行下列其中一個指令:

  • 如要只驗證 Apigee 專屬外掛程式:
    apigee-service apigee-sosreport diagnose -l

    這會傳回下列 Apigee 專屬外掛程式清單。

    sosreport (version 3.9)
    
    The following plugins are currently enabled:
    
    apigee-mgmt          This is the apigee plugin for edge-management-server
    apigee-mp            This is the apigee plugin for edge-message-processor
    apigee-rrt           This is the apigee plugin for edge-router
    apigee-sample        Main diagnostics gatehring class
  • 如要驗證所有外掛程式:
    apigee-service apigee-sosreport diagnose -s -l

    這會傳回 sosreport 可用的外掛程式清單,如下所示:

    sosreport (version 3.9)
    
    The following plugins are currently enabled:
    
     acpid                ACPI daemon information
     alternatives         System alternatives
     anacron              Anacron job scheduling service
     apigee-cassandra     This is the base class for sosreport plugins. Plugins should subclass
        this and set the class variables where applicable. ←truncated→
     apigee-mgmt          This is the base class for sosreport plugins. Plugins should subclass
        this and set the class variables where applicable. ←truncated→
     apigee-mp            Main diagnostics gathering class
     apigee-rrt           This is the base class for sosreport plugins. Plugins should subclass
        this and set the class variables where applicable. ←truncated→
    
    ………………………………………………….
    ………………………………………………….
    ………………………………………………….
    ←truncated→

建立報表

如要使用 Sosreport 工具建立報表,請執行 sosreport 指令,並提供必要的外掛程式選項 (請參閱「Apigee 外掛程式」)。報表的預設儲存目錄為 tmp/var/tmp。如要變更報表的儲存目錄,請將其他目錄傳遞至 tmp-dir 選項。舉例來說,如要在管理伺服器上建立報表,並將報表儲存至名為 my_report-dir 的目錄,請輸入下列其中一個指令:

  • 使用 Apigee 版本的 sosreport
    sudo sosreport --config-file /opt/apigee/apigee-sosreport/conf/sos.conf -o apigee-mgmt  --batch --tmp-dir=my_report-dir
  • 使用 SoS 版本的 sosreport:
    sudo sosreport -o apigee-mgmt  --batch --tmp-dir=my_report-dir

報表會儲存在您使用 tmp-dir 選項指定的目錄中,並以 .tar.xz 檔案的形式呈現。.tar.xz 檔案的位置會顯示在 STDOUT 上,以及總和檢查碼。例如:

Your sosreport has been generated and saved in:
 /var/sosreport-prc-test-0-9613-2021-07-12-orwxufx.tar.xz
The checksum is: 5a8b97c6020346a688254c8b04ef86ec
For more available options for sosreport, read the man file:
sudo man sosreport

報表會儲存在您使用 tmp-dir 選項指定的目錄中,並以 .tar.xz 檔案的形式呈現。.tar.xz file 的位置會顯示在 STDOUT 上,以及檢查碼。例如:

如要進一步瞭解 sosreport 的可用選項,請參閱 man 檔案:

sudo man sosreport

Apigee 外掛程式

以下各節說明 Sosreport 工具的 Apigee 外掛程式,適用於下列元件:

管理伺服器

apigee-mgmt 外掛程式會從管理伺服器收集下列資訊:

  • 伺服器主機名稱 (預設)
  • cpuinfo (預設)
  • meminfo (預設)
  • Java 虛擬機器 (JVM) 設定,例如記憶體、Djdk.tls.allowUnsafeServerCertChange 等 (預設)
  • 目前的管理記錄 (預設)
  • 十個連續的 top 和 jstacks 輸出 (預設)
  • 整個管理記錄資料夾 (選用)
  • config-files (選用)

範例:

如要收集所有預設項目,請輸入下列任一指令:

  • 使用 Apigee 版本的 sosreport
    sudo sosreport --config-file /opt/apigee/apigee-sosreport/conf/sos.conf  -o apigee-mgmt --batch my_report-dir
  • 使用 SoS 版 sosreport
    sudo sosreport -o apigee-mgmt --batch my_report-dir

如要收集所有預設項目,以及指令中指定的選用項目(例如設定檔和所有記錄),請輸入下列任一指令:

  • 使用 Apigee 版本的 sosreport
    sudo sosreport --config-file /opt/apigee/apigee-sosreport/conf/sos.conf  -o apigee-mgmt --batch -k apigee-mgmt.config-files -k apigee-mgmt.all-logs
  • 使用 SoS 版 sosreport
    sudo sosreport -o apigee-mgmt --batch -k apigee-mgmt.config-files -k apigee-mgmt.all-logs

如要收集所有項目,請輸入下列任一項:

  • 使用 Apigee 版本的 sosreport
    sudo sosreport --config-file /opt/apigee/apigee-sosreport/conf/sos.conf  -o apigee-mgmt --batch -k apigee-mgmt.config-files -k apigee-mgmt.all-logs

    或者,您也可以輸入:

    sudo sosreport --config-file /opt/apigee/apigee-sosreport/conf/sos.conf  -o apigee-mgmt --batch -a
  • 使用 SoS 版 sosreport
    sudo sosreport -o apigee-mgmt --batch -k apigee-mgmt.config-files -k apigee-mgmt.all-logs

    或者,也可以輸入:

    sudo sosreport -o apigee-mgmt --batch -a

訊息處理器

apigee-mp 外掛程式會從管理處理器 (MP) 收集下列資訊:

  • 伺服器主機名稱 (預設)
  • cpuinfo (預設)
  • meminfo (預設)
  • buildinfo/release info (預設)
  • apigee-all 狀態 (預設)
  • 伺服器詳細資料 (預設)
  • JVM 層級設定,例如記憶體、Djdk.tls.allowUnsafeServerCertChange等 (預設)
  • 目前 MP 記錄 (預設)
  • 連續輸出 10 個頂端、jstack 和 NIO 指標 (預設)
  • 整個 MP 記錄資料夾 (選用)
  • 分類樹 (選用)
  • 記憶體快照資料 (選用)
  • config-files (選用)
  • 執行階段追蹤記錄 (選用,僅在提供 org:env:api:rev detail 時適用)。注意:外掛程式會等待 25 秒,收集執行階段要求。

範例:

如要收集所有預設項目,請輸入下列任一指令:

  • 使用 Apigee 版本的 sosreport
    sudo sosreport --config-file /opt/apigee/apigee-sosreport/conf/sos.conf  -o apigee-mp --batch
  • 使用 SoS 版 sosreport
    sudo sosreport -o apigee-mp --batch

除了所有預設項目外,您也可以指定要收集的其他選用項目。 舉例來說,如要使用 -k apigee-mp.heap 旗標指定堆積傾印,請輸入下列其中一項:

  • 使用 Apigee 版本的 sosreport
    sudo sosreport --config-file /opt/apigee/apigee-sosreport/conf/sos.conf  -o apigee-mp --batch -k apigee-mp.heap
  • 使用 SoS 版 sosreport
    sudo sosreport -o apigee-mp --batch -k apigee-mp.heap

同樣地,您也可以指定下列選用項目:

-k apigee-mp.deployments
-k apigee-mp.heap
-k apigee-mp.all-logs
-k apigee-mp.config-files
-k apigee-mp.trace=gsc-cps:test:httpbin:3

您可以在單一指令中指定多個選項。例如:

  • 使用 Apigee 版本的 sosreport
    sudo sosreport --config-file /opt/apigee/apigee-sosreport/conf/sos.conf  -o apigee-mp --batch -k apigee-mp.deployments -k apigee-mp.all-logs
  • 使用 SoS 版 sosreport
    sudo sosreport -o apigee-mp --batch -k apigee-mp.deployments -k apigee-mp.all-logs

如要收集所有內容 (追蹤記錄除外),請輸入下列其中一項:

  • 使用 Apigee 版本的 sosreport
    sudo sosreport --config-file /opt/apigee/apigee-sosreport/conf/sos.conf  -o apigee-mp --batch -a
  • 使用 SoS 版 sosreport
    sudo sosreport -o apigee-mp --batch -a

路由器

apigee-rrt 外掛程式會從路由器收集下列資訊:

  • 伺服器主機名稱 (預設)
  • cpuinfo (預設)
  • meminfo (預設)
  • buildinfo/release info (預設)
  • apigee-all 狀態 (預設)
  • 伺服器詳細資料 (預設)
  • ps 輸出內容。這會提供 JVM 層級設定,例如記憶體、Djdk.tls.allowUnsafeServerCertChange 等等 (預設)。
  • 目前路由器記錄 (預設)
  • 虛擬主機檔案名稱清單,包括錯誤的檔案名稱 (預設)
  • 整個路由器記錄資料夾 (選用)
  • config-files (選用)

範例:

如要收集所有預設項目,請輸入下列任一指令:

  • 使用 Apigee 版本的 sosreport
    sudo sosreport --config-file /opt/apigee/apigee-sosreport/conf/sos.conf  -o apigee-rrt --batch
  • 使用 SoS 版 sosreport
    sudo sosreport -o apigee-rrt --batch

除了所有預設項目外,您也可以指定要收集的其他選用項目。 舉例來說,如要使用 -k apigee-rrt.all-logs 旗標指定整個記錄資料夾,請輸入下列其中一個指令:

  • 使用 Apigee 版本的 sosreport
    sudo sosreport --config-file /opt/apigee/apigee-sosreport/conf/sos.conf  -o apigee-rrt --batch -k apigee-rrt.all-logs
  • 使用 SoS 版 sosreport
    sudo sosreport -o apigee-rrt --batch -k apigee-rrt.all-logs

同樣地,您也可以指定下列選用項目:

-k apigee-rrt.all-logs
-k apigee-rrt.config-files

如要收集所有內容,請按照下列步驟操作:

  • 使用 Apigee 版本的 sosreport
    sudo sosreport --config-file /opt/apigee/apigee-sosreport/conf/sos.conf  -o apigee-rrt --batch -a
  • 使用 SoS 版 sosreport
    sudo sosreport -o apigee-rrt --batch -a

Cassandra

apigee-cassandra 外掛程式會從 Cassandra 節點收集下列資訊:

  • 機器統計資料:
    "hostname -i"
    "cat /proc/cpuinfo"
    "cat /proc/meminfo"
    "ulimit -a"
    "ps auxw"
    "df -kh"
    "du -sh"
    "netstat -ntlpu"
    "free -h"
    "ifconfig -h"
    "ps -ef"
  • Apigee 元件的狀態和版本 apigee-all version && apigee-all status
  • apigee-cassandra 記錄: /opt/apigee/var/log/apigee-cassandra/ 下的所有檔案
  • 提交記錄計數
  • Top 指令的輸出內容
  • 執行緒傾印
  • 設定檔:cassandra-topology.propertiescassandra.yamlcassandra-env.sh
  • 下列參數的節點工具輸出內容:version、status、ring、info、gossipinfo、compactionstats -H、tpstats、netstats、cfstats、proxyhistograms

範例:

如要收集所有預設項目,請輸入下列任一指令:

  • 使用 Apigee 版本的 sosreport
    sudo sosreport --config-file /opt/apigee/apigee-sosreport/conf/sos.conf  -o apigee-cassandra
  • 使用 SoS 版 sosreport
    sudo sosreport -o apigee-cassandra