How To Use vmstat To Monitor Linux Performance

RSS
EMAIL
FACEBOOK
FACEBOOK
GOOGLE
GOOGLE
https://www.poftut.com/how-to-use-vmstat-to-monitor-linux-performance/
PINTEREST
PINTEREST
INSTAGRAM

Linux distributions provides a lot of tools in order to monitor system performance. vmstat is one of the most used tool for system performance monitoring. vmstat can collect and report information about memory, cpu, swap, io in a detailed way. In this tutorial we will examine the output of the vmstat and different features and options of it.

List System Resource Usage

We will start by using vmstat command without any option. This will list general statistics and information about system resource usage.

List System Resource Usage
List System Resource Usage

We can see that there is 5 main column.

  • procs display information about processes.
  • memory display information about memory metrics
    • swpd provides avaible swap size
    • free provides unused memory size
    • buff provides buffered memory size
    • cache provides cached memory size
  • swap provides swap related information but in these days it is not used so much.
  • io provides disk related informatin
    • bi block input shows data block count read from block devices
    • bo block output shows block count sent to block devices
  • system provides interrup and context switch information which is related with CPU
    • in number of interrupts per second
    • cs number of context switches per second
  • cpu provides CPU usage information
    • us time spent user space operations or user time
    • id time spent idle
    • sy time spent system operations
    • wa time spent waiting for IO.
    • st time spent from virtual machine

Print Output At Specified Interval Interactively

By default vmstat command is non interactive. It will print information just one time after called and then quit. If we need to it continuously and print command output at given intervals we need to provide the interval as seconds after command. We will print at 5 second interval in this example.

LEARN MORE  What Is Windows Sysinternal?

Print Output At Specified Interval Interactively
Print Output At Specified Interval Interactively

Print Timestamp

As the output printed one or multiple times we may need to know related time. We can print given information time by printing time stamp. We need to provide -t option for this. Time column will be added as last column after cpu column.

Print Timestamp
Print Timestamp

List Memory Active and Inactive

Active memory is part or size of the memory which is actively used currently running processes. Inactive memory is part or size of the memory where died or non existing processes. We will use -a option for active and inactive memory. We can see that memory column provides inact and active columns.

List Memory Active and Inactive
List Memory Active and Inactive

View Disk I/O Statics In Detail

As writing disk and disk topology is a complex area related information can be printed with the -d option. Following information will be provided by this option.

View Disk I/O Statics In Detail
View Disk I/O Statics In Detail
  • Reads show read related information
    • total shows successfully completed total read
    • merged shows grouped reads
    • sectors shows sector reads
    • ms shows milliseconds spent for reads
  • Writes show write related information
    • total shows successfully completed total read
    • merged shows grouped reads
    • sectors shows sector reads
    • ms shows milliseconds spent for reads
  • IO show currently active IO operations information
    • cur I/O in progress
    • s seconds spent for I/O

View Disk I/O Statics Summary

We can also print disk related I/O statistics in summary or brief mode with -D option.

View Disk I/O Statics Summary
View Disk I/O Statics Summary

Usage Megabyte As Metric

During usage of all options the default metric for memory is byte. This will lower readability. We can make metrics more readable or human readable with -S M option which will set Megabyte as metric.

LEARN MORE  Python Timestamp Examples with Time Module

Usage Megabyte As Metric
Usage Megabyte As Metric

List Event Counters and Memory Statics

We can use -s option in order to print event counters and memory statistics.

List Event Counters and Memory Statics
List Event Counters and Memory Statics

RSS
EMAIL
FACEBOOK
FACEBOOK
GOOGLE
GOOGLE
https://www.poftut.com/how-to-use-vmstat-to-monitor-linux-performance/
PINTEREST
PINTEREST
INSTAGRAM