溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

怎么在Linux中安裝sosreport和supportconfig來收集系統(tǒng)信息

發(fā)布時(shí)間:2021-08-05 20:12:10 來源:億速云 閱讀:300 作者:chen 欄目:系統(tǒng)運(yùn)維

本篇內(nèi)容介紹了“怎么在Linux中安裝sosreport和supportconfig來收集系統(tǒng)信息”的有關(guān)知識(shí),在實(shí)際案例的操作過程中,不少人都會(huì)遇到這樣的困境,接下來就讓小編帶領(lǐng)大家學(xué)習(xí)一下如何處理這些情況吧!希望大家仔細(xì)閱讀,能夠?qū)W有所成!

sosreport
sosreport是一個(gè)類型于supportconfig 的工具,sosreport是python編寫的一個(gè)工具,適用于centos(和redhat一樣,包名為sos)、ubuntu(其下包名為sosreport)等大多數(shù)版本的linux 。sosreport在github上的托管頁面為:https://github.com/sosreport/sos ,而且默認(rèn)在很多系統(tǒng)的源里都已經(jīng)集成有。如果使用的是正版redhat,在出現(xiàn)系統(tǒng)問題,尋求官方支持時(shí),官方一般也會(huì)通過sosreport將收集的信息進(jìn)行分析查看。需要注意的是在一些老的redhat發(fā)行版中叫sysreport ------ 如redhat4.5之前的版本中。

一、sosreport的安裝

在默認(rèn)使用linux發(fā)行版的源進(jìn)行安裝時(shí),由于在不同的系統(tǒng)上包名稱也會(huì)有差異,所以使用的命令也不同,如redhat和ubuntu平臺(tái)的安裝如下:

代碼如下:


//    redhat/centos下的安裝
# yum -y insatll sos
//    ubuntu下的安裝
# sudo apt-get install sosreport


二、sosreport用法

可以使用sosreport --help或man sosreport 獲取使用幫助手冊(cè),如下:

代碼如下:


[root@361way ~]# 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


上面也列出了具體操作的示例。其中-l 參數(shù)會(huì)列出當(dāng)前enable和disable的所有服務(wù)插件及當(dāng)前available的所有插件。

代碼如下:


[root@361way log]# sosreport -a --report
sosreport (version 3.0)
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 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://www.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 [361way.com]:
Please enter the case number that you are generating this report for:
Running plugins. Please wait ...
 Running 68/68: yum...
Creating compressed archive...
Your sosreport has been generated and saved in:
 /var/tmp/sosreport-361way.com-20140912204339.tar.xz
The checksum is: eaf5b2cbb1e9be68d41be5e5a60a61b6
Please send this file to your support representative.


如上所示,我使用-A 啟用所有的模塊,--report是開啟所有的結(jié)果以html /xml 的格式一個(gè)總的報(bào)告。生成的包需要通過下面的命令進(jìn)行解包。

代碼如下:


# xz -d ***.tar.xz
# tar -xvf  ***.tar


或直接使用下面的命令一步完成解壓

代碼如下:


tar xvJf  ***.tar.xz


在解包后的sos_reports 目錄會(huì)有report的結(jié)果sos.html文件生成,同時(shí)會(huì)有sos.txt文件生成,該文件內(nèi)列出了具體執(zhí)行的命令及copy 文件的一些信息。

由于頁面較大,這里只截出了最上面的部分,列出了所有的收集模塊,下面alerts 給出了報(bào)警模塊的信息。再往下就是具體到每一個(gè)模塊的信息。

三、sosreport配置文件

sosreport的配置文件是/etc/sos.conf ,默認(rèn)內(nèi)容如下:

代碼如下:


[root@361way ~]# 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]  //此處可以設(shè)置默認(rèn)enable和disable的模塊
#disable = rpm, selinux, dovecot
[tunables]  //可調(diào)參數(shù)
#rpm.rpmva = off
#general.syslogsize = 15


