yum -y install dstat
-cdngy
, 并会有提示You did not select any stats, using -cdngy by default.
dstat [-afv] [options..] [delay] [count]
# 查看 cpu 使用率汇总信息
[root@192-168-248-80 ~]# dstat -c
----total-cpu-usage----
usr sys idl wai hiq siq
1 0 99 0 0 0
1 0 98 0 0 0
# 同上
[root@192-168-248-80 ~]# dstat --cpu
----total-cpu-usage----
usr sys idl wai hiq siq
1 0 99 0 0 0
1 1 98 0 0 0
# 查看特定 cpu 使用率信息
[root@192-168-248-80 ~]# dstat -c -C 1,3
-------cpu1-usage--------------cpu3-usage------
usr sys idl wai hiq siq:usr sys idl wai hiq siq
1 0 99 0 0 0: 1 0 99 0 0 0
1 2 97 0 0 0: 1 1 98 0 0 0
# -C total, 等价于 -c 或 --cpu
[root@192-168-248-80 ~]# dstat -cC total
----total-cpu-usage----
usr sys idl wai hiq siq
1 0 99 0 0 0
1 1 98 0 0 0
[root@192-168-248-80 ~]# dstat --top-cpu
-most-expensive-
cpu process
k3s agent 0.2
java 0.2
# 查看磁盘读写汇总信息
[root@192-168-248-80 ~]# dstat -d
-dsk/total-
read writ
4001B 131k
0 0
# 查看特定磁盘读写信息
[root@192-168-248-80 ~]# dstat -dD sda,sdb
--dsk/sda-----dsk/sdb--
read writ: read writ
3894B 14k: 104B 117k
0 0 : 0 0
[root@192-168-248-80 ~]# dstat -r
--io/total-
read writ
0.15 2.07
0 0
# util 高则表示繁忙
[root@192-168-248-80 ~]# dstat --disk-util
sda--sdb-
util:util
0.41:0.04
0: 0
[root@192-168-248-80 ~]# dstat --top-io
----most-expensive----
i/o process
dockerd 507k 217k
dockerd 1109k 360k
[root@192-168-248-80 ~]# dstat --top-bio
----most-expensive----
block i/o process
dockerd 1B 54k
java 0 8192B
[root@192-168-248-80 ~]# dstat -m
------memory-usage-----
used buff cach free
34.4G 2212k 8434M 209G
34.4G 2212k 8434M 209G
[root@192-168-248-80 ~]# dstat -s
----swap---
used free
0 10G
0 10G
[root@192-168-248-80 ~]# dstat --top-mem
--most-expensive-
memory process
java 3127M
java 3127M
[root@192-168-248-80 ~]# dstat --top-oom
--out-of-memory---
kill score
java 1.0k
java 1.0k
# 查看网卡传输汇总信息
[root@192-168-248-80 ~]# dstat -n
-net/total-
recv send
0 0
41k 40k
# 查看特定网卡传输信息
[root@192-168-248-80 ~]# dstat -nN em1
--net/em1--
recv send
0 0
6442B 9112B
[root@192-168-248-80 ~]# dstat --socket
------sockets------
tot tcp udp raw frg
4 143 4 0 0
4 143 4 0 0
[root@192-168-248-80 ~]# dstat --tcp
----tcp-sockets----
lis act syn tim clo
11 132 0 0 0
11 132 0 0 0
[root@192-168-248-80 ~]# dstat --udp
--udp--
lis act
4 0
4 0
[root@192-168-248-80 ~]# dstat --proc-count
proc
tota
626
626
[root@192-168-248-80 ~]# dstat -p
---procs---
run blk new
0 0 3.1
0 0 0
[root@192-168-248-80 ~]# dstat -l
---load-avg---
1m 5m 15m
0.59 0.80 0.64
0.59 0.80 0.64
# 展示文件总数和inode数
[root@192-168-248-80 ~]# dstat --fs
--filesystem-
files inodes
11136 172k
11136 172k
# 日期时间
[root@192-168-248-80 ~]# dstat -t
----system----
time
01-04 19:23:49
01-04 19:23:50
# 从 epoch 到现在的秒数
[root@192-168-248-80 ~]# dstat -T
--epoch---
epoch
1617276248
1617276249
# int 代表系统中断次数, csw 代表上下文切换次数
[root@192-168-248-80 ~]# dstat -y
---system--
int csw
9886 19k
17k 34k
[root@192-168-248-80 ~]# dstat -i
----interrupts---
150 151 152
3 1 0
0 0 0
# 数值为 0 最佳, 数值越高, 交换越高, 性能越差
[root@192-168-248-80 ~]# dstat -g
---paging--
in out
0 0
0 0
# 不显示颜色
[root@192-168-248-80 ~]# dstat -c --nocolor
----total-cpu-usage----
usr sys idl wai hiq siq
1 0 99 0 0 0
1 1 98 0 0 0
[root@192-168-248-80 ~]# dstat --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-tps, disk-util, dstat, dstat-cpu, dstat-ctxt, dstat-mem, 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, qmail, rpc, rpcd, sendmail, snooze, squid, test, thermal, top-bio,
top-bio-adv, top-childwait, top-cpu, top-cpu-adv, top-cputime, top-cputime-avg, top-int, top-io, top-io-adv,
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
# delay 为 3, count 为 5; 3 秒统计一次, 共打印5次
dstat --top-cpu --top-mem -r --top-io 3 5
# 文件路径要写全
dstat --output ~/a.csv
# 时间, 负载, cpu最大进程, 上下文切换, 内存最大进程, swap, IO数据量&请求数, IO最大进程, 块IO最大进程, 1秒统计一次, 打印3次
[root@192-168-248-80 ~]# dstat -tl --top-cpu -g --top-mem -s -rd --top-io --top-bio 1 3
----system---- ---load-avg--- -most-expensive- ---paging-- --most-expensive- ----swap--- --io/total- -dsk/total- ----most-expensive---- ----most-expensive----
time | 1m 5m 15m | cpu process | in out | memory process | used free| read writ| read writ| i/o process | block i/o process
02-04 11:24:05|0.52 0.51 0.70|k3s agent 0.2| 0 0 |java 3127M| 0 10G|0.12 2.26 |3070B 124k|dockerd 510k 217k|sshd 1373B 58k
02-04 11:24:06|0.56 0.52 0.71|beam.smp 0.4| 0 0 |java 3127M| 0 10G| 0 0 | 0 0 |dockerd 753k 172k|dockerd 0 4096B
02-04 11:24:07|0.56 0.52 0.71|beam.smp 0.2| 0 0 |java 3127M| 0 10G| 0 0 | 0 0 |dockerd 751k 325k|java 0 4096B
02-04 11:24:08|0.56 0.52 0.71|k3s agent 0.6| 0 0 |java 3127M| 0 10G| 0 7.00 | 0 64k|dockerd 752k 247k|java 0 8192B