サーバーを管理する上では、様々な設定ファイルやコマンドの実行結果を見る必要があります。
RedHat系OSであれば、それらの主要な設定ファイルやコマンドの実行結果をまとめてくれる、sysreportという便利なコマンドがあります。
主要な設定ファイル、ログファイル、コマンドの実行結果を一気にまとめてみよう!
実行方法は、いたって簡単で
# sysreport
と、実行するだけです。
sysreportコマンドが存在しない場合は、RPMパッケージで提供されているので、yumコマンドでインストールしてみるのが簡単です。
参考: yumによるRPMパッケージの更新管理
sysreportコマンドを実行すると、まず下記のようなメッセージが表示されます。
# sysreport
This utility will go through and collect some detailed information
about the hardware and setup of your Red Hat Linux system.
This information will be used to diagnose problems with your system
and will be considered confidential information. Red Hat will use
this information for diagnostic purposes ONLY.
Please wait while we collect information about your system.
This process may take a while to complete....
No changes will be made to your system during this process.
NOTE: You can safely ignore a failed message. This only means a file
we were checking for did not exist.
If your system hangs while gathering rpm information, please abort
the script with CTRL-C and run it again after adding -norpm to the
sysreport command line
Press ENTER to continue, or CTRL-C to quit.
取りやめる場合(またはsysreportの実行途中にハングした場合)は、Ctrl+Cを押せという注意なので、問題ない場合はそのままENTERキーを押しましょう。
しばらくすると、
Please enter your case number (if you have one):
というメッセージが表示されます。
レポートファイルに付与する任意の数字を入れます。
完了すると
Please send /tmp/sysreport-localhost.localdomain-1.20090125150118.tar.bz2 to your support representative.
のように、レポートの保存先のパスが表示されます。
(/tmpや/var/tmpのような一時領域に保存されます)
ファイル名を見ればわかるように、圧縮ファイルになっていますので、それを展開すればsysreportで取りまとめた様々な設定ファイルやコマンドの実行結果を見ることができます。
sysreportの実行結果を見てみよう
sysreportの実行結果は、圧縮ファイルになっていますので、まずは展開してみます。
# tar -jxvf sysreport-localhost.localdomain-1.20090125150118.tar.bz2
中身をみれば直感的にわかるかと思いますが、コマンド名のファイルやLinux上の主要なディレクトリが中に入っています。
# ls
chkconfig fdisk-l installed-rpms lsof proc rpm-Va uname
date free ipcs lspci ps sestatus uptime
df hostname ls-boot ls-samba pstree sysctl var
etc ifconfig lsmod mount route sysreport.log wbinfo
例えば、左上から見ていくとchkconfig(自動起動スクリプトの状況)、date(sysreport実行時の日時)、df(ファイルスペースの容量)など、ファイルに関してはコマンドの実行結果が保存されています。
一方で、etcやvarなど設定ファイルやログファイルのディレクトリもコピーされています。
# ls etc/
aliases exports httpd nsswitch.conf samba udev
cron.d fstab inittab ntp securetty X11
cron.daily ftpchroot krb5.conf ntp.conf security xinetd.conf
cron.deny ftpusers ld.so.conf openldap shells xinetd.d
cron.hourly host.conf ld.so.conf.d pam.d ssh
cron.monthly hosts mail rc.d sysconfig
crontab hosts.allow named.conf redhat-release sysctl.conf
cron.weekly hosts.deny nscd.conf resolv.conf syslog.conf
# ls var/log/
boot.log httpd maillog.1 maillog.3 messages messages.2 messages.4 secure
dmesg maillog maillog.2 maillog.4 messages.1 messages.3 rpmpkgs
実行時の注意点と使い道
sysreportコマンドは、様々なファイルをコピーしたり、コマンドを実行したりするため、それなりの時間とサーバーに負荷がかかります。
実行時間はサーバーのスペックや、ログファイルの容量などによって異なってきますが、5分から10分ほどかかる場合もあります。
また、負荷もそれなりに大きいため、何らかのサービスを提供している状況での実行は控えたほうがよいでしょう。
また、主要な設定ファイルが含まれるため、渡す相手には注意しておいたほうがよいでしょう。
保守契約を結んでいる業者などであれば、あれこれとコマンドの実行結果やログファイルのやり取りをするよりは、このレポートファイルを送ったほうが早い場合もあります。
現に、このsysreportの実行結果を送れと指示してくる業者も結構あります。
また、サーバーを移行する場合などに利用すれば、前のサーバーの主要なファイルやコマンドの実行結果を一気にまとめられるので便利です。
サーバー保守や運用を楽にするコマンドですので、用途に応じて使ってみてはいかがでしょうか。