sysstat安装与使用

1、下载与安装:
# wget http://perso.orange.fr/sebastien.godard/sysstat-8.0.4.1.tar.gz
# tar zxvf sysstat-8.0.4.1.tar.gz
# cd sysstat-8.0.4.1
# ./configure
# make
# make install

这个包一但安装下去,一般包括如下的几个命令可以使用。
    sar    iostat    sa1    sa2    sadf    mpstat    sadc    sysstat

2、定时设置:
# crontab -e
*/10 * * * * /usr/lib/sa/sa1 1 1
53 23 * * * /usr/lib/sa/sa2 -A

# /etc/init.d/crond restart

3、权限设置:
让普通用户能够使用sar命令,至少有两种办法:
1、将普通用户加到adm组中;
2、这个例子中,就是这个命令:chmod o+x /usr/lib/sa/sadc

4、查看软件版本
[root@localhost sysstat-8.1.6]# sar -V
sysstat version 8.1.6

5、基本使用方法:
   1). 查看CPU使用情况
      sar 2 5
      //每隔2秒,显示5次,CPU使用的情况

      
   2). 查看内存使用情况
      sar -r 2 5
      //每隔2秒,显示5次,内存使用的情况

   3). 查看网络吞吐量
    sar -n DEV 2 5
      //每隔2秒,显示5次,网络吞吐量情况


6、常见问题解决:
If you’re not able to run sar command of sysstat package use the following fix:
Move the invalid file and run
/usr/lib/sa/sa1
which should recreate the file.
Or you should be able to get this fixed once you try reinstalling sysstat package.
If you continue facing the issue, find out the sar binaries using which
    # whereis sar
    sar: /usr/bin/sar /usr/local/bin/sar /usr/share/man/man1/sar.1.gz
now check the time stamps on both the files
    # ls -al /usr/bin/sar
    -rwxr-xr-x  1 root root 56872 Jul 26 02:36 /usr/bin/sar

    # ls -al /usr/local/bin/sar
    -rwxr-xr-x  1 root root 47952 Aug  6 21:22 /usr/local/bin/sar

Remove the old on and link the new file. Now run the sar command to  see it working.

安装完成后,用户sar 2 5测试,不行,删除文件重新安装,发现在./configure的时候出现三个warning,并且在make的时候,很多文件被忽略了,特别是.o文件,从网上搜索,需要安装gettext

因为在虚拟机上,不能直接连接到网络,所以选择了下载gettext-xxx.deb后安装,如果可以上网的话,可以直接使用
apt-get install gettext
进行安装

猜你喜欢

转载自ikon.iteye.com/blog/1213550