May
30
2010

sar

9:57 am

sar(System Admin Report)は、システムの情報を収集し、リポートを出力します。
sar は、sysstat に含まれています。
インストールは、
$ sudo apt-get install sysstat
とするだけです。

sarは 引数に実行間隔、回数を指定することで、実行時からの情報を取得することができます。

$ sar 1 5 とすると1秒ごとに5回出力して、平均値を出してくれます。

コマンド実行時からのシステム負荷情報の表示は、以上で問題ないわけですが、サーバーなど普段から取得しているシステム負荷情報の表示をする場合は、システム情報を普段から収集しておく設定をしておく必要があり、デフォルトでは収集しない設定になっているので、設定ファイルを修正します。
$ sudo nano /etc/default/sysstat で設定ファイルを編集します。
修正するのは、以下のENABLED=”false”をコメントアウトし、ENABLED=”true”追記します。

# Should sadc collect system activity informations? Valid values
# are "true" and "false". Please do not put other values, they
# will be overwritten by debconf!
ENABLED="false"

修正後です。

# Should sadc collect system activity informations? Valid values
# are "true" and "false". Please do not put other values, they
# will be overwritten by debconf!
#ENABLED="false"
ENABLED="true"

/etc/cron.d/sysstat がインストール時に自動的に生成されています。

# The first element of the path is a directory where the debian-sa1
# script is located
PATH=/usr/lib/sysstat:/usr/sbin:/usr/sbin:/usr/bin:/sbin:/bin
# Activity reports every 10 minutes everyday
5-55/10 * * * * root command -v debian-sa1 > /dev/null && debian-sa1 1 1
# Additional run at 23:59 to rotate the statistics file
59 23 * * * root command -v debian-sa1 > /dev/null && debian-sa1 60 2

設定ファイルを上記のように編集すると普段から収集しているシステム負荷情報の表示ができるようになり、単純に $ sar とするだけで、 cron に設定している10分間隔でのレポートが見られます。

/etc/sysstat/sysstat を編集し、14日分のデータを保存するようにしました。

# sysstat configuration file.
# How long to keep log files (in days).
# Used by sa2(8) script
# If value is greater than 28, then log files are kept in
# multiple directories, one for each month.
#HISTORY=7
HISTORY=14
# Compress (using gzip or bzip2) sa and sar files older than (in days):
COMPRESSAFTER=10

isag は sysstat で取得した情報をグラフ化してくれるツールです。
$ sudo apt-get install isag
でインストールします。
Munin というツールもあるようです。
$ sudo apt-get install munin munin-node
KSar というのもあるようです。

参考サイト
アクセラと+αな生活
いますぐ実践! Linux システム管理 / Vol.178 /

Written by hbirds in: basic settings | Tags: , , , ,

No Comments »

RSS feed for comments on this post. TrackBack URL

Leave a comment

You must be logged in to post a comment.

www.hbirds.net