Merge pull request #1057 from disylee/master

Translated -by disylee 2014/5/26
This commit is contained in:
Xingyu.Wang 2014-05-26 21:39:34 +08:00
commit 894323209c
2 changed files with 142 additions and 121 deletions

View File

@ -1,121 +0,0 @@
disylee占个坑周末做2014/5/22
Linux Terminal: Dstat monitoring tools
================================================================================
Dstat is a versatile replacement for vmstat, iostat, netstat and ifstat. Dstat overcomes some of their limitations and adds some extra features, more counters and flexibility. Dstat is handy for monitoring systems during performance tuning tests, benchmarks or troubleshooting.
Dstat allows you to view all of your system resources in real-time, you can eg. compare disk utilization in combination with interrupts from your IDE controller, or compare the [network bandwidth][1] numbers directly with the disk throughput (in the same interval).
Dstat gives you detailed selective information in columns and clearly indicates in what magnitude and unit the output is displayed. Less confusion, less mistakes. And most importantly, it makes it very easy to write plugins to collect your own counters and extend in ways you never expected.
Dstats output by default is designed for being interpreted by humans in real-time, however you can export details to CSV output to a file to be imported later into Gnumeric or Excel to generate graphs.
### Features ###
- Combines vmstat, iostat, ifstat, netstat information and more
- Shows stats in exactly the same timeframe
- Enable/order counters as they make most sense during analysis/troubleshooting
- Modular design
- Written in python so easily extendable for the task at hand
- Easy to extend, add your own counters (please contribute those)
- Includes many external plugins to show how easy it is to add counters
- Can summarize grouped block/network devices and give total numbers
- Can show interrupts per device
- Very accurate timeframes, no timeshifts when system is stressed
- Shows exact units and limits conversion mistakes
- Indicate different units with different colors
- Show intermediate results when delay > 1
- Allows to export CSV output, which can be imported in Gnumeric and Excel to make graphs
### Installation ###
Ubuntu/Mint and Debian:
The package its available on the repository, so you can easily install it with the command:
# sudo apt-get install dstat
RHEL/Centos and Fedora:
The package its available in the rpmforge repository, so you can add it, see [this guide][2], and after that install it easily with the command:
# yum install dstat
ArchLinux:
The package its available in the community repository, so it can be easily installed with the command:
# pacman -S dstat
### Usage ###
The basic usage of dstat its just the command dstat that produces an output like this one:
![](http://cdn.linuxaria.com/wp-content/uploads/2014/05/dstat.png)
The default will show you these information:
**CPU stats**: What percentage of the CPU is in use. The more interesting sections of this report are user, system, and idle, which should break down most of the current CPU use. If you see high CPU use in the “wait” column there might be a problem elsewhere in the system. When a cpu “waits” its because its expecting a response from an I/O device (like memory, disk, or network) and hasnt received it yet.
**Disk stats**: Read and write activity to disks, this is the total for all of your disks.
**Net stats**: Data sent and received on network devices, this is the total of all of your network devices.
**Paging stats**: Paging activity on the system. Paging refers to a memory management technique used behind the scenes on your system. A high level of paging can indicate that the system is using a lot of swap space, or it could mean that memory is very fragmented, in general you want to see 0 0 for pages/in page/out.
**System stats**: This shows interrupts (int) and context switches (csw). These stats are usually only useful if you have a baseline to compare them to. Higher stats in these columns usually indicate a large number of processes jostling for the CPUs attention. Since your server is likely running many processes by default, there will always be some numbers there.
By default dstat reports new figures every second. To quit dstat you can use “control-C”.
Note that the first line of the report is typically going to show nothing for all stats.
Thats because dstat operates by summarizing what it saw since its last report. When it first runs theres no data to average or sum.
Its possible to control the delay between reports and the number of reports dstat will output in a run by passing 2 options. As example if you want dstat to run with default stats, wait 3 seconds between reports, and only report 10 results, you could run:
dstat 3 10
In dstat there are a lot of options, you can see all with the command man dstat, some of the most useful parameters are:
- -l = shows load statistics
- -m = shows the memory usage (used, buffer, cache, free)
- -r = displays I/O statistics,
- -s = shows the swap usage
- -t = puts the current time in the first column
- fs = displays file system stats (includes amount of files and used inodes)
- nocolor = sometimes very useful…
- socket = shows interesting network statistics
- tcp = displays common TCP stats
- udp = shows you the listen and active figures for the UDP usage
And thats not all, dstat ships with a number of **plugins** that extend its capabilities greatly. Its possible to check the directory /usr/share/dstat in order to view a list of them. Some of the most useful are:
- disk-util = shows how much the disks are busy at the moment
- freespace = shows the current disk usage
- proc-count = displays the number of running processes
- top-bio = points to the most expensive block I/O process
- top-cpu = draws the attention on the most expensive CPU process
- top-io = shows the most expensive “normal” I/O process
- top-mem = displays the process using the most memory
Some examples:
To see who is eating all the memory:
dstat -g -l -m -s --top-mem
To shows some stats about the CPU resource consumption:
dstat -c -y -l --proc-count --top-cpu
#### How to send to a csv file ####
To send the output to a csv file for later use we can issue the following command:
# dstat output /tmp/sampleoutput.csv -cdn
--------------------------------------------------------------------------------
via: http://linuxaria.com/howto/linux-terminal-dstat-monitoring-tools
译者:[译者ID](https://github.com/译者ID) 校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
[1]:http://linuxaria.com/tag/network
[2]:http://www.tecmint.com/install-and-enable-rpmforge-repository-in-rhel-centos-6-5-4/

View File

@ -0,0 +1,142 @@
Linux终端Dstat监控工具
================================================================================
Dstat 是一个可以取代vmstatiostatnetstat和ifstat这些命令的多功能产品。Dstat克服了这些命令的局限并增加了一些另外的功能比如增加了运算能力和变得更灵活了。Dstat在很方便监控系统运行状况并用于基准测试和排除故障。
Dstat可以让你实时地看到所有系统资源例如你能够通过中断IDE控制器来比较磁盘利用率或者直接通过网络带宽数来比较磁盘的吞吐率在相同的时间间隔内
Dstat将以列表的形式为你提供选项信息并清晰地告诉你是在何种幅度和单位显示输出。这样更好地避免了信息混乱和误报。更重要的是它让你更方便写插件来收集你想要的数据信息并且这种方式会令你意想不到。
Dstat的默认输出是专门为人们实时解释而设计的然而你却可以将详细信息通过CSV输出到一个文件或导入到Gnumeric或者Excel生成表格。
###特征###
- 结合了vmstatiostatifstatnetstat等信息
- 实时显示统计情况
- 运算结果在分析和排障时具有重要意义
- 模块化设计
- 使用python编写的更方便扩展现有的工作任务
- 容易扩展和添加你的计数器(请为此做出贡献)
- 包含了许多扩展插件以方便添加计数器
- 分组统计节点/网络设备总数
- 显示每台设备说明
- 极准确的时间帧,当系统负荷时不存在时间差
- 显示准确地单位和限制转换过程中产生的错误
- 用不同的颜色显示不同的单元内容
- 显示中间结果延时小于1秒
- 支持输出CSV格式报表并能导入到Gnumeric和Excel生成表格
### 安装方法 ###
Ubuntu/Mint和Debin系统
本地软件库中有相关安装包,你可以用下面命令安装:
# sudo apt-get install dstat
RHEL/Centos和Fedora系统:
你可以在romforge软件库中添加有相关安装包参照[2】指导后使用命令很简单就能进行安装
# yum install dstat
ArchLinux系统
相关软件包在社区资源库中,你可以用这个命令来安装:
# pacman -S dstat
###使用方法 ###
dstat的基本用法只是用dstat命令就会像这样输出
![](http://cdn.linuxaria.com/wp-content/uploads/2014/05/dstat.png)
这是默认输出显示的信息:
CPU状态CPU的使用率。这项报告更有趣的部分是显示了用户系统和空闲这更好地分析了CPU当前的使用状况。如果你看到"wait"一栏中CPU的状态是一个高使用率值那说明系统存在一些其它问题。当CPU的状态在"waits"时那是因为它正在等待I/O设备例如内存磁盘或者网络的响应而且还没有收到。
**磁盘统计**:磁盘的读写操作,这一栏显示磁盘的读写总数。
**网络统计**:网络设备发送和接受的数据,这一栏显示的网络收发数据的总数。
**分页统计**系统的分页活动。分页指的是一种内存管理技术用于查找系统场景一个高水平的分页表明系统正在使用大量的交换空间或者说内存非常分散大多数情况下你都希望看到page in和page out的值是0 0。
**系统统计**这一项显示的是中断int和文本转换csw。如果你需要一个基线来比较他们的话这项统计通常是唯一有用的。这一栏中较高的统计值通常表示大量的进程造成拥塞需要对CPU进行关注。当你的服务器默认情况下正在运行一些程序时那一项将会显示一些数值。
默认情况下dstat每秒都会刷新数据。如果想退出dstat你可以按"control-C"键。
需要注意的是报告的第一行通常所有统计都不显示数值的。
这是由于dstat会通过上一次的报告来给出一个总结。所以第一次运行时是没有平均值和总值的相关数据。
但是dstat可以通过传递2个参数运行输出来控制报告和报告数量之间的延迟。例如如果你想要dstat输出默认统计和报表输出的时间间隔未3秒钟,并且报表中输出10个结果你可以运行如下命令
dstat 3 10
在dstat命令中有很多参数可选你可以通过man dstat命令查看大多数常用的参数有这些
- -l = shows load statistics #显示加载统计量#
- -m = shows the memory usage (used, buffer, cache, free) #显示内存使用率包括usedbuffercachefree值#
- -r = displays I/O statistics, #显示I/O统计#
- -s = shows the swap usage #显示swap使用情况#
- -t = puts the current time in the first column #将当前时间显示在第一行#
- fs = displays file system stats (includes amount of files and used inodes)#显示系统数据包括文件总数量和inodes值#
- nocolor = sometimes very useful…
- socket = shows interesting network statistics #显示感兴趣的网络数据#
- tcp = displays common TCP stats #显示常用的CPU统计#
- udp = shows you the listen and active figures for the UDP usage #显示你监听的和UDP用法中的一些动态数据#
当然不止这些用法dstat附带了一些**插件**很大程度地扩展了它的功能。你可以通过查看/usr/share/dstat目录来查看它们的一些使用方法常用的有这些
- disk-util = shows how much the disks are busy at the moment#显示某一时间磁盘的忙碌状况#
- freespace = shows the current disk usage#显示当前磁盘使用率#
- proc-count = displays the number of running processes#显示正在运行的程序数量#
- top-bio = points to the most expensive block I/O process #指出最大块I/O进程#
- top-cpu = draws the attention on the most expensive CPU process#图形化显示最值得引起注意的CPU进程#
- top-io = shows the most expensive “normal” I/O process#显示大多数正常的I/O进程#
- top-mem = displays the process using the most memory#显示占用最多内存的进程#
举一些例子:
查看全部内存都有谁在占用:
dstat -g -l -m -s --top-mem
显示一些关于CPU资源损耗的数据
dstat -c -y -l --proc-count --top-cpu
###如何输出一个csv文件###
在往后的使用中想输出一个csv格式的文件可以通过下面的命令
# dstat output /tmp/sampleoutput.csv -cdn
--------------------------------------------------------------------------------
via: http://linuxaria.com/howto/linux-terminal-dstat-monitoring-tools
译者disylee (https://github.com/译者ID) 校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
[1]:http://linuxaria.com/tag/network
[2]:http://www.tecmint.com/install-and-enable-rpmforge-repository-in-rhel-centos-6-5-4/