Linux命令(129)之dstat
  wwLZeziuqjLR 2023年12月15日 26 0


linux命令之dstat

1.dstat介绍

linux命令dstat是用来实时显示系统中各个进程的资源占用情况

2.dstat用法

dstat [参数]

dstat参数

参数

说明

-c

显示CPU的相关信息

-d

显示磁盘的相关信息

-g

显示page相关的统计数据

-m

显示内存的相关统计数据

-n

显示网络的相关统计数据

-p

显示进程的相关统计数据

-r

显示io请求的相关的统计数据

-s

显示swap相关的统计数据

--tcp

启用tcp相关的统计数据

--udp

启用udp相关的统计数据

--raw

启用raw相关的统计数据

--socket

启用socket相关的统计数据

--top-cpu

显示最占用cpu的进程

--top-io

显示最占用io的进程

--top-mem

显示最占用内存的进程

3.实例

3.1.显示dstat的帮助信息

命令:

dstat -h

[root@centos79 ~]# dstat -h
Usage: dstat [-afv] [options..] [delay [count]]
Versatile tool for generating system resource statistics

Dstat options:
  -c, --cpu              enable cpu stats
     -C 0,3,total           include cpu0, cpu3 and total
  -d, --disk             enable disk stats
     -D total,hda           include hda and total
  -g, --page             enable page stats
  -i, --int              enable interrupt stats
     -I 5,eth2              include int5 and interrupt used by eth2
  -l, --load             enable load stats
  -m, --mem              enable memory stats
  -n, --net              enable network stats
     -N eth1,total          include eth1 and total
  -p, --proc             enable process stats
  -r, --io               enable io stats (I/O requests completed)
  -s, --swap             enable swap stats
     -S swap1,total         include swap1 and total
  -t, --time             enable time/date output
  -T, --epoch            enable time counter (seconds since epoch)
  -y, --sys              enable system stats

  --aio                  enable aio stats
  --fs, --filesystem     enable fs stats
  --ipc                  enable ipc stats
  --lock                 enable lock stats
  --raw                  enable raw stats
  --socket               enable socket stats
  --tcp                  enable tcp stats
  --udp                  enable udp stats
  --unix                 enable unix stats
  --vm                   enable vm stats

  --plugin-name          enable plugins by plugin name (see manual)
  --list                 list all available plugins

  -a, --all              equals -cdngy (default)
  -f, --full             automatically expand -C, -D, -I, -N and -S lists
  -v, --vmstat           equals -pmgdsc -D total

  --bits                 force bits for values expressed in bytes
  --float                force float values on screen
  --integer              force integer values on screen

  --bw, --blackonwhite   change colors for white background terminal
  --nocolor              disable colors (implies --noupdate)
  --noheaders            disable repetitive headers
  --noupdate             disable intermediate updates
  --output file          write CSV output to file
  --profile              show profiling statistics when exiting dstat

delay is the delay in seconds between each update (default: 1)
count is the number of updates to display before exiting (default: unlimited)

[root@centos79 ~]#

3.2.实时显示系统中各个进程的资源占用情况

命令:

dstat

You did not select any stats, using -cdngy by default.
----total-cpu-usage---- -dsk/total- -net/total- ---paging-- ---system--
usr sys idl wai hiq siq| read  writ| recv  send|  in   out | int   csw 
  3   1  91   4   0   0| 434k   34k|   0     0 |   0     0 | 539   876 
  1   1  99   0   0   0|   0     0 |  12k   13k|   0     0 | 403   748 
  0   1  99   0   0   0|   0     0 |2482B 2938B|   0     0 | 334   694 ^C
[root@centos79 ~]#

3.3.显示cpu的相关信息

命令:

dstat -c

[root@centos79 ~]# dstat -c
----total-cpu-usage----
usr sys idl wai hiq siq
  3   1  91   4   0   0
  0   1  99   0   0   0
  0   0 100   0   0   0
  1   0  99   0   0   1^C