從配置文件上可以看出,sosreport同樣將收集的結(jié)果上傳到server 上,可以通過man sos.conf 查看配置文件的幫助信息,不過man給出的并沒有太多信息,想在了解更多的信息可以查看 sosreport在github上的wiki頁 。

四、sosreport總結(jié)

相于supportconfig,由于sosreport是由python語言進(jìn)行編寫的,所以其在功能擴(kuò)展上更有優(yōu)勢(shì),但由于在不同的發(fā)行版本上的python版本不同,在進(jìn)行功能擴(kuò)展時(shí),對(duì)不同版本間的異常處理相對(duì)麻煩。而supportconfig由于是shell 語言編寫的一個(gè)工具,對(duì)版本的依賴相對(duì)少些 ,但對(duì)一些工具的依賴相對(duì)多些 ,如在獲取進(jìn)程相關(guān)的信息時(shí),shell 需要將ps 工具或處理proc的結(jié)果,而sosreport則可以直接import psutil 模塊,兩者之間的區(qū)別,歸根到底就是shell 和python的區(qū)別。

supportconfig
一、supportconfig的安裝

可以通過yast進(jìn)行安裝,也可以通過zypper命令進(jìn)行安裝,安裝命令如下:

直接使用源進(jìn)行安裝

代碼如下:

#zypper install supportutils


也可以將rpm包下載下來使用yast進(jìn)行安裝或者在yast的管理界面里查找安裝

代碼如下:

#yast install supportutils-xxx.rpm


注:根據(jù)系統(tǒng)的版本不同,包名也可能是supportconfig 。

安裝完成后可以使用rpm -ql supportutils 查看包中具體包含的文件信息,如下:

代碼如下:


# rpm -ql supportutils
/etc/schealth.conf
/etc/supportconfig.conf
/sbin/chkbin
/sbin/supportconfig
/usr/bin/schealth
/usr/share/man/man5/supportconfig.conf.5.gz
/usr/share/man/man8/chkbin.8.gz
/usr/share/man/man8/supportconfig.8.gz


注:上面的結(jié)果是在 suse11 sp1企業(yè)版上的測(cè)試的結(jié)果,在opensuse 13上目錄結(jié)構(gòu)會(huì)略有不同,其上使用的是新版本的supportconfig。

二、supportconfig用法

以下是supportconfig的幫助輸出

代碼如下:


# supportconfig -h
=============================================================================
                    Support Utilities - Supportconfig
                         Script Version: 2.25-197
                         Script Date: 2010 04 02
=============================================================================
Usage: supportconfig [OPTION [OPTION ...]]
 -h This screen
 -A Activates all supportconfig functions with additional logging and full
    rpm verification.
 -B <string> Custom tar ball file name element
 -C Creates a new default /etc/supportconfig.conf
 -D Use defaults; ignore  /etc/supportconfig.conf
 -E <string> Contact email address
 -F Display available supportconfig feature keywords (case-sensitive) used
    with -i and -x
 -G <gpg_uid> The GPG recipient's user ID used to encrypt the supportconfig tarball
 -H <number> Limit number of included HA Policy engine files
 -I <number> Default log file line count
 -L Create a full file listing from '/'
 -M <string> Contact terminal ID
 -N <string> Contact name
 -O <string> Contact company name
 -P <string> Contact phone number
 -Q Run in silent mode
 -R <path> Log output directory
 -S <number> Limit number of included SAR files
 -T <seconds> Binary execution timeout
 -U <URI string> Sets upload target URL and initiates an upload, supported
                 services include: ftp, scp, http, https
 -M <string> Contact store ID
 -X <number> Max system logs line count
 -a Upload the tar ball to the specified alternate target VAR_OPTION_UPLOAD_ALT
 -b Screen buffer mode
 -d Exclude detailed disk info and scans
 -e Search root file system for eDirectory instances; -L implied. Be patient.
 -f From directory. Don't collect report files, just use files in that
    directory.
 -g Use gzip instead of the default bzip2 compression.
 -i <keyword list>
    Include keywords. A comma separated list of feature keywords that specify
    which features to include. Use -F to see a list of valid keywords.
 -l Gathers additional rotated logs
 -m Only gather a minimum amount of info: basic env, basic health, hardware,
    rpm, messages, y2logs
 -o Toggle listed features on or off
 -p Disable all plugins
 -q Add a uuid to the tar ball filename to ensure uniqueness
 -r <srnum>
    Includes the Novell 11 digit service request number when uploading
    the tar ball to Novell
 -s Include full SLP service lists
 -t Target directory. Just save log files here, do not create tarball.
 -u Upload the tar ball to the specified VAR_OPTION_UPLOAD_TARGET.
 -v Performs an rpm -V for each installed rpm  NOTE: This takes a long time
    to complete
 -x <keyword list>
    Exclude keywords. A comma separated list of feature keywords that specify
    which features to exclude. Use -F to see a list of valid keywords.
 -y Only gather the minimum y2log files.
 Use Ctrl- to try and skip a function that is hanging.
