Sosreport:收集系統日誌和診斷信息的工具

Sosreport:收集系統日誌和診斷信息的工具

編譯自: https://www.ostechnix.com/sosreport-a-tool-to-collect-system-logs-and-diagnostic-information/

如果你是 RHEL 管理員,你可能肯定聽說過 Sosreport :一個可擴展、可移植的支持數據收集工具。它是一個從類 Unix 操作系統中收集系統配置詳細信息和診斷信息的工具。當用戶提出支持服務單時,他/她必須運行此工具並將由 Sosreport 工具生成的結果報告發送給 Red Hat 支持人員。然後,執行人員將根據報告進行初步分析,並嘗試找出系統中的問題。不僅在 RHEL 系統上,你可以在任何類 Unix 操作系統上使用它來收集系統日誌和其他調試信息。

安裝 Sosreport

Sosreport 在 Red Hat 官方系統倉庫中,因此你可以使用 Yum 或 DNF 包管理器安裝它,如下所示。

$ sudo yum install sos

要麼,

$ sudo dnf install sos

在 Debian、Ubuntu 和 Linux Mint 上運行:

$ sudo apt install sosreport

用法

安裝後,運行以下命令以收集系統配置詳細信息和其他診斷信息。

$ sudo sosreport

系統將要求你輸入系統的一些詳細信息,例如系統名稱、案例 ID 等。相應地輸入詳細信息,然後按回車鍵生成報告。如果你不想更改任何內容並使用默認值,只需按回車鍵即可。

我的 CentOS 7 服務器的示例輸出:

sosreport (version 3.5)

This command will collect diagnostic and configuration information from

this CentOS Linux system and installed applications.

An archive containing the collected information will be generated in

/var/tmp/sos.DiJXi7 and may be provided to a CentOS support

representative.

Any information provided to CentOS will be treated in accordance with

the published support policies at:

https://wiki.centos.org/

The generated archive may contain data considered sensitive and its

content should be reviewed by the originating organization before being

passed to any third party.

No changes will be made to system configuration.

Press ENTER to continue, or CTRL-C to quit.

Please enter your first initial and last name [server.ostechnix.local]:

Please enter the case id that you are generating this report for []:

Setting up archive ...

Setting up plugins ...

Running plugins. Please wait ...

Running 73/73: yum...

Creating compressed archive...

Your sosreport has been generated and saved in:

/var/tmp/sosreport-server.ostechnix.local-20180628171844.tar.xz

The checksum is: 8f08f99a1702184ec13a497eff5ce334

Please send this file to your support representative.

如果你不希望系統提示你輸入此類詳細信息,請如下使用批處理模式。

$ sudo sosreport --batch

正如你在上面的輸出中所看到的,生成了一個歸檔報告並保存在 /var/tmp/sos.DiJXi7 中。在 RHEL 6/CentOS 6 中,報告將在 /tmp 中生成。你現在可以將此報告發送給你的支持人員,以便他可以進行初步分析並找出問題所在。

你可能會擔心或想知道報告中的內容。如果是這樣,你可以通過運行以下命令來查看它:

$ sudo tar -tf /var/tmp/sosreport-server.ostechnix.local-20180628171844.tar.xz

要麼,

$ sudo vim /var/tmp/sosreport-server.ostechnix.local-20180628171844.tar.xz

請注意,上述命令不會解壓存檔,而只顯示存檔中的文件和文件夾列表。如果要查看存檔中文件的實際內容,請首先使用以下命令解壓存檔:

$ sudo tar -xf /var/tmp/sosreport-server.ostechnix.local-20180628171844.tar.xz

存檔的所有內容都將解壓當前工作目錄中 ssosreport-server.ostechnix.local-20180628171844/ 目錄中。進入目錄並使用 cat 命令或任何其他文本瀏覽器查看文件內容:

$ cd sosreport-server.ostechnix.local-20180628171844/

$ cat uptime

17:19:02 up 1:03, 2 users, load average: 0.50, 0.17, 0.10

有關 Sosreport 的更多詳細信息,請參閱手冊頁。

$ man sosreport

就是這些了。希望這些有用。還有更多好東西。敬請關注!

乾杯!


via: https://www.ostechnix.com/sosreport-a-tool-to-collect-system-logs-and-diagnostic-information/

作者: SK 選題: lujun9972 譯者: geekpi 校對: wxy

本文由 LCTT 原創編譯, Linux中國 榮譽推出


分享到:


相關文章: