SOSreport - 收集系统日志和诊断信息的工具

时间:2020-03-21 11:47:18  来源:igfitidea点击:

如果我们正在作为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等。
相应地键入详细信息,然后按Enter键生成报告。
如果我们不想更改任何内容并希望使用默认值,只需按Enter键。

来自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 Jan 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 Jan 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.theitroad.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.theitroad.local-20160628171844.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.theitroad.local-20160628171844.tar.xz

或者,

$sudo vim /var/tmp/sosreport-server.theitroad.local-20160628171844.tar.xz

请注意,上面的命令不会提取存档,但仅显示存档中的文件和文件夹列表。
如果要查看存档中文件的实际内容,请使用命令首先提取存档:

$sudo tar -xf /var/tmp/sosreport-server.theitroad.local-20160628171844.tar.xz

存档的所有内容将在当前工作目录中的名为"sosreport-server.theitroad.local-20160628171844 /"的目录中提取。
转到目录并使用CAT命令或者任何其他文本查看器查看任何文件的内容:

$cd sosreport-server.theitroad.local-20160628171844/
$cat uptime 
17:19:02 up 1:03, 2 users, load average: 0.50, 0.17, 0.10

有关SOSreport的更多详细信息,请参阅MAN页面。

$man sosreport