Java OpenResty Spring Spring Boot MySQL Redis MongoDB PostgreSQL Linux Android Nginx 面试 小程序 Arthas JVM AQS juc Kubernetes Docker 诊断工具


Linux 使用 dstat 性能监测

Linux dstat 诊断工具 大约 4951 字

dstat

每隔一秒打印一次数据,一直打印,按Ctrl+C退出。

[root@root ~]$ dstat
----total-cpu-usage---- -dsk/total- -net/total- ---paging-- ---system--
usr sys idl wai hiq siq| read  writ| recv  send|  in   out | int   csw 
  1   0  98   0   0   0| 266B   43k|   0     0 |   6B   19B| 326  2520 
 21   2  77   0   0   0|   0     0 |2777k 1668k|   0     0 |  11k   15k
 40   4  54   0   0   1|   0  3028k|5668k 6909k|   0     0 |  25k   37k
 87   4   7   0   0   2|   0     0 |7906k   12M|   0     0 |  38k   47k
 41   5  53   0   0   2|   0   116k|6214k 6331k|   0     0 |  27k   47k
 30   3  66   0   0   1|   0     0 |6705k 3710k|   0     0 |  20k   30k
 31   3  65   0   0   1|   0     0 |5535k 3714k|   0     0 |  20k   28k
 59   4  35   0   0   1|   0  6416k|5021k 4834k|   0     0 |  26k   33k
 41   5  52   0   0   2|   0     0 |7074k   10M|   0     0 |  29k   46k
 30   3  65   0   0   1|   0    64k|5420k 6597k|   0     0 |  21k   33k
 25   2  72   0   0   1|   0     0 |4101k 2887k|   0     0 |  16k   21k
 57   2  41   0   0   1|   0     0 |3863k 2723k|   0     0 |  19k   23k
 44   2  54   0   0   0|   0     0 |4678k 3037k|   0     0 |  18k   22k
 19   1  79   0   0   0|   0  4424k|3643k 2486k|   0     0 |  14k   20k
 19   2  79   0   0   0|   0   148k|4592k 3614k|   0   124k|  19k   29k
 46   6  46   0   0   2|   0     0 |7200k   11M|   0     0 |  34k   56k
 61   5  32   0   0   1|   0     0 |5913k 7486k|   0     0 |  28k   42k
 26   2  71   0   0   1|   0     0 |4230k 2858k|   0     0 |  17k   24k
 59   2  38   0   0   1|   0  6912k|4091k 2669k|   0     0 |  20k   25k
 21   2  77   0   0   0|   0   644k|3404k 2362k|   0     0 |  13k   15k^C

dstat 3 10

每隔3秒打印一次数据,输出10次并退出。

输出为一个csv文件

dstat -output ./output.csv -cdn

显示信息

  • total-cpu-usage CPU使用率
    • usr:用户空间的程序所占百分比;
    • sys:系统空间程序所占百分比;
    • idel:空闲百分比;
    • wai:等待磁盘I/O所消耗的百分比;
    • hiq:硬中断次数;
    • siq:软中断次数;
  • dsk/total 磁盘统计
    • read:读总数
    • writ:写总数
  • net/total 网络统计
    • recv:网络收包总数
    • send:网络发包总数
  • paging 内存分页统计
    • in: pagein(换入)
    • out:page out(换出)
    • 注:系统的分页活动。分页指的是一种内存管理技术用于查找系统场景,一个较大的分页表明系统正在使用大量的交换空间,通常情况下当系统已经开始用交换空间的时候,就说明内存已经不够用了,或者说内存非常分散,理想情况下page in(换入)和page out(换出)的值是0 0。
  • system 系统信息
    • int:中断次数
    • csw:上下文切换
    • 注:中断(int)和上下文切换(csw)。这项统计仅在有比较基线时才有意义。这一栏中较高的统计值通常表示大量的进程造成拥塞,需要对CPU进行关注。服务器一般情况下都会运行运行一些程序,所以这项总是显示一些数值。

常用参数

查看dstat能使用的所有参数

dstat --list
  • -l :显示负载统计量
  • -m :显示内存使用率(包括used,buffer,cache,free值)
  • -r :显示I/O统计
  • -s :显示交换分区使用情况
  • -t :将当前时间显示在第一行
  • --fs :显示文件系统统计数据(包括文件总数量和inodes值)
  • --nocolor :不显示颜色(有时候有用)
  • --socket :显示网络统计数据
  • --tcp :显示常用的TCP统计
  • --udp :显示监听的UDP接口及其当前用量的一些动态数据
  • --disk-util :显示某一时间磁盘的忙碌状况
  • --freespace :显示当前磁盘空间使用率
  • --proc-count :显示正在运行的程序数量
  • --top-bio :指出块I/O最大的进程
  • --top-cpu :图形化显示CPU占用最大的进程
  • --top-io :显示正常I/O最大的进程
  • --top-mem :显示占用最多内存的进程

帮助文档

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)
阅读 2824 · 发布于 2019-09-03

————        END        ————

Give me a Star, Thanks:)

https://github.com/fendoudebb

扫描下方二维码关注公众号和小程序↓↓↓

扫描二维码关注我
昵称:
随便看看 换一批