From dc9e3e81596242ecb313751de7408bc48a5aae45 Mon Sep 17 00:00:00 2001 From: geekpi Date: Wed, 15 Jan 2014 03:07:34 +0000 Subject: [PATCH] [Translated] Linux iostat Command to Report CPU Statistics and IO Statistics --- ...Report CPU Statistics and IO Statistics.md | 113 ------------------ ...Report CPU Statistics and IO Statistics.md | 110 +++++++++++++++++ 2 files changed, 110 insertions(+), 113 deletions(-) delete mode 100644 sources/Linux iostat Command to Report CPU Statistics and IO Statistics.md create mode 100644 translated/Linux iostat Command to Report CPU Statistics and IO Statistics.md diff --git a/sources/Linux iostat Command to Report CPU Statistics and IO Statistics.md b/sources/Linux iostat Command to Report CPU Statistics and IO Statistics.md deleted file mode 100644 index 4099fced52..0000000000 --- a/sources/Linux iostat Command to Report CPU Statistics and IO Statistics.md +++ /dev/null @@ -1,113 +0,0 @@ -Translating-------------geekpi - - -Linux iostat Command to Report CPU Statistics and I/O Statistics -================================================================================ -A Central Processing Unit or CPU is the brain of the computer. All of processing command is run here. Input / Ouput or I/O also play critical roles. The disks is used to provide data to processor and keeps the data which has been processed by CPU. One of the methods for measuring processor utilization and I/O utilization is to use **iostat** command. From its utilization we can decide do we need to add more resources or not. - -### What is iostat ### - -iostat command is a command that used for monitoring system input/output device loading by observing the time the devices are active in relation to their average transfer rates. The iostat create reports that can be used to change system configuration to better balance the input/output between physical disks. - -### Installing iostat ### - -iostat is included in **sysstat** package. If you don’t have it, you need to install first. - -#### On RedHat / CentOS / Fedora #### - - # yum install sysstat - -#### On Debian / Ubuntu / Linux Mint #### - - $ sudo apt-get install sysstat - -#### How to run iostat #### - -To run it, just **type iostat** in your console. Here’s a sample. - - $ iostat - -![iostat default report](http://linoxide.com/wp-content/uploads/2013/12/iostat_default.png) - -#### Here’s how to read iostat reports #### - -#### The first section contains CPU report #### - -- **%user** : show the percentage of CPU utilization that occured while executing at the user (application) level -- **%nice** : show the percentage of CPU utilization that occured while executing at the user level with nice priority -- **%system** : show the percentage of CPU utilization that occured while executing at the system (kernel) level -- **%iowait** : show the percentage of the time that the CPU or CPUs were idle during whcih the system had an outstanding disk I/O request -- **%steal** : show the percentage of time spent in involuntary wait by the virtual CPU or CPUs while the hypervisor was servicing another virtual processor -- **%idle** : show the percentage of time that the CPU or CPUs were idle and the system did not have an outstanding disk I/O request - -#### The second section contains device utilization report #### - -- **Device** : device / partition name as listed in **/dev** directory -- **tps** : show the number of transfers per second that were issued to the device. Higher tps means the processor is busier -- **Blk_read/s** : show the amount of data read from the device expressed in a number of blocks (kilobytes, megabytes) per second -- **Blk_wrtn/s** : show the amount of data written to the device expressed in a number of blocks (kilobytes, megabytes) per second -- **Blk_read** : show the total number of blocks read -- **Blk_wrtn** : show the total number of blocks written - -### Capture iostat with kilobytes or megabytes ### - -By default iostat measure the I/O system with bytes unit. To make it easier to read, we can convert iostat to show us reports in kilobytes or megabytes unit. Just add **-k parameter** to create reports with **kilobytes unit** and **-m parameter** to create reports with **megabytes unit**. - - $ iostat -k - -![iostat with kilobytes](http://linoxide.com/wp-content/uploads/2013/12/iostat_k.png) - - $ iostat -m - -![iostat megabytes unit](http://linoxide.com/wp-content/uploads/2013/12/iostat_m.png) - -To extend the reports we can use **-x parameter** after iostat command. - - $ iostat -x - -![extend iostat report](http://linoxide.com/wp-content/uploads/2013/12/iostat_x.png) - -### Using iostat with delay ### - -Same with [vmstat][1], as a statistic tool the best way to use it is with delay parameter. With delay, we can see what’s the trend. Here are some samples to run iostat with delay. - -#### Run iostat with kilobytes unit, 2 seconds interval with 3 times reports #### - - $ iostat -k 2 3 - -![iostat reports in kilobytes](http://linoxide.com/wp-content/uploads/2013/12/iostat_k_2_3.png) - -#### Show CPU only report with 3 seconds interval and 6 times reports #### - - $ iostat -c 3 6 - -![iostat cpu only with delay 3 seoncds](http://linoxide.com/wp-content/uploads/2013/12/iostat_c_3_6.png) - -#### Show hda2 and hda6 device only report with 2 seconds interval and 4 times reports #### - - $ iostat -d hda2 hda6 2 4 - -![iostat disk only](http://linoxide.com/wp-content/uploads/2013/12/iostat_d_hda2_hda6_2_4.png) - -### Files ### - -iostat use these files to create reports. - -**/proc/stat** which contains system statistics -**/proc/partitions** which contains disk statistics (for pre 2.5 kernel that have been patched) -**/proc/diskstats** contains disks statistics (for post 2.5 kernel) -**/sys** which contains statistics for block devices (post 2.5 kernel) - -### Conclusion ### - -With vmstat to monitor memory usage, iostat to monitor CPU usage and I/O system then we have a complete tool to monitor three critical components in your machine. One of the advantage of those tools is you can run them without root privilege. You can dig it deeper by exploring iostat manual page. Just type **man iostat** in your console to bring iostat manual page. - --------------------------------------------------------------------------------- - -via: http://linoxide.com/linux-command/linux-iostat-command/ - -译者:[译者ID](https://github.com/译者ID) 校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出 - -[1]:http://linoxide.com/linux-command/linux-vmstat-command-tool-report-virtual-memory-statistics/ diff --git a/translated/Linux iostat Command to Report CPU Statistics and IO Statistics.md b/translated/Linux iostat Command to Report CPU Statistics and IO Statistics.md new file mode 100644 index 0000000000..5b976897ea --- /dev/null +++ b/translated/Linux iostat Command to Report CPU Statistics and IO Statistics.md @@ -0,0 +1,110 @@ +Linux 下报告CPU和I/O报告命令iostat +================================================================================ +一个通用处理单元挥着CPU是一台电脑的大脑。所有的处理命令运行在上面。输入/输出或者I/O同样扮演了一个重要的角色。硬盘被用于提供数据给处理器并保存已被CPU处理的数据。一种恒来那个处理器和I/O利用率的方法是使用**iostat**命令。从它们的利用率,我们可以决定是否该增加更多资源。 + +### iostat 是什么 ### + +iostat是一个通过观察设备的活跃时间和他们平均传输率之间的管理来监视系统输入/输出设备负载的命令。iostat可以生成一个用于改变系统系统从而更好在输入/输出和物理硬盘间取得平衡的报告。 + +### 安装 iostat ### + +iostat包含在**sysstat**包内。如果你没有,你首先需要安装它。 + +#### 在 RedHat / CentOS / Fedora #### + + # yum install sysstat + +#### 在 Debian / Ubuntu / Linux Mint #### + + $ sudo apt-get install sysstat + +#### 如何运行 iostat #### + +要运行它,只需在控制台下**输入iostat**。下面是一个例子。 + + $ iostat + +![iostat 默认报告](http://linoxide.com/wp-content/uploads/2013/12/iostat_default.png) + +#### 下面是如何读取iostat默认报告 #### + +#### 第一部分包含了CPU报告 #### + +- **%user** : 显示了在执行用户(应用)层时的CPU利用率 +- **%nice** : 显示了在执行以nice后的优先级运行用户层的CPU利用率 +- **%system** : 显示了在执行系统(内核)层时的CPU利用率 +- **%iowait** : 显示了CPU在有未完成的I/O请求时空闲时间的百分比 +- **%steal** : 显示了当hypervisor正服务于另外一个虚拟处理器时无意识地等待虚拟CPU所占有的时间百分比。 +- **%idle** : 请求时空闲时间的百分比 + +#### 第二部分包含了设备利用率报告 #### + +- **Device** : 设备/分区名字列在 **/dev** 目录 +- **tps** : 显示每秒传输给设备的数量。更高的tps意味着处理器更忙。 +- **Blk_read/s** : 显示了每秒从设备上读取的块的数量(KB,MB) +- **Blk_wrtn/s** : 显示了每秒写入设备上块的数量(KB,MB) +- **Blk_read** : 显示所有已读取的块 +- **Blk_wrtn** : 显示所有已写入的块 + +### 以KB或MB捕捉iostat ### + +默认上,iostat以B为单位衡量I/O系统。为了更便于阅读,我们可以iostat将报告转换成以KB或者MB为单位。只需要加入**-k参数**来创建以**KB为单位**,**-m参数**来创建以**MB为单位**。 + + $ iostat -k + +![以KB为单位的iostat](http://linoxide.com/wp-content/uploads/2013/12/iostat_k.png) + + $ iostat -m + +![以MB为单位的iostat](http://linoxide.com/wp-content/uploads/2013/12/iostat_m.png) + +要扩展报告,我们可以在iostat后面跟上**-x选项**。 + + $ iostat -x + +![扩展iostat报告](http://linoxide.com/wp-content/uploads/2013/12/iostat_x.png) + +### 带延迟使用iostat ### + +和[vmstat][1]一样,作为一个统计工具,最好带延迟参数来使用它。带了它,我们可以看到趋势。这里有一些带延时运行iostat的示例。 + +#### 以KB为单位,2秒间隔,运行3次的方式运行iostat #### + + $ iostat -k 2 3 + +![iostat以KB来报告](http://linoxide.com/wp-content/uploads/2013/12/iostat_k_2_3.png) + +#### 只显示CPU报告,并以3秒为间隔,报告6次 #### + + $ iostat -c 3 6 + +![以3秒为间隔,只显示iostat](http://linoxide.com/wp-content/uploads/2013/12/iostat_c_3_6.png) + +#### Show hda2 and hda6 device only report with 2 seconds interval and 4 times reports #### + + $ iostat -d hda2 hda6 2 4 + +![只显示硬盘的iostat](http://linoxide.com/wp-content/uploads/2013/12/iostat_d_hda2_hda6_2_4.png) + +### 文件 ### + +iostat使用这些文件来创建报告。 + +**/proc/stat** 包含了系统统计 +**/proc/partitions** 包含磁盘统计 (对于2.5以前的已打过补丁的内核) +**/proc/diskstats** 包含磁盘统计 (对于2.5以后的内核) +**/sys** 包含块设备统计 (2.5以后内核) + +### 总结 ### + +vmstat用于监视内存使用,iostat用于监视CPU使用率和I/O系统,这样我们就有了完整的工具来监视你机器中三个重要的组件。这些工具的一个好处是你无需使用特权运行它们。你可以浏览iostat的手册来深入了解。只需在控制台下输入**man iostat**就可进入iostat手册界面。 + +-------------------------------------------------------------------------------- + +via: http://linoxide.com/linux-command/linux-iostat-command/ + +译者:[geekpi](https://github.com/geekpi) 校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出 + +[1]:http://linoxide.com/linux-command/linux-vmstat-command-tool-report-virtual-memory-statistics/