sosreportとは?
sosreportとはシステムの構成やログなどの情報を一括取得するためのツール。
どうやって取得するか?
昔、サーバ障害の原因が分からずサポートに問い合わせた時に、このsosreportを取得して送付して欲しいと言われたことがある。
その時のことをふと思い出したので、自分の環境で取得してみた。
環境は以下で実施。
[root@~]$cat /etc/redhat-release
CentOS Linux release 7.2.1511 (Core)
[root@~]$uname -r
3.10.0-327.3.1.el7.x86_64
sosreportはrootユーザで実行する必要がある。
rootユーザではない場合、以下のようなエラーになる。
[testuser@~]$sosreport
sosreport (version 3.2)
no valid plugins were enabled
以下、rootユーザでsosreportを実行した時の出力。
途中3回入力するインタラクション部分がある。(赤字は出力ではなく、メモ)
[root@tmp]$sosreport
sosreport (version 3.2)
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:
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. <- ここで一回Enter
Please enter your first initial and last name : sagantaf <-レポート名として名前を入力しEnter
Please enter the case id that you are generating this report for : <- レポート番号をつけられるが今回は何も入力せずEnter
Setting up archive ...
Setting up plugins ...
dbname must be supplied to dump a database.
Running plugins. Please wait ...
Running 84/84: yum...
Creating compressed archive...
Your sosreport has been generated and saved in:
/var/tmp/sosreport-sagantaf-20160414155523.tar.xz <- ここにレポートが出力される
The checksum is: b7023ecf3cfbd20dbff42fc1629d4364
Please send this file to your support representative.
これでsosreportが作成される。上記に記載されるように、
sosreport-sagantaf-20160414155523.tar.xz
というレポートが /var/tmp配下に作成されているので、確認する。
[root@tmp]$ls -ltr | grep sos
-rw------- 1 root root 6244916 4月 14 15:55 sosreport-sagantaf-20160414155523.tar.xz
-rw-r--r-- 1 root root 33 4月 14 15:55 sosreport-sagantaf-20160414155523.tar.xz.md5
[root@tmp]$
[root@tmp]$xz -dv sosreport-sagantaf-20160414155523.tar.xz
sosreport-sagantaf-20160414155523.tar.xz (1/1)
100 % 6,098.6 KiB / 30.1 MiB = 0.198
[root@tmp]$tar -xvf sosreport-sagantaf-20160414155523.tar
(出力は長いので省略)
作成されたレポートはtar.xz形式なので、xzコマンドとtarコマンドで解凍した。各オプションの意味は以下のとおり。
xz -dv <filename>
-d:解凍
-v:詳細を表示
tar -xvf <filename>
-x:解凍
-v:詳細を表示
-f:ファイルを指定
sosreportの中身はどうなっているか?
解凍後、中身を確認すると、boot, lib, usr, var, sysなどのシステム情報が収集されている。
[root@tmp]$ls -ltr | grep sos
drwx------ 14 root root 4096 4月 14 15:55 sosreport-sagantaf-20160414155523
-rw------- 1 root root 31610880 4月 14 15:55 sosreport-sagantaf-20160414155523.tar
-rw-r--r-- 1 root root 33 4月 14 15:55 sosreport-sagantaf-20160414155523.tar.xz.md5
[root@tmp]$ls ./sosreport-sagantaf-20160414155523
boot free lib proc sos_commands usr
chkconfig hostname lsmod ps sos_logs var
date installed-rpms lsof pstree sos_reports version.txt
df ip_addr lspci root sys vgdisplay
dmidecode java mount route uname
[root@tmp]$
[root@tmp]$du -h ./sosreport-sagantaf-20160414155523 | tail -1
39M ./sosreport-sagantaf-20160414155523
↑サイズは39Mほど。
まとめ
root権限で sosreportコマンドを実行することで、サーバの構成情報やログを収集することができる。
実行後、/var/tmpにtar.xz形式でレポートが出力される。