vmstat

Vmstat es un comando que nos permite obtener un detalle general de los procesos, E/S, uso de memoria/swap, estado del sistema y actividad del CPU. Es esencial para entender que esta pasando en tu sistema, detectar cuellos de botella, etc..

Para usarlo, podemos correrlo sin parámetros, y obtendremos algo similar a esto:

System configuration: lcpu=2 mem=4096MB ent=0.40

$ vmstat

procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu------

 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st

 0  0 397132 795284 853808 22016848    2    2  1923   693    0   15  2  0 88 10  0

$

La primera línea es simple, se divide en seis categorías: procesos, memoria, swap, E/S, sistema y CPU.

La segunda un detalle abierto de cada categoría superior.

Los campos mostrados en relación a los a procesos son:

r: El número de procesos ejecutables esperando para acceder al CPU.

b: El número de procesos en un estado dormido continuo.

Los campos relacionados a la memoria son:

swpd: La cantidad de memoria utilizada.

free: La cantidad de memoria libre.

buff: La cantidad de memoria utilizada por las memorias intermedias.

cache: La cantidad de memoria utilizada como caché de páginas.

Los campos relacionados a swap son:

si: La cantidad de memoria intercambiada desde el disco.

so: La cantidad de memoria intercambiada hacia el disco.

Los campos relacionados con E/S son:

bi: Los bloques enviados a un dispositivo de bloques.

bo: Los bloques recibidos desde un dispositivo de bloques.

Los campos relacionados al sistema son:

in: El número de interrupciones por segundo.

cs: El número de cambios de contexto por segundo.

Los campos relacionados al CPU son:

us: El porcentaje de tiempo que el CPU ejecutó código de nivel del usuario.

sy: El porcentaje de tiempo que el CPU ejecutó código de nivel del sistema.

id: El porcentaje de tiempo que el CPU estaba desocupado.

wa: Esperas de E/S.

Si se ejecuta el comando “vmstat” sin opciones, nos muestra una unica línea, que contiene promedios calculados desde la última vez que se arrancó el sistema.

Si ejecutamos “vmstat 1? muestra una nueva línea de utilización de datos cada segundo, mientras que el comando “vmstat 1 10?, muestra una nueva línea por segundo, pero sólo por los próximos 10 segundos.

Ejemplos:

Tomar 5 muestra de 2 seg de intervalo:

# vmstat 2 5

System configuration: lcpu=2 mem=4096MB ent=0.40

kthr    memory              page              faults              cpu

----- ----------- ------------------------ ------------ -----------------------

 r  b   avm   fre  re  pi  po  fr   sr  cy  in   sy  cs us sy id wa    pc    ec

 2  0 376033 333158   0   0   0   0    0   0  21  420 248  0  4 96  0  0.02   4.8

 2  0 376032 333159   0   0   0   0    0   0   1   99 227  0  1 99  0  0.00   1.0

 2  0 376032 333159   0   0   0   0    0   0   3  106 220  0  1 99  0  0.00   1.0

 2  0 376032 333159   0   0   0   0    0   0   1  142 223  0  1 99  0  0.00   1.0

 2  0 376032 333159   0   0   0   0    0   0   3  111 225  0  0 99  0  0.00   0.8

Usando la flag -v

 If you specify the -v flag, the following statistics are displayed:

              compressed percentage

                   Percentage of memory used by compressed pages.

              client filesystem I/Os blocked with no fsbuf

                   Number of client filesystem I/O requests blocked because no fsbuf was available. NFS (Network File System) and VxFS (Veritas) are client

                   filesystems. Fsbuf are pinned memory buffers used to hold I/O requests in the filesystem layer.

              client pages

                   Number of client pages.

              compressed pages

                   Number of compressed memory pages.

              external pager filesystem I/Os blocked with no fsbuf

                   Number of external pager client filesystem I/O requests blocked because no fsbuf was available. JFS2 is an external pager client

                   filesystem. Fsbuf are pinned memory buffers used to hold I/O requests in the filesystem layer.

              file pages

                   Number of 4 KB pages currently used by the file cache.

              free pages

                   Number of free 4 KB pages.

              filesystem I/Os blocked with no fsbuf

                   Number of filesystem I/O requests blocked because no fsbuf was available. Fsbuf are pinned memory buffers used to hold I/O requests in

                   the filesystem layer.

              lruable pages

                   Number of 4 KB pages considered for replacement. This number excludes the pages used for VMM internal pages, and the pages used for the

                   pinned part of the kernel text.

              maxclient percentage

                   Tuning parameter (managed using vmo) specifying the maximum percentage of memory which can be used for client pages.

              maxperm percentage

                   Tuning parameter (managed using vmo) in percentage of real memory. This specifies the point above which the page stealing algorithm

                   steals only file pages.

              maxpin percentage

                   Tuning parameter (managed using vmo) specifying the percentage of real memory which can be pinned.

              memory pages

                   Size of real memory in number of 4 KB pages.

              memory pools

                   Tuning parameter (managed using vmo) specifying the number of memory pools.

              minperm percentage

                   Tuning parameter (managed using vmo) in percentage of real memory. This specifies the point below which file pages are protected from the

                   re-page algorithm.

              numclient percentage

                   Percentage of memory occupied by client pages.

              numperm percentage

                   Percentage of memory currently used by the file cache.

# vmstat -v

              1048576 memory pages

              1005056 lruable pages

               333168 free pages

                    2 memory pools

               303953 pinned pages

                 90.0 maxpin percentage

                  3.0 minperm percentage

                 90.0 maxperm percentage

                 32.7 numperm percentage

               329510 file pages

                  0.0 compressed percentage

                    0 compressed pages

                 32.7 numclient percentage

                 90.0 maxclient percentage

               329510 client pages

                    0 remote pageouts scheduled

                    0 pending disk I/Os blocked with no pbuf

                    0 paging space I/Os blocked with no psbuf

                 2228 filesystem I/Os blocked with no fsbuf

                    0 client filesystem I/Os blocked with no fsbuf

                    8 external pager filesystem I/Os blocked with no fsbuf

                 36.8 percentage of memory used for computational pages

#

Fuente: Internet, consola, man.