+4 votes
250 views
How to use vmstat Linux command

in Linux / Unix by (552k points)
reopened | 250 views

1 Answer

+5 votes
Best answer

1. How to use vmstat on Linux
2. How to combine vmstat with slabinfo on Linux
3. How to generate a disk activity report with vmstat Linux
4. How to configure vmstat to add the timestamp to each Linux output line
5. How to display system event information
6. How to display exchange statistics

The Linux distributions offer us a series of commands and tools ideal to maintain the best control over every aspect of the server or system and this is useful if within our roles we must access detailed process information, CPU activity, memory , hard disk and more, because in this way we will know in which points of the system anomalies can occur and in this way take actions either administrative or support on them..

One of the best options to access this type of information is to use vmstat and TechnoWikis will explain what it is and how to use this tool in Linux.

What is vmstat
The vmstat tool has been developed in order to provide administrators with information about processes, memory, paging, block I / O, CPU activity, number of context changes, device interruptions and system calls in order to Access the best control details.

Vmstat generates a first report where details are accessed since the last boot, then additional values ​​are added that give in a specific length sampling period. Thanks to vmstat it will be possible to know in detail every aspect that plays a role within the system ..


1. How to use vmstat on Linux


The basic syntax of using vmstat is as follows:
 vmstat [options] [delay [count]] 
The first basic use option is to execute the following:
 Vmstat 
The result will be as follows: image

There we found a series of fields that are the following:

Procs
  • r: Indicate the number of core processes in the distribution queue
  • b: They are the number of kernel processes blocked while waiting for resources
  • w: Refers to the number of processes in space to be assigned
Memory
  • swpd: It is the amount of virtual memory used (KB)
  • free: It is the amount of inactive memory (KB)
  • buff: It is the amount of memory used as buffers (kB)
Swap
  • yes: Indicates the amount of memory brought from the swap space from the disk (kB / s)
  • so: It is the amount of exchange memory to disk (kB / s).
IO
  • bi: They are the blocks sent to a block device
  • bo: They are blocks received from a block device
System
  • in: Indicates the number of interruptions per second, including the clock
  • cs: The number of context changes per second
CPU
They are the percentages of total CPU time.
  • us: user time
  • sy: system time
  • id: idle time

In some cases we will see additional arguments such as:

Pages
  • re: Are the pages claimed
  • mf: Indicate secondary errors and important errors
  • pi: These are the kilobytes of pages loaded in memory
  • Po: They are the Kilobytes of pages extracted from memory
  • fr: Indicates the Kilobytes released
  • From: Is the expected memory required for process data that has been loaded into swap memory
  • Sr: These are the pages scanned by the daemon page that is not currently in use
Disk
Gives a report on the number of disk operations per second and displays data from up to four disks simultaneously
Faults
Create a report on catch and interrupt frequencies per second
  • In: It's interrupts per second
  • Sy: Are the system calls per second
  • Cs: Is the frequency of CPU context change

By default, vmstat generates the output only once, it is possible that vmstat automatically updates this output, for this it will be necessary to specify a numerical value as input for the command like this:

 vmstat 4 
image

Thus, each vmstat line will be updated every 4 seconds.


2. How to combine vmstat with slabinfo on Linux


Slabinfo is a file located in the / proc / slabinfo directory whose mission is to provide statistics on the caches of frequently used objects in the Linux kernel such as buffer heads, inodes, dentries and more.

To obtain this information we must use the -my parameter that it is vital that the Linux distribution kernel is compatible with slabinfo, to access this information we execute the following with sudo permissions:

 sudo vmstat -m 
image

3. How to generate a disk activity report with vmstat Linux


The vmstat command gives us the option to create a detailed report of hard disk activity, for this we must execute the following:
 vmstat -D 
information
This will give us information such as:
  • Number of discs
  • Number of partitions
  • Readings that have been merged
  • Amount of reading and writing
  • Sectors read and more
image

4. How to configure vmstat to add the timestamp to each Linux output line


This option is useful if we want to see in detail the data in which the reports are generated by vmstat, for this we will execute the following:
 vmstat -t 
image

5. How to display system event information


This alternative is practical to obtain complete information on the events that occur on the server to access to detail each point that may be affecting its general behavior.
If we want to see the system events we will execute the following:
 vmstat -s 
Values
This generates how many system events have been processed since the last time the system was started, as a result we find values ​​of:
  • Total memory, used, active and free
  • Exchange Cache
  • CPU tics
  • Entry and Exit Pages
  • mero de interrupciones Number of interruptions
  • Boot time and more
image

6. How to display exchange statistics


If we only want to access the information in the swap memory, we must execute the following:
 vmstat -S 
If we want to access the help of vmstat we must execute the following:
 vmstat -h 
image

In this way the vmstat command is of great help to access essential information of the system used and keep a specific control on each aspect of both CPU, disks or memory in real time and with the most optimal results available..


by (3.5m points)
edited

Related questions

+3 votes
1 answer
asked Oct 20, 2020 in Linux / Unix by backtothefuture (552k points) | 266 views
+4 votes
1 answer
asked Sep 22, 2020 in Linux / Unix by backtothefuture (552k points) | 355 views
+3 votes
1 answer
+4 votes
1 answer
asked Jul 29, 2020 in Linux / Unix by backtothefuture (552k points) | 475 views
+4 votes
1 answer
asked Jun 12, 2020 in Linux / Unix by backtothefuture (552k points) | 342 views
Sponsored articles cost $40 per post. You can contact us via Feedback

Most popular questions within the last 30 days

10,659 questions
10,791 answers
510 comments
3 users