[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

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