1. sysstat 服务
1.1. /etc/cron.d/sysstat
Linux 下的性能分析,少不了要使用 sysstat 工具包中的命令。同时 sysstat 服务会自动每个10分钟收集一次系统状态信息,并将它们存储到 /var/log/sa目录下。每天一个文件,文件名分别是sa1, sa2,... sa30..
[root@localhost sa]#pwd
/var/log/sa
[root@localhost sa]#ls
sa01 sa03 sa05 sa06 sa07 sa08 sa09 sa10 sa11 sa12 sa13 sa14 sa15 sa25 sa26 sa27 sa28 sa29 sa30 sar25
自动收集系统信息,是通过 /etc/cron.d/sysstat 来实现的:
[root@localhost sa]#cat /etc/cron.d/sysstat
# Run system activity accounting tool every 10 minutes
*/10 * * * * root /usr/lib/sa/sa1 1 1
#0 * * * * root /usr/lib/sa/sa1 600 6 &
# Generate a daily summary of process accounting at 23:53
53 23 * * * root /usr/lib/sa/sa2 -A
上面标示每个10分钟,运行一次 /usr/lib/sa/sa1 1 1, 该命令 man sa1:
sa1 - Collect and store binary data in the system activity daily data file.
SYNOPSIS:/usr/lib/sa/sa1 [ --boot | interval count ]
sa1 收集到的是 binary data. 所以 sa2 -A 负责将当天的二进制文件转换成文本文件。
sa2 - Write a daily report in the /var/log/sa directory
其中的收集信息的频率我们可以根据需要进行修改。
1.2. /etc/sysconfig/sysstat
/var/log/sa/目录下的文件保存时间等相关配置存在于文件 /etc/sysconfig/sysstat中:
[root@localhost ~]#cat /etc/sysconfig/sysstat
# sysstat-9.0.4 configuration file.
# How long to keep log files (in days).
# If value is greater than 28, then log files are kept in
# multiple directories, one for each month.
HISTORY=28
#Compress (using gzip or bzip2) sa and sar files older than (in days):
COMPRESSAFTER=31
#Parameters for the system activity data collector (see sadc manual page)
# which are used for the generation of log files.
SADC_OPTIONS="-S DISK"
#Compression program to use.
ZIP="bzip2"
其中的 HISTORY=28 表示最多保存28天的数据。保存时间,我们可以根据需要进行修改。
1.3. 确保 sysstat 服务启动:
[root@localhost ~]#chkconfig --level 3 --level 5 sysstat on
[root@localhost ~]#chkconfig |grep sysstat
sysstat 0:off 1:on 2:on 3:on 4:on 5:on 6:off
上面是 sysstat 服务运行的知识。下面是 sysstat 工具包中的命令行如何使用收集到的信息,来了解系统的运行情况。
2. sysstat 工具包中的命令
原文:http://www.cnblogs.com/digdeep/p/4878138.html