云网牛站
所在位置:首页 > Linux常用命令大全 > 更多实用命令 > sosreport命令

sosreport命令

sosreport命令用于收集系统配置并诊断信息后输出结论文档。当Linux系统出现故障需要联系红帽厂商或其他技术支持时,大多数时候都要先使用这个SOS功能来简单收集计算机的运行状态和服务配置信息,以便让技术支持公司能够通过远程就解决了一些小问题,又或者让他们能对复杂问题能提前有些了解。

语法

sosreport

参数

--help:运行sosreport --help查看帮助信息。以下是输出信息:

[root@ywnz ~]# sosreport --help
Usage: sosreport [options]
Options:
-h, --help            show this help message and exit
-l, --list-plugins    list plugins and available plugin options
-n NOPLUGINS, --skip-plugins=NOPLUGINS
disable these plugins
-e ENABLEPLUGINS, --enable-plugins=ENABLEPLUGINS
enable these plugins
-o ONLYPLUGINS, --only-plugins=ONLYPLUGINS
enable these plugins only
-k PLUGOPTS, --plugin-option=PLUGOPTS
plugin options in plugname.option=value format (see
-l)
-a, --alloptions      enable all options for loaded plugins
--batch               batch mode - do not prompt interactively
--build               keep sos tree available and dont package results
-v, --verbose         increase verbosity
--quiet               only print fatal errors
--debug               enable interactive debugging using the python debugger
--ticket-number=TICKET_NUMBER
specify ticket number
--name=CUSTOMER_NAME  specify report name
--config-file=CONFIG_FILE
specify alternate configuration file
--tmp-dir=TMP_DIR     specify alternate temporary directory
--report              Enable HTML/XML reporting
--profile             turn on profiling
-z COMPRESSION_TYPE, --compression-type=COMPRESSION_TYPE
compression technology to use [auto, zip, gzip, bzip2,
xz] (default=auto)
Some examples:
enable cluster plugin only and collect dlm lockdumps:
# sosreport -o cluster -k cluster.lockdump
disable memory and samba plugins, turn off rpm -Va collection:
# sosreport -n memory,samba -k rpm.rpmva=off

sosreport的安装

不同的Linux版本安装方法不同,下面以redhat/centos/ubuntu为例说明安装方法。

在redhat/centos下的安装
# yum -y insatll sos

在ubuntu下的安装
# sudo apt-get install sosreport

sosreport配置文件

sosreport的配置文件是/etc/sos.conf ,默认内容如下:

[root@ywnz ~]# cat /etc/sos.conf
[general]
#ftp_upload_url = ftp://example.com/incoming
#gpg_keyring = /usr/share/sos/rhsupport.pub
#gpg_recipient = support@redhat.com
smtp_server = None
[plugins]  //此处可以设置默认enable和disable的模块
#disable = rpm, selinux, dovecot
[tunables]  //可调参数
#rpm.rpmva = off
#general.syslogsize = 15

从配置文件上可以看出,sosreport同样将收集的结果上传到server上,可以通过man sos.conf查看配置文件的帮助信息。

实例

下面输出信息加粗的部分是收集好的资料压缩文件以及校验码,发送给对方即可:
[root@ywnz ~]# sosreport
sosreport (version 3.0)
This command will collect diagnostic and configuration information from
this Red Hat Enterprise Linux system and installed applications.
An archive containing the collected information will be generated in
/var/tmp and may be provided to a Red Hat support representative.
Any information provided to Red Hat will be treated in accordance with
the published support policies at:
https://access.redhat.com/support/
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 [ywnz.com]:此处敲击回车,来确认主机名称
Please enter the case number that you are generating this report for:此处敲击回车来确认主机编号
Running plugins. Please wait ...
Running 70/70: yum...
Creating compressed archive...
Your sosreport has been generated and saved in:
/var/tmp/sosreport-ywnz.com-20180205230631.tar.xz
The checksum is: 79436cdf791327040efde48c452c6322
Please send this file to your support representative.

sosreport总结

相于supportconfig,由于sosreport是由python语言进行编写的,所以其在功能扩展上更有优势,但由于在不同的发行版本上的python版本不同,在进行功能扩展时,对不同版本间的异常处理相对麻烦。而supportconfig由于是shell语言编写的一个工具,对版本的依赖相对少些,但对一些工具的依赖相对多些,如在获取进程相关的信息时,shell需要将ps工具或处理proc的结果,而sosreport则可以直接import psutil模块,两者之间的区别,归根到底就是shell和python的区别。

相关命令