linux 效能分析工具dstat之一

wisdomone1發表於2019-11-18

文章目錄

  • linux效能分析圖表

  • dstat概述

  • 前提條件

  • dstat語義

  • dstat命令示例


linux效能分析圖表

dstat概述

      linux雖然有iostat或vmstat相關工具,dstat提供另一種可以監控磁碟及CPU或網路等效能瓶頸的全新方法。可以豐富分析診斷作業系統效能故障手段。

前提條件

[root@three57 ~]# more /etc/redhat-release 
Red Hat Enterprise Linux Server release 6.8 (Santiago)


[root@three57 ~]# dstat -V
Dstat 0.7.0

dstat語義

[root@three57 ~]# dstat --help
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
  --bw, --blackonwhite   change colors for white background terminal
  --float                force float values on screen
  --integer              force integer values on screen
  --nocolor              disable colors (implies --noupdate)
  --noheaders            disable repetitive headers
  --noupdate             disable intermediate updates
  --output file          write CSV output to file
delay is the delay in seconds between each update (default: 1)
count is the number of updates to display before exiting (default: unlimited)

dstat命令示例

2,預設顯示分為5個部分
第一部分  cpu部分
第二部分  磁碟讀寫
第三部分  網路卡傳送及接收
第四部分  換頁換出
第五部分  上下文切換及中斷
[root@three57 ~]# dstat
----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|  76k   47k|   0     0 |   0     1B|  29   825 
  0   0 100   0   0   0|   0     0 |  66B  826B|   0     0 |  40    94 
  0   0 100   0   0   0|   0     0 |  66B  346B|   0     0 |  11    37 
  0   0 100   0   0   0|   0     0 |  66B  346B|   0     0 |  33    92 
  0   0  99   1   0   0|   0    56k|  66B  346B|   0     0 |  20    47 
  0   1  99   0   0   0|   0     0 |  66B  346B|   0     0 |  35    95 
  0   0 100   0   0   0|   0     0 |  66B  346B|   0     0 |  14    46 
  0   0 100   0   0   0|   0     0 |  66B  346B|   0     0 |  33    92 
  0   0 100   0   0   0|   0     0 |  66B  346B|   0     0 |  13    41 
  0   0 100   0   0   0|   0     0 |  66B  346B|   0     0 |  32    93 
  0   0 100   0   0   0|   0     0 |  66B  346B|   0     0 |  15    40 
  1   0  99   0   0   0|   0     0 |  66B  346B|   0     0 |  34    93 
  0   0 100   0   0   0|   0     0 |  66B  346B|   0     0 |  11    37
3,顯示檔案系統
[root@three57 ~]# dstat  --fs
--filesystem-
files  inodes
 2752  37079 
 2752  37079 
 2752  37079 
 2752  37079 
 2752  37079 
 2752  37079 
 2752  37079 
 2752  37079 ^C
[root@three57 ~]# 
4,顯示系統負載
[root@three57 ~]# dstat  --load
---load-avg---
 1m   5m  15m 
0.07 0.12 0.17
0.07 0.12 0.17
0.07 0.12 0.17
0.07 0.12 0.17^C
[root@three57 ~]# 
5,顯示記憶體
[root@three57 ~]# dstat --mem
------memory-usage-----
 used  buff  cach  free
 540M 56.1M 1169M  113M
 540M 56.1M 1169M  113M
 540M 56.1M 1169M  113M
 540M 56.1M 1169M  113M^C
 6,顯示程式
 [root@three57 ~]# dstat --proc
---procs---
run blk new
  0   0 0.6
  0   0   0
  0   0   0
  0   0   0
  0   0   0
  0   0   0^C
[root@three57 ~]# 
7,顯示時間
[root@three57 ~]# dstat --time
----system----
  date/time   
18-11 23:21:09
18-11 23:21:10
18-11 23:21:11
18-11 23:21:12
18-11 23:21:13
18-11 23:21:14
18-11 23:21:15
18-11 23:21:16
18-11 23:21:17^C
[root@three57 ~]# 
[root@three57 ~]# dstat --time --mem
----system---- ------memory-usage-----
  date/time   | used  buff  cach  free
18-11 23:21:37| 540M 56.1M 1169M  113M
18-11 23:21:38| 540M 56.1M 1169M  113M
18-11 23:21:39| 540M 56.1M 1169M  113M
18-11 23:21:40| 540M 56.1M 1169M  113M^C
8,顯示opoch
[root@three57 ~]# dstat --time --mem --epoch
----system---- ------memory-usage----- --epoch---
  date/time   | used  buff  cach  free|  epoch   
