Sosreport:收集Unix系統(tǒng)日志和診斷信息的工具
如果你是 RHEL 管理員,你可能肯定聽說過 Sosreport :一個可擴(kuò)展、可移植的支持?jǐn)?shù)據(jù)收集工具。它是一個從類 Unix 操作系統(tǒng)中收集系統(tǒng)配置詳細(xì)信息和診斷信息的工具。當(dāng)用戶提出支持服務(wù)單時,他/她必須運(yùn)行此工具并將由 Sosreport 工具生成的結(jié)果報告發(fā)送給 Red Hat 支持人員。然后,執(zhí)行人員將根據(jù)報告進(jìn)行初步分析,并嘗試找出系統(tǒng)中的問題。不僅在 RHEL 系統(tǒng)上,你可以在任何類 Unix 操作系統(tǒng)上使用它來收集系統(tǒng)日志和其他調(diào)試信息。
安裝 Sosreport
Sosreport 在 Red Hat 官方系統(tǒng)倉庫中,因此你可以使用 Yum 或 DNF 包管理器安裝它,如下所示。
$ sudo yum install sos
要么,
$ sudo dnf install sos
在 Debian、Ubuntu 和 Linux Mint 上運(yùn)行:
$ sudo apt install sosreport
用法
安裝后,運(yùn)行以下命令以收集系統(tǒng)配置詳細(xì)信息和其他診斷信息。
$ sudo sosreport
系統(tǒng)將要求你輸入系統(tǒng)的一些詳細(xì)信息,例如系統(tǒng)名稱、案例 ID 等。相應(yīng)地輸入詳細(xì)信息,然后按回車鍵生成報告。如果你不想更改任何內(nèi)容并使用默認(rèn)值,只需按回車鍵即可。
我的 CentOS 7 服務(wù)器的示例輸出:
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.
如果你不希望系統(tǒng)提示你輸入此類詳細(xì)信息,請如下使用批處理模式。
$ sudo sosreport --batch
正如你在上面的輸出中所看到的,生成了一個歸檔報告并保存在 /var/tmp/sos.DiJXi7
中。在 RHEL 6/CentOS 6 中,報告將在 /tmp
中生成。你現(xiàn)在可以將此報告發(fā)送給你的支持人員,以便他可以進(jìn)行初步分析并找出問題所在。
你可能會擔(dān)心或想知道報告中的內(nèi)容。如果是這樣,你可以通過運(yùn)行以下命令來查看它:
$ sudo tar -tf /var/tmp/sosreport-server.ostechnix.local-20180628171844.tar.xz
要么,
$ sudo vim /var/tmp/sosreport-server.ostechnix.local-20180628171844.tar.xz
請注意,上述命令不會解壓存檔,而只顯示存檔中的文件和文件夾列表。如果要查看存檔中文件的實(shí)際內(nèi)容,請首先使用以下命令解壓存檔:
$ sudo tar -xf /var/tmp/sosreport-server.ostechnix.local-20180628171844.tar.xz
存檔的所有內(nèi)容都將解壓當(dāng)前工作目錄中 ssosreport-server.ostechnix.local-20180628171844/
目錄中。進(jìn)入目錄并使用 cat
命令或任何其他文本瀏覽器查看文件內(nèi)容:
$ cd sosreport-server.ostechnix.local-20180628171844/
$ cat uptime
17:19:02 up 1:03, 2 users, load average: 0.50, 0.17, 0.10
有關(guān) Sosreport 的更多詳細(xì)信息,請參閱手冊頁。
$ man sosreport
就是這些了。希望這些有用。還有更多好東西。敬請關(guān)注!