Linux命令(129)之dstat

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 ~]# 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
dstat是一个用于监视系统资源使用情况的命令行工具。它提供了全面的系统性能统计信息,并可以实时显示CPU、内存、磁盘、网络等方面的数据。下面是对dstat命令的详细解释: 1. 安装dstat:在大多数Linux发行版中,dstat已经预装了。如果没有安装,可以使用包管理器来安装。例如,在Debian/Ubuntu上可以使用以下命令安装: ``` sudo apt-get install dstat ``` 2. 基本用法:运行dstat命令即可获取实时的系统统计信息,默认情况下,每秒更新一次数据。例如: ``` dstat ``` 3. 参数选项: - `-c`:显示CPU信息,包括每个CPU核心的使用率、上下文切换次数等。 - `-d`:显示磁盘信息,包括每个磁盘的读写速度、I/O等待时间等。 - `-m`:显示内存信息,包括内存使用量、交换分区使用量等。 - `-n`:显示网络信息,包括每个网络接口的传输速率、连接数等。 - `-p`:显示进程信息,包括每个进程的CPU使用率、内存使用量等。 - `-r`:显示系统信息,包括系统负载、运行时间等。 - `-s`:显示系统调度信息,包括每个调度器的活动和等待时间等。 - `-t`:显示时间戳,以便更容易分析数据。 - `-y`:显示系统文件信息,包括打开的文件描述符数等。 - `-l`:显示磁盘I/O统计信息,包括每个磁盘的读写次数、读写延迟等。 4. 高级用法: - 可以使用`-a`选项来显示所有可用的统计信息。 - 可以使用`-p`选项加上进程ID来仅显示特定进程的统计信息。例如:`dstat -p PID`。 - 可以使用`-D`选项来指定一个逗号分隔的磁盘列表,仅显示指定磁盘的统计信息。例如:`dstat -D sda,sdb`。 - 可以使用`-C`选项来指定一个逗号分隔的CPU核心列表,仅显示指定核心的统计信息。例如:`dstat -C 0,1`。 以上就是对dstat命令的详细解释。通过使用dstat命令,你可以实时监视系统的各种资源使用情况,有助于定位系统性能问题和进行性能优化。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小黑要上天

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值