18-11 23:22:19| 540M 56.1M 1169M  113M|1574090539
18-11 23:22:20| 540M 56.1M 1169M  113M|1574090540
18-11 23:22:21| 540M 56.1M 1169M  113M|1574090541
18-11 23:22:22| 540M 56.1M 1169M  113M|1574090542^C
9,顯示aio
[root@three57 ~]# dstat --time --aio
----system---- async
  date/time   | #aio
18-11 23:22:50|2661B
18-11 23:22:51|2661B
18-11 23:22:52|2661B
18-11 23:22:53|2661B
18-11 23:22:54|2661B^C
10,顯示ipc
[root@three57 ~]# dstat --time --ipc
----system---- --sysv-ipc-
  date/time   |msg sem shm
18-11 23:23:18|  0   2   5
18-11 23:23:19|  0   2   5
18-11 23:23:20|  0   2   5^C
11,顯示鎖
[root@three57 ~]# dstat --time --lock
----system---- ---file-locks--
  date/time   |pos lck rea wri
18-11 23:23:48| 33 5.0   0  38
18-11 23:23:49| 33 5.0   0  38
18-11 23:23:50| 33 5.0   0  38
18-11 23:23:51| 33 5.0   0  38^C
12,顯示socket
[root@three57 ~]# dstat --time --socket
----system---- ------sockets------
  date/time   |tot tcp udp raw frg
18-11 23:24:26|391   9   7   0   0
18-11 23:24:27|391   9   7   0   0
18-11 23:24:28|391   9   7   0   0
18-11 23:24:29|391   9   7   0   0
18-11 23:24:30|391   9   7   0   0^C
13,顯示tcp
[root@three57 ~]# dstat --time --tcp
----system---- ----tcp-sockets----
  date/time   |lis act syn tim clo
18-11 23:24:52| 12   3   0   0   0
18-11 23:24:53| 12   3   0   0   0
18-11 23:24:54| 12   3   0   0   0
18-11 23:24:55| 12   3   0   0   0
18-11 23:24:56| 12   3   0   0   0
18-11 23:24:57| 12   3   0   0   0
18-11 23:24:58| 12   3   0   0   0
18-11 23:24:59| 12   3   0   0   0^C
14,顯示所有可用外掛
[root@three57 ~]# dstat --time --list
internal:
	aio, cpu, cpu24, disk, disk24, disk24old, epoch, fs, int, int24, io, ipc, load, lock, mem, net, page, page24, proc, raw, socket, swap, swapold, sys, tcp, time, udp, unix, vm
/usr/share/dstat:
	battery, battery-remain, cpufreq, dbus, disk-util, fan, freespace, gpfs, gpfs-ops, helloworld, innodb-buffer, innodb-io, innodb-ops, lustre, memcache-hits, mysql-io, mysql-keys, mysql5-cmds, mysql5-conn, mysql5-io, 
	mysql5-keys, net-packets, nfs3, nfs3-ops, nfsd3, nfsd3-ops, ntp, postfix, power, proc-count, rpc, rpcd, sendmail, snooze, thermal, top-bio, top-cpu, top-cputime, top-cputime-avg, top-io, top-latency, top-latency-avg, 
	top-mem, top-oom, utmp, vm-memctl, vmk-hba, vmk-int, vmk-nic, vz-cpu, vz-io, vz-ubc, wifi
15,重定向到一個檔案
[root@three57 ~]# dstat --time --aio --output /dstat.log
----system---- async
  date/time   | #aio
18-11 23:27:33|2661B
18-11 23:27:34|2661B
18-11 23:27:35|2661B
18-11 23:27:36|2661B
18-11 23:27:37|2661B
18-11 23:27:38|2661B
18-11 23:27:39|2661B
18-11 23:27:40|2661B
18-11 23:27:41|2661B^C
[root@three57 ~]# more /dstat.log 
"Dstat 0.7.0 CSV output"
"Author:","Dag Wieers <dag@wieers.com>",,,,"URL:","http://dag.wieers.com/home-made/dstat/"
"Host:","three57",,,,"User:","root"
"Cmdline:","dstat --time --aio --output /dstat.log",,,,"Date:","18 Nov 2019 23:27:33 CST"
"system","async"
"date/time","#aio"
18-11 23:27:33,2661.0
18-11 23:27:34,2661.0
18-11 23:27:35,2661.0
18-11 23:27:36,2661.0
18-11 23:27:37,2661.0
18-11 23:27:38,2661.0
18-11 23:27:39,2661.0
18-11 23:27:40,2661.0
18-11 23:27:41,2661.0	


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/9240380/viewspace-2664721/,如需轉載,請註明出處,否則將追究法律責任。

相關文章