Merge pull request #1615 from cvsher/master

Linux Performance Monitoring with Vmstat and Iostat Commands翻译完成
下回不要改文件名:》
This commit is contained in:
Xingyu.Wang 2014-09-14 10:20:29 +08:00
commit 892eba3195

View File

@ -1,42 +1,39 @@
translating by cvsher
Linux Performance Monitoring with Vmstat and Iostat Commands
================================================================================
This is our on-going series of commands and performance monitoring in **Linux**. **Vmstat** and **Iostat** both commands are available on all major **Unix-like (Linux/Unix/FreeBSD/Solaris)** Operating Systems.
使用Vmstat和Iostat命令进行Linux性能监控
================================================================
这是我们正在进行的**Linux**命令和性能监控系列的一部分。**Vmstat**和**Iostat**两个命令都适用于所有主要的类**unix**系统(**Linux/unix/FreeBSD/Solaris**)。
如果**vmstat**和**iostat**命令在你的系统中不可用,请安装**sysstat**软件包。**vmstat****sar**和**iostat**命令都包含在**sysstat**系统监控工具软件包中。iostat命令生成**CPU**和所有设备的统计信息。你可以从连接[sysstat][1]中下载源代码包编译安装sysstat但是我们建议通过**YUM**命令进行安装。
If **vmstat** and **iostat** commands are not available on your box, please install **sysstat** package. The **vmstat**, **sar** and **iostat** commands are the collection of package included in **sysstat** the system monitoring tools. The iostat generates reports of **CPU** & all device statistics. You may download and install **sysstat** using source tarball from link [sysstat][1], but we recommend installing through **YUM** command.
![使用Vmstat和Iostat命令进行Linux性能监控](http://www.tecmint.com/wp-content/uploads/2012/09/Linux-VmStat-Iostat-Commands.png)
![Linux Performance Monitoring with Vmstat and Iostat](http://www.tecmint.com/wp-content/uploads/2012/09/Linux-VmStat-Iostat-Commands.png)
使用Vmstat和Iostat命令进行Linux性能监控
Linux Performance Monitoring with Vmstat and Iostat
###在Linux系统中安装sysstat###
### Install Sysstat in Linux ###
#yum -y install sysstat
# yum -y install sysstat
- **vmstat** - 内存,进程和分页等的简要信息。
- **iostat** - CPU统计信息设备和分区的输入/输出统计信息。
- **vmstat** Summary information of Memory, Processes, Paging etc.
- **iostat** Central Processing Unit (CPU) statistics and input/output statistics for devices and partitions.
### Linux下vmstat命令的6个范例###
### 6 Vmstat Command Examples in Linux ###
####1. 列出活动和非活动的内存####
#### 1. List Active and Inactive Memory ####
如下范例中输出6列。**vmstat**的man页面中解析的每一列的意义。最重要的是内存中的**free**属性和交换分区中是**si**和**so**属性。
In the below example, there are six columns. The significant of the columns are explained in man page of **vmstat** in details. Most important fields are **free** under memory and **si**, **so** under swap column.
[root@tecmint ~]# vmstat -a
[root@tecmint ~]# vmstat -a
procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu-----
procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu-----
r b swpd free inact active si so bi bo in cs us sy id wa st
1 0 0 810420 97380 70628 0 0 115 4 89 79 1 6 90 3 0
- **Free** Amount of free/idle memory spaces.
- **si** Swaped in every second from disk in Kilo Bytes.
- **so** Swaped out every second to disk in Kilo Bytes.
- **Free** 空闲的内存空间
- **si** 每秒从磁盘中交换进内存的数据量以KB为单位
- **so** 每秒从内存中交换出磁盘的数据量以KB为单位
**Note**: If you run **vmstat** without parameters itll displays summary report since system boot.
**注意**:如果你不带参数的执行**vmstat**命令,它会输出自系统启动以来的总结报告。
#### 2. Execute vmstat X seconds and (Nnumber of times) ####
With this command, **vmstat** execute every two seconds and stop automatically after executing six intervals.
####2. 每X秒执行vmstat共执行N次####
下面命令将会每2秒中执行一次**vmstat**执行6次后自动停止执行。
[root@tecmint ~]# vmstat 2 6
@ -49,9 +46,10 @@ With this command, **vmstat** execute every two seconds and stop automatically a
0 0 0 810412 22064 101368 0 0 0 0 17 35 0 0 100 0 0
0 0 0 810412 22064 101368 0 0 0 0 18 36 0 1 100 0 0
#### 3. Vmstat with timestamps ####
####3. 带时间戳的vmstat命令####
带**-t**参数执行**vmstat**命令,该命令将会在每一行输出后都带一个时间戳,如下所示。
**vmstat** command with **-t** parameter shows timestamps with every line printed as shown below.
[tecmint@tecmint ~]$ vmstat -t 1 5
@ -63,9 +61,10 @@ With this command, **vmstat** execute every two seconds and stop automatically a
0 0 0 631780 24992 192244 0 0 0 0 156 524 0 5 95 0 0 2012-09-02 14:57:21 IST
1 0 0 631656 24992 192244 0 0 0 0 189 592 0 5 95 0 0 2012-09-02 14:57:22 IST
#### 4. Statistics of Various Counter ####
####4. 统计各种计数器####
**vmstat**命令的**-s**参数,将输出各种事件计数器和内存的统计信息。
**vmstat** command and -s switch displays summary of various event counters and memory statistics.
[tecmint@tecmint ~]$ vmstat -s
@ -96,9 +95,9 @@ With this command, **vmstat** execute every two seconds and stop automatically a
1346574857 boot time
2309 forks
#### 5. Disks Statistics ####
####5. 磁盘统计信息####
**vmstat** with **-d** option display all disks statistics.
**vmstat**的**-d**参数将会输出所有磁盘的统计信息。
[tecmint@tecmint ~]$ vmstat -d
@ -133,9 +132,9 @@ With this command, **vmstat** execute every two seconds and stop automatically a
dm-0 11578 0 659242 1113017 32163 0 257384 8460026 0 126
dm-1 324 0 2592 3845 0 0 0 0 0 2
#### 6. Display Statistics in Megabytes ####
####6. 以MB为单位输出统计信息####
The **vmstat** displays in **Megabytes** with parameters **-S** and **M**(Uppercase & megabytes). By default **vmstat** displays statistics in kilobytes.
**vmstat**的**-S**和**-M**参数大写和MB将会以MB为单位输出。**vmstat**默认以KB为单位输出统计信息。
[root@tecmint ~]# vmstat -S M 1 5
@ -147,11 +146,11 @@ The **vmstat** displays in **Megabytes** with parameters **-S** and **M**(Upperc
0 0 0 346 53 476 0 0 0 0 15 13 0 0 100 0 0
0 0 0 346 53 476 0 0 0 0 34 61 0 1 99 0 0
### 6 Iostat Command Examples in Linux ###
###linux下的Iostat命令的6个范例###
#### 7. Display CPU and I/O statistics ####
####1. 输出CPU和输入/输出I/O的统计信息####
**iostat** without arguments displays **CPU** and **I/O** statistics of all partitions as shown below.
不带参数的**iostat**命令将会输出**CPU**和每个分区的**输出/输出**的统计信息,如下所示。
[root@tecmint ~]# iostat
@ -165,9 +164,9 @@ The **vmstat** displays in **Megabytes** with parameters **-S** and **M**(Upperc
dm-0 5.76 159.71 13.47 1077154 90864
dm-1 0.05 0.38 0.00 2576 0
#### 8. Shows only CPU Statistics ####
####2. 只输出CPU的统计信息####
**iostat** with **-c** arguments displays only **CPU** statistics as shown below.
**iostat**命令的**-c**参数仅输出**CPU**的统计信息,如下所示。
[root@tecmint ~]# iostat -c
@ -176,9 +175,9 @@ The **vmstat** displays in **Megabytes** with parameters **-S** and **M**(Upperc
avg-cpu: %user %nice %system %iowait %steal %idle
0.12 0.01 1.47 1.98 0.00 96.42
#### 9. Shows only Disks I/O Statistics ####
####3. 只输出磁盘的输入/输出统计信息####
**iostat** with **-d** arguments displays only disks **I/O** statistics of all partitions as shown.
**iostat**命令的**-d**参数仅输出磁盘的所有分区的**输入/输出**的统计信息,如下所示。
[root@tecmint ~]# iostat -d
@ -189,9 +188,9 @@ The **vmstat** displays in **Megabytes** with parameters **-S** and **M**(Upperc
dm-0 5.37 148.59 12.65 1077154 91728
dm-1 0.04 0.36 0.00 2576 0
#### 10. Shows I/O statistics only of a single device. ####
####4. 只输出某个磁盘的输入/输出统计信息####
By default it displays statistics of all partitions, with **-p** and device name arguments displays only disks **I/O** statistics for specific device only as shown.
在默认情况下iostat命令会输出所有分区的统计信息但是若在iostat命令后加上**-p**参数和磁盘设备名,该命令将会仅输出列出的磁盘的输入/输出统计信息,如下所示。
[root@tecmint ~]# iostat -p sda
@ -205,9 +204,9 @@ By default it displays statistics of all partitions, with **-p** and device name
sda1 0.07 0.56 0.00 4120 18
sda2 3.22 147.79 12.55 1080650 91752
#### 11. Display LVM Statistics ####
####5. 输出逻辑卷管理LVM的统计信息####
With **-N** (Uppercase) parameter displays only **LVM** statistics as shown.
iostat命令的**-N**(大写)参数将会输出**LVM**LCTT译注[LVM][2]是linux环境下对磁盘分区进行管理的一种机制是磁盘分区和文件系统间的一个逻辑层的统计信息如下所示。
[root@tecmint ~]# iostat -N
@ -221,26 +220,27 @@ With **-N** (Uppercase) parameter displays only **LVM** statistics as shown.
vg_tecmint-lv_root 5.13 141.68 12.16 1077154 92448
vg_tecmint-lv_swap 0.04 0.34 0.00 2576 0
#### 12. iostat version. ####
####6. iostat版本信息####
With **-V** (Uppercase) parameter displays version of **iostat** as shown.
iostat的**-V**(大写)参数将会输出**iostat**的版本信息,如下所示。
[root@tecmint ~]# iostat -V
sysstat version 9.0.4
(C) Sebastien Godard (sysstat orange.fr)
**Note**: **vmstat** and **iostat** contains number of columns and flags which may not possible to explain in details. If you want to know more about it you may refer man page of **vmstat** and **iostat**. Please share it if you find this article is useful through our comment box below.
**注意****vmstat**和**iostat**的输出中包含多列的数据和标志,限于篇幅无法在本文中进行详细的解析。如果你想知道更多的信息,请查看**vmstat**和**iostat**的man帮助手册。如果你觉得本文对你有价值请在下面的评论框中与你的朋友分享。
--------------------------------------------------------------------------------
via: http://www.tecmint.com/linux-performance-monitoring-with-vmstat-and-iostat-commands/
作者:[Ravi Saive][a]
译者:[译者ID](https://github.com/译者ID)
译者:[cvsher](https://github.com/cvsher)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
[a]:http://www.tecmint.com/author/admin/
[1]:http://sebastien.godard.pagesperso-orange.fr/download.html
[2]:http://en.wikipedia.org/wiki/Logical_Volume_Manager_(Linux)