-----------------------------------------------------------------------------
 NOTE:
 This tool will create a tar ball in the /var/log directory. Please attach
 the log file tar ball to your open Service.  Request at the following URL:
 <a href="https://secure-support.novell.com/eService_enu">https://secure-support.novell.com/eService_enu</a>
 If you cannot attach the tar ball to the SR, then email it to the engineer.
 Please submit bug fixes or comments via:
 <a href="http://en.opensuse.org/Supportutils#Reporting_Bugs">http://en.opensuse.org/Supportutils#Reporting_Bugs</a>
=============================================================================
                    Support Utilities - Supportconfig
                         Script Version: 2.25-197
                         Script Date: 2010 04 02
=============================================================================


默認(rèn)supportconfig或supportconfig -A執(zhí)行后會(huì)將收集后的結(jié)果打包為一個(gè)nts_主機(jī)名_日期.tbz 文件,同時(shí)會(huì)生成一個(gè)以該文件名加.md5后綴的文件。

三、supportconfig常用示例

1、supportconfig -A 收集所有日志

代碼如下:


# supportconfig
=============================================================================
                    Support Utilities - Supportconfig
                         Script Version: 2.25-290
                         Script Date: 2011 07 14
=============================================================================
Gathering system information
 Data Directory:    /var/log/nts_361way.com_140825_1504
 Basic Server Health Check...                 Done
 RPM Database...                              Done
 Basic Environment...                         Done
 Basic Health Report...                       Done
 System Modules...                            Done
 Memory Details...                            Done
 Disk I/O...                                  Done
 YaST Files...                                Done
 Auditing...                                  Done
 Crash Info...                                Done
 NTP...                                       Done
 PROC...                                      Done
 Boot Files...                                Done
 SLERT...                                     Skipped
 Updates...                                   Done
 SMT...                                       Skipped
 Novell eDirectory...                         Please Wait... Skipped
 Novell LUM...                                Skipped
 Novell NCP...                                Skipped
 Novell NSS...                                Skipped
 Novell DFS...                                Skipped
 Novell SMS...                                Skipped
 Novell NCS...                                Skipped
 Novell AFP...                                Skipped
 Novell CIFS...                               Skipped
 Novell iManager...                           Skipped
 HA Cluster...                                Skipped
 OCFS2...                                     Skipped
 DRBD...                                      Skipped
 PAM...                                       Done
 LDAP...                                      Done
 CIMOM...                                     Done
 Open Files...                                Done
 Environment...                               Done
 ETC...                                       Done
 SYSCONFIG...                                 Done
 SYSFS...                                     Done
 System Daemons...                            Done
 CRON...                                      Done
 AT...                                        Done
 UDEV...                                      Done
 LVM...                                       Please Wait... Base Detail Done
 EVMS...                                      Skipped
 Software Raid...                             Done
 Multipathing...                              Done
 Networking...                                Done
 Web...                                       Done
 InfiniBand...                                Done
 DNS...                                       Done
 DHCP...                                      Done
 SLP...                                       Done
 SSH...                                       Done
 iSCSI...                                     Done
 Samba...                                     Done
 NFS...                                       Done
 AUTOFS...                                    Done
 SAR Files...                                 Done
 AppArmor...                                  Done
 Xen...                                       Done
 KVM...                                       Done
 X...                                         Done
 Printing...                                  Done
 SMART Disks...                               Excluded
 Hardware...                                  Please Wait... Done
 File System List...                          Skipped
 Supportability Analysis...                   Please Wait... Done
 System Logs...                               Done