[root@centos79 ~]#

3.4.显示内存的相关信息

命令:

dstat -m

[root@centos79 ~]# dstat -m
------memory-usage-----
 used  buff  cach  free
7118M 1176k 1383M 1477M
7118M 1176k 1383M 1477M
7118M 1176k 1383M 1477M^C
[root@centos79 ~]#

3.5.显示page相关的统计数据

命令:

dstat -g

[root@centos79 ~]# dstat -g
---paging--
  in   out 
   0     0 
   0     0 
   0     0 
   0     0 ^C
[root@centos79 ~]#

3.6.显示磁盘相关的统计数据

命令:

dstat -d

[root@centos79 ~]# dstat -d
-dsk/total-
 read  writ
 415k   33k
   0     0 
   0     0 ^C
[root@centos79 ~]#

3.7.显示网络相关的统计数据

命令:

dstat -n

[root@centos79 ~]# dstat -n
-net/total-
 recv  send
   0     0 
1476B 1802B
  16k   16k
1476B 1754B
2482B 2746B^C
[root@centos79 ~]#

3.8.显示进程相关的统计数据

命令:

dstat -p

[root@centos79 ~]# dstat -p
---procs---
run blk new
  0   0 1.5
  0   0   0
  0   0   0
  0   0   0^C
[root@centos79 ~]#

3.9.显示io请求相关的统计数据

命令:

dstat -r

[root@centos79 ~]# dstat -r
--io/total-
 read  writ
10.2  2.04 
   0     0 
   0     0 
   0     0 ^C
[root@centos79 ~]#

3.10.显示swap相关的统计数据

命令:

dstat -s

[root@centos79 ~]# dstat -s
----swap---
 used  free
   0  3072M
   0  3072M
   0  3072M
   0  3072M^C
[root@centos79 ~]#

3.11.启用tcp的统计数据

命令:

dstat --tcp

[root@centos79 ~]# dstat --tcp
----tcp-sockets----
lis act syn tim clo
 35  28   0   0   0
 35  28   0   0   0
 35  28   0   0   0^C
[root@centos79 ~]#

3.12.启用udp的统计数据

命令:

dstat --udp

[root@centos79 ~]# dstat --udp
--udp--
lis act
 10   0
 10   0
 10   0
 10   0^C
[root@centos79 ~]#

3.13.启用raw的统计数据

命令:

dstat --raw

[root@centos79 ~]# dstat --raw
raw
raw
  0
  0
  0
  0^C
[root@centos79 ~]#

3.14.启用socket的统计数据

命令:

dstat --socket

[root@centos79 ~]# dstat --socket
------sockets------
tot tcp udp raw frg
  3  46   7   0   0
  3  46   7   0   0
  3  46   7   0   0
  3  46   7   0   0^C
[root@centos79 ~]#

3.15.显示最占用 cpu 的进程

命令:

dstat --top-cpu

[root@centos79 ~]# dstat --top-cpu
-most-expensive-
  cpu process   
java         1.4
java         1.0
node         0.5^C
[root@centos79 ~]#

3.16.显示最占用 io 的进程

命令:

dstat --top-io

[root@centos79 ~]# dstat --top-io
----most-expensive----
     i/o process      
bash        278k 7109B
java        133k  932B
java       2806B    0 
vmtoolsd     11k    0 ^C
[root@centos79 ~]#

3.17.显示最占用内存的进程

dstat --top-mem

[root@centos79 ~]# dstat --top-mem
--most-expensive-
  memory process 
java        4535M
java        4535M
java        4535M^C
[root@centos79 ~]#
【版权声明】本文内容来自摩杜云社区用户原创、第三方投稿、转载,内容版权归原作者所有。本网站的目的在于传递更多信息,不拥有版权,亦不承担相应法律责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@moduyun.com

  1. 分享:
最后一次编辑于 2023年12月15日 0

暂无评论

推荐阅读
wwLZeziuqjLR