[Linux] 系统资源统计工具 dstat

1. 默认统计指标

dstat 不带参数,默认参数参考下例,连续打印,1条记录/s
dstat 3 5 输出时间间隔为3秒钟,总共输出5次(实际会有6行,第一行是针对之前的数据统计),每行记录在3s内会不断刷新

[root@xxx bin]# dstat 3 5
----total-cpu-usage---- -dsk/total- -net/total- ---paging-- ---system--
usr sys idl wai hiq siq| read  writ| recv  send|  in   out | int   csw
  0   0 100   0   0   0|  70B 2299B|   0     0 |   0     0 |  25    12
  0   0 100   0   0   0|   0     0 | 447B  113B|   0     0 |  24    14
  0   0 100   0   0   0|   0     0 | 646B  113B|   0     0 |  27    15
  0   0 100   0   0   0|   0  2731B| 539B  113B|   0     0 |  28    17
  0   0 100   0   0   0|   0     0 | 755B  107B|   0     0 |  27    18
  0   0 100   0   0   0|   0     0 | 554B  107B|   0     0 |  24    14
[root@xxx bin]#

2.显示其它统计指标

-l :显示负载统计
-m :显示内存使用
-r :显示I/O统计
-s :显示交换分区使用
-t :第一列显示当前实际
–-tcp :显示常用的TCP统计
–-socket :显示网络统计数据
-–freespace :显示当前磁盘空间使用率
-–proc-count :显示正在运行的程序数量

[root@xxx bin]# dstat -m 3 2
------memory-usage-----
 used  buff  cach  free
 304M  176M 2213M 12.9G
 304M  176M 2213M 12.9G
 304M  176M 2213M 12.9G
[root@xxx bin]# dstat -l 3 2
---load-avg---
 1m   5m  15m
   0    0    0
   0    0    0
   0    0    0
[root@xxx bin]# dstat -r 3 2
--io/total-
 read  writ
0.00  0.22
   0     0
   0     0
[root@xxx bin]# dstat -s 3 2
----swap---
 used  free
   0    16G
   0    16G
   0    16G
[root@xxx bin]# dstat -t
----system----
  date/time
12-03 16:19:51
12-03 16:19:52
12-03 16:19:53
12-03 16:19:54
12-03 16:19:55^C
[root@xxx bin]# 
[root@xxx bin]# dstat -t -c -m
----system---- ----total-cpu-usage---- ------memory-usage-----
  date/time   |usr sys idl wai hiq siq| used  buff  cach  free
12-03 16:20:28|  0   0 100   0   0   0| 304M  176M 2213M 12.9G
12-03 16:20:29|  0   0 100   0   0   0| 304M  176M 2213M 12.9G
12-03 16:20:30|  0   0 100   0   0   0| 304M  176M 2213M 12.9G^C
[root@xxx bin]#

3.将结果输写入csv文件

dstat –-output <csv file path> 输出结果写到一个csv格式

[root@xxx bin]# dstat --output test22.csv --tcp
----tcp-sockets----
lis act syn tim clo
 11   8   0   0   0
 11   8   0   0   0
 11   8   0   0   0
 11   8   0   0   0^C
[root@xxx bin]# cat test22.csv
"Dstat 0.7.0 CSV output"
"Author:","Dag Wieers <[email protected]>",,,,"URL:","http://dag.wieers.com/home-made/dstat/"
"Host:","xxx",,,,"User:","root"
"Cmdline:","dstat --output test22.csv --tcp",,,,"Date:","12 Mar 2020 16:39:01 CST"

"tcp sockets",,,,
"lis","act","syn","tim","clo"
11.0,8.0,0.0,0.0,0.0
11.0,8.0,0.0,0.0,0.0
11.0,8.0,0.0,0.0,0.0
11.0,8.0,0.0,0.0,0.0
[root@xxx bin]#

 

更多选项参考 man dstat
--top-bio
       show most expensive block I/O process
--top-cpu
       show most expensive CPU process
--top-cputime
       show process using the most CPU time (in ms)
--top-cputime-avg
       show process with the highest average timeslice (in ms)
--top-io
       show most expensive I/O process
--top-latency
       show process with highest total latency (in ms)
--top-latency-avg
       show process with the highest average latency (in ms)
--top-mem
       show process using the most memory
--top-oom
       show process that will be killed by OOM the first

 

参考资料:Linux终端下dstat监控工具 https://linux.cn/article-3215-1.html

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章