Comprovar el rendiment de la CPU i entrada/sortida de dispositius i particions amb iostat

Última modificació: setembre de 2015

El paquet sysstat en proporciona tres eines de monitorització:

    • vmstat: ens proporciona informació sobre la memòria, processos, paginació, block IO, traps i activitat de CPU i discs.
    • sar: ens proporciona dades històriques de rendiment i ús de recursos d'un sistema
    • iostat: ens proporciona informació sobre la CPU i dades de entrada i sortida de dispositius i particions

Anem a veure com podem utilitzar iostat. Si l'executem obtindrem alguna cosa semblant a això:

bmw@usbdes:~$ iostat

Linux 3.16.0-44-generic (UBDESPTX) 13/09/15 _x86_64_ (2 CPU)

avg-cpu: %user %nice %system %iowait %steal %idle

5,58 0,15 1,31 0,90 0,00 92,06

Device: tps kB_read/s kB_wrtn/s kB_read kB_wrtn

sda 2,90 47,31 92,93 5141358 10099544

A la pàgina man de iostat s'explica amb detall que vol dir cada camp:

CPU Utilization Report

The first report generated by the iostat command is the CPU Uti‐

lization Report. For multiprocessor systems, the CPU values are

global averages among all processors. The report has the fol‐

lowing format:

%user

Show the percentage of CPU utilization that occurred

while executing at the user level (application).

%nice

Show the percentage of CPU utilization that occurred

while executing at the user level with nice priority.

%system

Show the percentage of CPU utilization that occurred

while executing at the system level (kernel).

%iowait

Show the percentage of time that the CPU or CPUs were

idle during which 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 servic‐

ing 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.

Device Utilization Report

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 parti‐

tions for which statistics are to be displayed may be entered on

the command 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_COR‐

RECT is set, in which case 512-byte blocks are used. The report

may show the following fields, depending on the flags used:

Device:

This column gives the device (or partition) name as

listed in the /dev directory.

tps

Indicate the number of transfers per second that were

issued to the device. A transfer is an I/O request to the

device. Multiple logical requests can be combined into a

single I/O request to the device. A transfer is of inde‐

terminate size.

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 there‐

fore have a size of 512 bytes.

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.

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) writ‐

ten.

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 servic‐

ing them.

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 servic‐

ing 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 servic‐

ing 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.

Veure estadísitiques només de CPU:

iostat -c

Veure estadísitiques només de I/O de disc:

iostat -d

Veure estadísitiques d'un dispositiu determinat:

iostat -p sda (indicarem el dispositiu que vulguem)

Veure estadísitiques de LVM:

iostat -N