Linux系统监控——dstat 工具的使用

官方对dstat的定义为:多功能系统资源统计生成工具。

在获取的信息上有点类似于top、free、iostat、vmstat等多个工具的合集,官方解释为vmstat、iostat、ifstat等工具的多功能替代品,且添加了许多额外的功能(Dstat is a versatile replacement for vmstat, iostat and ifstat. Dstat overcomes some of the limitations and adds some extra features.);其结果可以保持到csv文件,使用脚本或第三方工具对性能进行分析利用(如通过监控平台监控,也可以保持到数据库)。

在Centos 6.x系统上安装基本服务器即默认安装,而在其他操作系统可能需要手动安装。

e.g.

  • 监控CPU、内存、swap、磁盘使用率,并输出到csv。recordTime 是每条记录的间隔时间,以 秒 为单位。recordNum 是记录数。
$ dstat -tcms --freespace --disk-util --output /home/TempFold/status.csv recordTime recordNum

此处的输出是追加模式。

  • 找出占用资源最高的进程和用户
    --top-(io|bio|cpu|cputime|cputime-avg|mem) 通过这几个选项,可以看到具体是那个用户那个进程占用了相关系统资源,对系统调优非常有效。如查看当前占用I/O、cpu、内存等最高的进程信息可以使用
$ dstat --top-mem --top-io --top-cpu

部分dstat的插件

  • --disk-util :显示某一时间磁盘的忙碌状况
  • --freespace :显示当前磁盘空间使用率
  • --proc-count :显示正在运行的程序数量
  • --top-bio :指出块I/O最大的进程
  • --top-cpu :图形化显示CPU占用最大的进程
  • --top-io :显示正常I/O最大的进程
  • --top-mem :显示占用最多内存的进程

查看:

$ 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-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

参考:
http://www.cnblogs.com/vincent-hv/p/3358194.html
http://linux.cn/article-3215-1.html
http://linux.die.net/man/1/dstat

dstat完整参数
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,统计文件打开文件数和inodes数
  
  --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插件

While anyone can create their own dstat plugins (and contribute them) dstat ships with a number of plugins already that extend its capabilities greatly.

Here is an overview of the plugins dstat ships with:

参数含义
--batterybattery in percentage (needs ACPI)
--battery-remainbattery remaining in hours, minutes (needs ACPI)
--cpufreqCPU frequency in percentage (needs ACPI)
--dbusnumber of dbus connections (needs python-dbus)
--disk-util硬盘使用百分率。per disk utilization in percentage
--fanfan speed (needs ACPI)
--freespace每个硬盘使用情况。per filesystem disk usage
--gpfsGPFS read/write I/O (needs mmpmon)
--gpfs-opsGPFS filesystem operations (needs mmpmon)
--helloworldHello world example dstat plugin
--innodb-buffershow innodb buffer stats
--innodb-ioshow innodb I/O stats
--innodb-opsshow innodb operations counters
--lustreshow lustre I/O throughput
--memcache-hitsshow the number of hits and misses from memcache (needs the memcache module)
--mysql5-cmdsshow the MySQL5 command stats
--mysql5-connshow the MySQL5 connection stats
--mysql5-ioshow the MySQL5 I/O stats
--mysql5-keysshow the MySQL5 keys stats
--mysql-ioshow the MySQL I/O stats
--mysql-keysshow the MySQL keys stats
--net-packetsshow the number of packets received and transmitted
--nfs3show NFS v3 client operations
--nfs3-opsshow extended NFS v3 client operations
--nfsd3show NFS v3 server operations
--nfsd3-opsshow extended NFS v3 server operations
--ntpshow NTP time from an NTP server
--postfixshow postfix queue sizes (needs postfix)
--powershow power usage
--proc-countshow total number of processes
--rpcshow RPC client calls stats
--rpcdshow RPC server calls stats
--sendmailshow sendmail queue size (needs sendmail)
--snoozeshow number of ticks per second
--testshow test plugin output
--thermalsystem temperature sensors
--top-bioshow most expensive block I/O process
--top-cpushow most expensive CPU process
--top-cputimeshow process using the most CPU time (in ms)
--top-cputime-avgshow process with the highest average timeslice (in ms)
--top-ioshow most expensive I/O process
--top-latencyshow process with highest total latency (in ms)
--top-latency-avgshow process with the highest average latency (in ms)
--top-memshow process using the most memory
--top-oomshow process that will be killed by OOM the first
--utmpshow number of utmp connections (needs python-utmp)
--vmk-hbashow VMware ESX kernel vmhba stats
--vmk-intshow VMware ESX kernel interrupt stats
--vmk-nicshow VMware ESX kernel port stats
--vm-memctlshow ballooning status inside VMware guests
--vz-ioshow CPU usage per OpenVZ guest
--vz-ubcshow OpenVZ user beancounters
--wifiwireless link quality and signal to noise ratio

转载于:https://www.cnblogs.com/DamianZhou/p/4186826.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值