Creating Tar Ball
==[ DONE ]===================================================================
 Log file tar ball: /var/log/nts_361way.com_140825_1504.tbz
 Log file size:     4.0M
 Log file md5sum:   484b111cda54ca04419facd82a1da7d7
 Please attach the log file tar ball to your open Service Request at the
 following URL:
 <a href="https://secure-support.novell.com/eService_enu">https://secure-support.novell.com/eService_enu</a>
 You can also upload the tar ball to <a href="ftp://ftp.novell.com/incoming">ftp.novell.com/incoming</a>, or just use
 supportconfig -ur <srnum>, to upload the tar ball automatically.
 If you cannot attach the tar ball to the SR, then email it to the engineer.
=============================================================================


其他常用用法:

代碼如下:


//以最小選項(xiàng)搜集所需的信息
# supportconfig -m
//在輸出中包含附加的聯(lián)系人信息
# supportconfig -E <a href="mailto:tux@example.org">tux@example.org</a> -N "Tux Penguin" -O "Penguin Inc." ...
//要查看完整的功能列表
# supportconfig -F
//僅收集某個(gè)模塊的用法,如LVM相的信息
# supportconfig -i LVM
//-x 的功能與-i剛好相反,是排除某個(gè)模塊不收集
# supportconfig -x LVM
//使用-U url 可以將收集的結(jié)果上傳到服務(wù)器上,直接的服務(wù)有ftp, scp, http, https,如:
# supportconfig -A -U <a href="http://www.361way.com/files/">http://www.361way.com/files/</a>
具體可以參看官方的  常用的supportconfig選項(xiàng) 部分 。


supportconfig收集的系統(tǒng)健康報(bào)告:

代碼如下:


# supportconfig -A
# cd /var/log
# tar jxvf nts_361way.com_140825_1504.tbz
# more basic-health-report.txt
#==[ Command ]======================================#
# /usr/bin/schealth -q
######################################################################
Supportconfig Health Check Report Tool v1.00-5
Date Checked: 09/12/14 04:40:37
######################################################################
Health Check Files                                         [  Green  ]
Processes Waiting for Run Queue                            [  Green  ]
Kernel Taint Status                                        [   Red   ]
Kernel Tainted: 64 > 0
CPU Utilization                                            [  Green  ]
Interrupts Per Second                                      [  Green  ]
Context Switches Per Second                                [  Green  ]
Free Memory and Disk Swapping                              [  Green  ]
Used Disk Space                                            [  Green  ]
Uninterruptible Processes                                  [  Green  ]
Zombie Processes                                           [  Green  ]
######################################################################
Status:   Red Flag
Checked:  /var/log/nts_361way.com_140825_1504/basic-health-check.txt
Report:   /var/log/nts_361way.com_140825_1504/basic-health-report.txt
######################################################################


上面的報(bào)告中,我們發(fā)現(xiàn)kernel Tainted 狀態(tài)為red ,該處是通過cat  /proc/sys/kernel/tainted 進(jìn)行判斷的,如果值不為0,則是內(nèi)核受到污染 ,顯的值不同,具體可以參看/usr/src/linux/Documentation/sysctl/kernel 文件(具體的值不一樣,代表的意義也不一樣)。64報(bào)紅是由于加載了非系統(tǒng)官方或非開源的模塊所致( Unsupported modules loaded)。

四、supportconfig配置文件

supportconfig的默認(rèn)配置文件是 /etc/supportconfig.conf ,其默認(rèn)內(nèi)容如下:

代碼如下:


