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:
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.
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
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
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:
- Readings that have been merged
- Amount of reading and writing
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
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
- mero de interrupciones Number of interruptions
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
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..