简介
对于有磁盘操作的应用来说,查找性能问题,就应监控磁盘I/O。其中磁盘I/O使用率是最有用的监控数据。磁盘I/O使用率,即磁盘处于活动时间的百分比,磁盘在数据传输和处理命令(如寻道)时处于活动状态。磁盘利用率与资源争用程度成正比,与性能成反比。也就是说磁盘利用率越高,资源争用就越严重,性能也就越差,响应时间就越长。一般来说,如果磁盘利用率超过 70%,应用进程将花费较长的时间等待 I/O 完成,因为绝大多数进程在等待过程中将被阻塞或休眠。
语法
iostat [ -c ] [ -d ] [ -h ] [ -k | -m ] [ -N ] [ -t ] [ -V ] [ -x ] [ -y ] [ -z ] [ -j { ID | LABEL | PATH | UUID | ... } ] [ [ -T ] -g
group_name ] [ -p [ device [,...] | ALL ] ] [ device [...] | ALL ] [ interval [ count ] ]
描述
iostat命令用来监控系统的I/O设备负载,通过监视设备处于活动状态的时间,而不是它们的平均传输速率。iostat产生的报告可以用来协助修改系统配置,以在物理磁盘之间达到更好的I/O负载均衡。
iostat命令产生的第一条报告给出自系统启动以来的设备处于活动状态的时间,除非显示的指定了-y选项(这种情况下,第一行会被忽略)。接下来的报告是自上一次报告以来的时间。iostat
命令每运行一次产生一条全量统计报告。报告包含一个CPU行以及若干行CPU统计数据。在多处理器系统中,CPU统计数据是所有处理器的平均值。接下来的一行是设备头,以及每个设备的统计数据。
interval参数指定每次报告的间隔,以秒为单位。count参数可以在指定了interval后指定,该参数决定产生报告的次数。如果指定了interval参数后没有指定count参数,iostat命令会一直产生报告。
报告
iostat命令产生两种类型的报告,CPU利用率报告和设备利用率报告。
CPU利用率报告
iostat命令产生的第一个报告是CPU利用率报告。对于多处理器系统,这里的值是所有处理器的全局平均值。
%user
Show the percentage of CPU utilization that occurred while executing at the user level (application).
用户态的CPU利用率
%nice
Show the percentage of CPU utilization that occurred while executing at the user level with nice priority.
以nice优先级执行的用户态(应用)的CPU利用率
%system
Show the percentage of CPU utilization that occurred while executing at the system level (kernel).
系统态的CPU利用率。
%iowait
Show the percentage of time that the CPU or CPUs were idle during which the system had an outstanding disk I/O request.
系统有未处理的磁盘I/O请求造成的CPU(s)空闲的时间比例。
%steal
Show the percentage of time spent in involuntary wait by the virtual CPU or CPUs while the hypervisor was servicing another
virtual processor.
虚拟CPU(s)由于hypervisor正在服务其他虚拟处理器的被迫等待时间。
Hypervisor——一种运行在基础物理服务器和操作系统之间的中间软件层,可允许多个操作系统和应用共享硬件。也可叫做VMM( virtual machine monitor ),即虚拟机监视器。
%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.
系统没有未处理的磁盘I/O请求,且CPU(s)空闲的时间比例。
设备利用率报告
The second report generated by the iostat command is the Device Utilization Report. The device report provides statistics on a per
physical device or partition basis. Block devices and partitions for which statistics are to be displayed may be entered on the com‐
mand line. If no device nor partition is entered, then statistics are displayed for every device used by the system, and providing
that the kernel maintains statistics for it. If the ALL keyword is given on the command line, then statistics are displayed for
every device defined by the system, including those that have never been used. Transfer rates are shown in 1K blocks by default,
unless the environment variable POSIXLY_CORRECT is set, in which case 512-byte blocks are used. The report may show the following
fields, depending on the flags used:
iostat命令产生的第二个报告是设备利用率报告。设备报告提供每个物理设备或分区的统计数据。
Device:
This column gives the device (or partition) name as listed in the /dev directory.
显示/dev目录中列出的设备(或分区)名称。
tps
Indicate the number of transfers per second that were issued to the device. A transfer is an I/O request to the device. Mul‐
tiple logical requests can be combined into a single I/O request to the device. A transfer is of indeterminate size.
指示该设备每秒的传输次数。一次传输是该设备的一次I/O请求,多个逻辑请求可以合并成一个单独的I/O请求。一次传输的大小是不确定的。
Blk_read/s (kB_read/s, MB_read/s)
Indicate the amount of data read from the device expressed in a number of blocks (kilobytes, megabytes) per second. Blocks
are equivalent to sectors and therefore have a size of 512 bytes.
指示每秒从该设备读取的数据总量,以块为单位。块和扇区相等,因此是512bytes。
Blk_wrtn/s (kB_wrtn/s, MB_wrtn/s)
Indicate the amount of data written to the device expressed in a number of blocks (kilobytes, megabytes) per second.
指示每秒写入该设备的数据总量,以块为单位。块和扇区相等,因此是512bytes。
Blk_read (kB_read, MB_read)
The total number of blocks (kilobytes, megabytes) read.
读取的块总量。
Blk_wrtn (kB_wrtn, MB_wrtn)
The total number of blocks (kilobytes, megabytes) written.
写入的块总量。
rrqm/s
The number of read requests merged per second that were queued to the device.
在该设备排队的读请求,每秒合并的数目。
wrqm/s
The number of write requests merged per second that were queued to the device.
在该设备排队的写请求,每秒合并的数目。
r/s
The number (after merges) of read requests completed per second for the device.
该设备每秒完成的读请求(合并后)数目。
w/s
The number (after merges) of write requests completed per second for the device.
该设备每秒完成的读请求(合并后)数目。
rsec/s (rkB/s, rMB/s)
The number of sectors (kilobytes, megabytes) read from the device per second.
每秒读取的扇区数目
wsec/s (wkB/s, wMB/s)
The number of sectors (kilobytes, megabytes) written to the device per second.
每秒写入的扇区数目
avgrq-sz
The average size (in sectors) of the requests that were issued to the device.
该设备的请求的平均大小(以扇区为单位)
avgqu-sz
The average queue length of the requests that were issued to the device.
该设备的请求的平均队列长度。
await
The average time (in milliseconds) for I/O requests issued to the device to be served. This includes the time spent by the
requests in queue and the time spent servicing them.
该设备的I/O请求的平均处理时间(以毫秒为单位)。包括花费在队列以及处理的时间。
r_await
The average time (in milliseconds) for read requests issued to the device to be served. This includes the time spent by the
requests in queue and the time spent servicing them.
该设备的读请求的平均处理时间(以毫秒为单位)。包括花费在队列以及处理的时间。
w_await
The average time (in milliseconds) for write requests issued to the device to be served. This includes the time spent by the
requests in queue and the time spent servicing them.
该设备的写请求的平均处理时间(以毫秒为单位)。包括花费在队列以及处理的时间。
svctm
The average service time (in milliseconds) for I/O requests that were issued to the device. Warning! Do not trust this field
any more. This field will be removed in a future sysstat version.
已废除。
%util
Percentage of CPU time during which I/O requests were issued to the device (bandwidth utilization for the device). Device
saturation occurs when this value is close to 100% for devices serving requests serially. But for devices serving requests
in parallel, such as RAID arrays and modern SSDs, this number does not reflect their performance limits.
设备处于活动状态的时间的百分比(该设备的带宽利用率)。当该值接近100%时,设备接近饱和。但对于并行处理请求的设备,如RAID磁盘阵列、SSD,该值并不能反映他们的性能状态。
OPTIONS
-c Display the CPU utilization report.
显示CPU利用率报告。
-d Display the device utilization report.
显示磁盘利用率报告。
-g group_name { device [...] | ALL }
Display statistics for a group of devices. The iostat command reports statistics for each individual device in the list then a line
of global statistics for the group displayed as group_name and made up of all the devices in the list. The ALL keyword means that
all the block devices defined by the system shall be included in the group.
显示一组设备的统计数据。示例:iostat -h -g mygroup {sda,dm-0} 或者iostat -h -g mygroup sda dm-0
-h Make the Device Utilization Report easier to read by a human.
以友好格式展示磁盘利用率报告。
-j { ID | LABEL | PATH | UUID | ... } [ device [...] | ALL ]
Display persistent device names. Options ID, LABEL, etc. specify the type of the persistent name. These options are not limited,
only prerequisite is that directory with required persistent names is present in /dev/disk. Optionally, multiple devices can be
specified in the chosen persistent name type. Because persistent device names are usually long, option -h is enabled implicitly
with this option.
显示设备的固定名称。
-k Display statistics in kilobytes per second.
以kb/s为单位展示统计数据
-m Display statistics in megabytes per second.
以mb/s为单位展示统计数据
-N Display the registered device mapper names for any device mapper devices. Useful for viewing LVM2 statistics.
-p [ { device [,...] | ALL } ]
The -p option displays statistics for block devices and all their partitions that are used by the system. If a device name is
entered on the command line, then statistics for it and all its partitions are displayed. Last, the ALL keyword indicates that sta‐
tistics have to be displayed for all the block devices and partitions defined by the system, including those that have never been
used. If option -j is defined before this option, devices entered on the command line can be specified with the chosen persistent
name type.
-T This option must be used with option -g and indicates that only global statistics for the group are to be displayed, and not statis‐
tics for individual devices in the group.
该选项必须和-g选项一起使用,用来指定只显示全局统计数据。
-t Print the time for each report displayed. The timestamp format may depend on the value of the S_TIME_FORMAT environment variable
(see below).
打印每个报告的时间。
-V Print version number then exit.
显示版本
-x Display extended statistics.
显示扩展的统计信息。指定此选项来查看磁盘I/O利用率
-y Omit first report with statistics since system boot, if displaying multiple records at given interval.
忽略自系统起来以来的统计报告(第一条)
-z Tell iostat to omit output for any devices for which there was no activity during the sample period.
忽略采样周期中,处于不活动状态的设备的输出。
ENVIRONMENT
The iostat command takes into account the following environment variables:
S_TIME_FORMAT
If this variable exists and its value is ISO then the current locale will be ignored when printing the date in the report header.
The iostat command will use the ISO 8601 format (YYYY-MM-DD) instead. The timestamp displayed with option -t will also be compliant
with ISO 8601 format.
POSIXLY_CORRECT
When this variable is set, transfer rates are shown in 512-byte blocks instead of the default 1K blocks.
EXAMPLES
iostat
Display a single history since boot report for all CPU and Devices.
iostat -d 2
Display a continuous device report at two second intervals.
iostat -d 2 6
Display six reports at two second intervals for all devices.
iostat -x sda sdb 2 6
Display six reports of extended statistics at two second intervals for devices sda and sdb.
iostat -p sda 2 6
Display six reports at two second intervals for device sda and all its partitions (sda1, etc.)
相关推荐
### Linux IO实时监控iostat命令详解 #### 前言 在Linux系统管理与运维过程中,实时监控系统的I/O负载对于确保系统稳定性和性能至关重要。`iostat`工具作为一个强大的系统监视工具,能够帮助管理员监控系统中的磁盘...
linux系统监控工具汇总,包括vmstat、uptime、iostat、sar等各种监控工具的具体分析。
《Linux系统监控手册》 在IT领域,尤其是服务器运维中,Linux系统监控是至关重要的环节。通过对系统的实时监控,我们可以确保服务的稳定运行,及时发现并处理潜在的问题,避免故障的发生。这篇手册主要涵盖以下几个...
在Linux系统中,Cacti可以利用iostat命令来监控系统的输入/输出(I/O)性能,帮助管理员了解磁盘、块设备以及其他存储资源的使用情况。iostat是System Monitoring Suite(sysstat)的一部分,可以提供CPU利用率和I/O...
《鸟哥的 Linux 私房菜:基础学习...通过阅读这本书,初学者可以系统地建立起对Linux系统的理解,并具备日常操作和简单维护的能力。无论你是打算从事IT相关工作,还是希望提升个人技能,这本书都能为你提供宝贵的指导。
在运维和开发过程中,对Linux系统的性能监控是确保服务稳定性和效率的关键环节。本文将深入探讨Linux性能监控的重点,包括CPU、内存、IO和网络子系统的监控,以及如何针对不同类型的應用进行优化。 1. **CPU性能...
《经典 Linux系统性能监控 中文版》是一本深入浅出的Linux性能监控指南,它针对的是那些希望理解和优化Linux系统性能的技术人员。该书虽然基于较为传统的概念和技术,但其内容扎实,阐述清晰,覆盖了从基础到进阶的...
以上工具只是Linux系统监控的冰山一角,还有其他如`iostat`(磁盘I/O统计)、`netstat`(网络连接状态)、`htop`(增强版的`top`)等工具,都为管理员提供了宝贵的洞察力。了解并熟练使用这些工具,可以有效地管理和...
在Linux系统中,性能监控是确保系统稳定运行和优化资源使用的关键环节。本文将详细介绍几种常用的Linux性能监控工具,帮助你更好地理解系统状态并解决潜在问题。 1. **top** `top`命令是最基本的实时性能监控工具...
这份名为"Linux系统20个系统监控工具.zip"的资源包含了一份PDF文档,详细列举了20款常用的Linux系统监控工具,旨在帮助管理员更好地了解系统状态,及时发现并解决潜在问题。以下是这20个工具的详细介绍: 1. **top*...
文档中未直接提到这些内容,但运维人员需熟悉各种系统监控工具,如vmstat、iostat、top、htop等,以便及时发现系统瓶颈和进行性能优化。 8. 故障排除与安全:Linux系统运维还需要具备故障排除技能,以及了解如何...
- 学习使用各种系统监控工具,如top、htop、iostat、vmstat等。 - 理解CPU、内存、磁盘和网络的性能指标。 - 掌握性能问题的定位和调优技巧。 8. 内核调试技巧 - 学习使用kgdb、kdb、ftrace等内核调试工具。 -...
Linux系统监控是管理和维护服务器健康状态的关键工具,它允许管理员实时查看系统资源的使用情况,以便于优化性能、排查问题。本文将详细讲解两个常用的Linux监控命令:`top`和`vmstat`。 首先,`top`命令是Linux...
此外,Linux中还有许多专用于系统管理的命令,例如用于管理服务的chkconfig,用于权限管理的getenforce和getsebool,用于系统监控的iostat和free,以及用于定时任务的crontab。 Linux的文件系统支持多种类型,包括...
### Linux系统资源监控命令...以上介绍了几种常用的Linux系统资源监控命令,它们分别是`top`、`free`、`vmstat`和`iostat`。通过这些命令,我们可以有效地监控和管理Linux系统的资源使用情况,确保系统稳定高效地运行。
iostat命令是Linux系统中的一个重要工具,用于监控磁盘操作活动,提供了磁盘活动统计情况和CPU使用情况的信息。在这里,我们将详细介绍iostat命令的使用和参数解释。 iostat命令格式为:iostat [参数] [时间] [次数...
在Linux系统中,监控资源通常包括CPU使用率、内存占用、磁盘I/O、网络流量等关键指标。使用JMeter进行资源监控时,可以通过JMeter插件或者结合Linux自带的命令行工具来实现。例如,`top`或`htop`命令可以实时显示...
- 系统监控:使用vmstat、iostat、netstat等工具监控系统资源使用情况。 8. Shell脚本编程: - Bash基础知识:学习变量、条件语句、循环、函数等,编写简单的Shell脚本。 - 错误处理与调试:理解shell脚本中的...