# cat /etc/supportconfig.conf
####################################
# Default Options
####################################
OPTION_AFP=1
OPTION_APPARMOR=1
OPTION_AUDIT=1
OPTION_AUTOFS=1
OPTION_BOOT=1
OPTION_CHKCONFIG=1
OPTION_CIFS=1
OPTION_CIMOM=1
OPTION_CRASH=1
OPTION_CRON=1
OPTION_DFS=1
OPTION_DHCP=1
OPTION_DISK=1
OPTION_DNS=1
OPTION_EDIR=1
OPTION_ENV=1
OPTION_ETC=1
OPTION_EVMS=1
OPTION_HA=1
OPTION_HCREPORT=1
OPTION_IB=1
OPTION_ISCSI=1
OPTION_LDAP=1
OPTION_LUM=1
OPTION_LVM=1
OPTION_MEM=1
OPTION_MOD=1
OPTION_MPIO=1
OPTION_NCP=1
OPTION_NCS=1
OPTION_NET=1
OPTION_NFS=1
OPTION_NSS=1
OPTION_NTP=1
OPTION_OCFS2=1
OPTION_OFILES=1
OPTION_PAM=1
OPTION_PRINT=1
OPTION_PROC=1
OPTION_SAM=1
OPTION_SAR=1
OPTION_SLERT=1
OPTION_SLP=1
OPTION_SMART=0
OPTION_SMB=1
OPTION_SMS=1
OPTION_SMT=1
OPTION_SRAID=1
OPTION_SSH=1
OPTION_SYSCONFIG=1
OPTION_SYSFS=1
OPTION_UDEV=1
OPTION_UP=1
OPTION_UPD=1
OPTION_WEB=1
OPTION_X=1
OPTION_XEN=1
ADD_OPTION_EDIR=0
ADD_OPTION_FSLIST=0
ADD_OPTION_LOGS=0
ADD_OPTION_MINDISK=0
ADD_OPTION_MINYAST=0
ADD_OPTION_RPMV=0
ADD_OPTION_SLP=0
VAR_OPTION_BIN_TIMEOUT_SEC=300
VAR_OPTION_CONTACT_COMPANY=""
VAR_OPTION_CONTACT_EMAIL=""
VAR_OPTION_CONTACT_NAME=""
VAR_OPTION_CONTACT_PHONE=""
VAR_OPTION_CONTACT_STOREID=""
VAR_OPTION_CONTACT_TERMINALID=""
VAR_OPTION_CUSTOM_ARCH=""
VAR_OPTION_GPG_UID=""
VAR_OPTION_LINE_COUNT=500
VAR_OPTION_LOG_DIRS="/var/log /tmp"
VAR_OPTION_MSG_MAXSIZE=500000
VAR_OPTION_PENGINE_FILES_LIMIT=250
VAR_OPTION_SAR_FILES_LIMIT=30
VAR_OPTION_SBM=0
VAR_OPTION_SILENT=0
VAR_OPTION_UNIQUE_FILE=0
VAR_OPTION_UPLOAD_ALT='https://secure-www.novell.com/upload?appname=supportconfig&file={tarball}'
VAR_OPTION_UPLOAD_TARGET='ftp://ftp.novell.com/incoming'


配置文件中列出了默認(rèn)收集的模塊信息,公司信息、郵件、電話及上傳的服務(wù)器目錄等。

五、supportconfig總結(jié)

supportconfig是使用shell 編寫的一個(gè)功能十分強(qiáng)大的工具,具體可以通過vim /sbin/supportconfig 查看 。同時(shí),由于linux命令上的通用性,我們甚至可以很簡(jiǎn)單的進(jìn)行修改后將其移植到其他linux 發(fā)行版上。不過顯然這是沒必要的,因?yàn)檫€有一個(gè)比較通的用的開源工具sosreport和其作用差不多,而其適用性更強(qiáng),后面會(huì)單獨(dú)列一篇做一個(gè)總結(jié)。

“怎么在Linux中安裝sosreport和supportconfig來收集系統(tǒng)信息”的內(nèi)容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業(yè)相關(guān)的知識(shí)可以關(guān)注億速云網(wǎng)站,小編將為大家輸出更多高質(zhì)量的實(shí)用文章!

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI