dstat工具的安装和使用

dstat 是一款比较全面的性能监控工具,是排查服务器负载异常的利器!

dstat的安装

dstat的安装在这里介绍三种方式

  • 使用”绿色版”安装

    1
    2
    3
    4
    5
    wget http://dstat.sourcearchive.com/downloads/0.7.0/dstat_0.7.0.orig.tar.gz
    tar -xvzf dstat_0.7.0.orig.tar.gz
    cd dstat-0.7.0.orig/
    #使用以下方式即可使用dstat
    ./dstat -V
  • 使用rpm安装

    1
    2
    3
    4
    wget http://mirror.centos.org/centos/6/os/i386/Packages/dstat-0.7.0-2.el6.noarch.rpm
    rpm -ivh dstat-0.7.0-2.el6.noarch.rpm
    #直接在系统中调用dstat即可
    dstat -V
  • 使用yum安装

    yum install dstat

dstat的使用

dstat命令支持的参数这里就不再赘述啦,以下介绍一下个人比较常用的两种参数

  1. dstat -tcdrlmn –top-cpu –top=mem #查看时间、CPU、磁盘读写、IO、负载、内存、网络、最高的CPU占用和最高的内存占用
    1
    2
    3
    4
    5
    6
    7
    ----system---- ----total-cpu-usage---- -dsk/total- --io/total- ---load-avg--- ------memory-usage----- -net/total- -most-expensive- --most-expensive-
    date/time |usr sys idl wai hiq siq| read writ| read writ| 1m 5m 15m | used buff cach free| recv send| cpu process | memory process
    19-11 21:49:25| 0 0 100 0 0 0|1055B 1810B|0.02 0.07 |0.02 0.01 0| 236M 131M 2961M 4527M| 0 0 |kipmi0 0.0|sshd: root@p4488k
    19-11 21:49:26| 0 0 100 0 0 0| 0 0 | 0 0 |0.02 0.01 0| 236M 131M 2961M 4527M| 398B 1532B| |sshd: root@p4488k
    19-11 21:49:27| 0 0 100 0 0 0| 0 0 | 0 0 |0.02 0.01 0| 236M 131M 2961M 4527M| 352B 542B| |sshd: root@p4488k
    19-11 21:49:28| 0 0 100 0 0 0| 0 0 | 0 0 |0.02 0.01 0| 236M 131M 2961M 4527M| 850B 542B| |sshd: root@p4488k
    19-11 21:49:29| 0 0 100 0 0 0| 0 0 | 0 0 |0.02 0.01 0| 236M 131M 2961M 4527M| 256B 542B| |sshd: root@p4488k
  2. dstat -cl -C 0,1,2,3,4,5,6,7 –top-cpu #查看8颗核心,每颗核心的使用情况和CPU使用情况
    1
    2
    3
    4
    5
    6
    7
    8
    	-------cpu0-usage--------------cpu1-usage--------------cpu2-usage--------------cpu3-usage--------------cpu4-usage--------------cpu5-usage--------------cpu6-usage--------------cpu7-usage------ ---load-avg--- -most-expensive-
    usr sys idl wai hiq siq:usr sys idl wai hiq siq:usr sys idl wai hiq siq:usr sys idl wai hiq siq:usr sys idl wai hiq siq:usr sys idl wai hiq siq:usr sys idl wai hiq siq:usr sys idl wai hiq siq| 1m 5m 15m | cpu process
    0 0 100 0 0 0: 0 0 100 0 0 0: 0 0 100 0 0 0: 0 0 100 0 0 0: 0 0 100 0 0 0: 0 0 100 0 0 0: 0 0 100 0 0 0: 0 0 100 0 0 0|0.07 0.02 0|kipmi0 0.0
    0 0 100 0 0 0: 0 0 100 0 0 0: 0 1 99 0 0 0: 0 0 100 0 0 0: 0 0 100 0 0 0: 0 0 100 0 0 0: 0 0 100 0 0 0: 0 0 100 0 0 0|0.07 0.02 0|
    0 0 100 0 0 0: 0 0 100 0 0 0: 1 1 98 0 0 0: 0 0 100 0 0 0: 0 0 100 0 0 0: 0 0 100 0 0 0: 0 0 100 0 0 0: 0 0 100 0 0 0|0.07 0.02 0|kipmi0 0.1
    0 1 99 0 0 0: 0 0 100 0 0 0: 2 0 98 0 0 0: 0 0 100 0 0 0: 0 0 100 0 0 0: 0 0 100 0 0 0: 0 0 100 0 0 0: 0 0 100 0 0 0|0.07 0.02 0|events/3 0.1
    0 0 100 0 0 0: 0 0 100 0 0 0: 1 1 98 0 0 0: 0 0 100 0 0 0: 0 0 100 0 0 0: 0 0 100 0 0 0: 0 0 100 0 0 0: 0 0 100 0 0 0|0.07 0.02 0|
    0 0 100 0 0 0: 0 0 100 0 0 0: 1 0 99 0 0 0: 0 0 100 0 0 0: 0 0 100 0 0 0: 0 0 100 0 0 0: 0 0 100 0 0 0: 0 0 100 0 0 0|0.07 0.02 0|kipmi0 0.1