# cat /etc/redhat-release
CentOS release 5.4 (Final)
# yum install sysstat.i386 -y
sysstat をインストールすると、cron で下記のジョブも登録される。
# cat /etc/cron.d/sysstat
# run system activity accounting tool every 10 minutes
*/10 * * * * root /usr/lib/sa/sa1 1 1
# generate a daily summary of process accounting at 23:53
53 23 * * * root /usr/lib/sa/sa2 -A
- /usr/lib/sa/sa1 [ interval count ]
Collect and store binary data in the system activity daily data file
sa1 1 1 は interval 1秒で1回 システムの情報を取得
バイナリデータとして下記に保存される。( dd は 日にち )
# ls /var/log/sa/sa*
/var/log/sa/sa21 /var/log/sa/sa22
sar -f ファイル名で読める
# sar -f /var/log/sa/sa22
- /usr/lib/sa/sa2
sa2 - Write a daily report in the /var/log/sa directory
ログファイル
# ls /var/log/sa/sar*
/var/log/sa/sar21
/usr/lib/sa/sa1 は sadc 実行
# egrep -i sadc /usr/lib/sa/sa1 | uniq
exec ${ENDIR}/sadc -F -L 1 1 -
exec ${ENDIR}/sadc -F -L $* -
/usr/lib/sa/sa2 は sar を実行
# egrep -i sar /usr/lib/sa/sa2 | uniq
RPT=/var/log/sa/sar${DATE}
${ENDIR}/sar $* -f ${DFILE} > ${RPT}
find /var/log/sa \( -name 'sar??' -o -name 'sa??' \) -mtime +"${HISTORY}" -exec rm -f {} \;
sar で CPU , Memory etc の情報をチェック。
[ CPU usage ]
# LANG=C sar
Linux 2.6.18-164.el5 (hat2.localdomain) 04/22/10
00:20:01 CPU %user %nice %system %iowait %steal %idle
00:30:01 all 0.07 0.00 0.10 0.00 0.00 99.83
Average: all 0.07 0.00 0.10 0.00 0.00 99.83
%user + %system の合計がCPU使用率なので、
# LANG=C sar | grep -i average | awk '{print $3+$5"%"}'
0.17%
[ memory consumption ]
# LANG=C sar -r
Linux 2.6.18-164.el5 (hat2.localdomain) 04/22/10
00:20:01 kbmemfree kbmemused %memused kbbuffers kbcached kbswpfree kbswpused %swpused kbswpcad
00:30:01 69288 445544 86.54 19196 279824 451192 70912 13.58 17672
00:40:01 69164 445668 86.57 19368 279808 451192 70912 13.58 17672
Average: 69226 445606 86.55 19282 279816 451192 70912 13.58 17672
実質メモリ使用量は kbmemused - ( kbbuffers + kbcached ) なので、
# LANG=C sar -r | grep -i average | awk '{print $3-$5-$6"Kbytes"}'
146508Kbytes
[ network bandwidth ]
# LANG=C sar -n DEV | head -5
Linux 2.6.18-164.el5 (hat2.localdomain) 04/22/10
00:20:01 IFACE rxpck/s txpck/s rxbyt/s txbyt/s rxcmp/s txcmp/s rxmcst/s
00:30:01 lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00
00:30:01 eth0 0.00 0.00 0.00 0.00 0.00 0.00 0.00
受信、送信データは、 rxbyt/s , txbyt/s
# LANG=C sar -n DEV | grep eth0 | grep -i average | awk '{print "Rx:"$5"byte/sec","Tx:"$6"byte/sec"}'
Rx:0.00byte/sec Tx:0.00byte/sec
[ disk I/O ]
# LANG=C sar -b
Linux 2.6.18-164.el5 (hat2.localdomain) 04/22/10
00:20:01 tps rtps wtps bread/s bwrtn/s
00:30:01 0.26 0.00 0.26 0.00 3.12
00:40:01 0.37 0.00 0.37 0.00 7.04
00:50:01 0.68 0.00 0.68 0.00 12.85
01:00:01 0.29 0.00 0.29 0.00 4.48
01:10:01 0.46 0.00 0.46 0.00 7.55
01:20:01 0.28 0.00 0.28 0.00 4.03
Average: 0.39 0.00 0.39 0.00 6.51
bread/s = 読み出したデータ量
bwrtn/s = 書き込んだデータ量
単位はブロック
# LANG=C sar -b | egrep -i average | awk '{print "Read:"$5"block/sec","Write:"$6"block/sec"}'
Read:0.00block/sec Write:6.51block/sec
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.