vmstat, iostat & netstat ( Performance monitoring tools )…..

Pavan Pathak
5 min readAug 28, 2021

In Linux/Unix environment performance monitoring is very important to keep the things up and running. There are number of monitoring tools that have been a part of Linux/Unix systems. We can monitor the performance of system or disk using these commands vmstat, iostat & netstat. There are few other tools which are available to monitor performance like ( topas, top, sar, nmon, svmon etc etc…) but in this blog we will talk about vmstat, iostat and netstat.

If these commands aren’t there in your system. You can install using systat package.

RPM packages can be installed using “ sudo yum install systat “ .

Debian packages can be installed using “ sudo apt install systat “.

Fedora & Suse packages can be installed using “ sudo dnf install systat” & “sudo zypper install systat”.

The vmstat command :

The vmstat command reports statistics about kernel threads, virtual memory, disks, traps, and CPU activity. Reports generated by the vmstat command can be used to balance system load activity. The kernel maintains statistics for kernel threads, paging, and interrupt activity, which the vmstat command accesses.

vmstat command can be used to get multiple information with and without flag.

  1. If you will run “vmstat” without flag it will display a summary of stats since the system boot.

As you see with vmstat output contain a lot of parameters. The description of those parameters are as follow :

r : Number of kernel threads waiting in run queue. The value increases as per CPU utilization. Ideally it’s zero for idle server.

b : Number of kernel threads waiting on the wait queue (awaiting resource, awaiting input/output).

swpd : ‘swpd’ means the amount of virtual memory used.

si : Swapped in every second from disk in Kilo Bytes.

so : Swapped out every second to disk in Kilo Bytes.

free : Size of the free list RAM pages or It specifies the amount of free memory/idle memory spaces which are not being used.’

in : Device interrupts

sy : System calls

cs : Kernel thread context switches

us : User time

sy : System time

id : CPU idle time

wa : CPU cycles to determine that the current process is wait, and there is pending disk input/output.

bi and bo fields indicate the number of blocks being read from disk and block being written to disk.

2. If you run “vmstat 2 5” it will display 5 summaries at 2 second interval.

3. If you run “vmstat -t 2 5” it will display the 5 entries with timestamps.

4. If you run “vmstat -f” it will display fork statistics.

5. The vmstat displays memory statistics in kilobytes by default, but you can also display reports with memory sizes in megabytes with the argument -S -M. “vmstat -S M”.

6. If you run “vmstat -s” it will display the count of various events.

7. If you run “vmstat -d” it will display all the disk characteristics.

The iostat command :

The iostat command is used for monitoring system input/output device loading by observing the time the physical disks are active in relation to their average transfer rates with the output of this command we can analyse and do the changes to enhance system performance.

The iostat command can be used with various flags to monitor different different activities.

  1. To display a single history since boot report for all tty, CPU, and Disks run “iostat”.

As you see with iostat output contain a lot of parameters. The description of those parameters are as follow :

% idle : Shows the percentage of time that the CPU or CPUs were idle, and the system did not have an outstanding disk I/O request.

% iowait : Shows the percentage of time that the CPU or CPUs were idle during which the system had an outstanding disk I/O request.

tps : Indicates the number of transfers per second that were issued to the physical disk. A transfer is an I/O request to the physical disk. Multiple logical requests can be combined into a single I/O request to the disk. A transfer is of indeterminate size.

Kb_read : The total number of KB read.

Kb_wrtn : The total number of KB written.

% user : Shows the percentage of CPU utilization that occurred while executing at the user level (application).

% system : Shows the percentage of CPU utilization that occurred while executing at the system level (kernel).

%nice : Show the percentage of CPU utilization that occurred while executing at the user level with nice priority.

2. To display only CPU statistics run “iostat -c”.

3. To display only I/O statistics run “iostat -d”.

4. To display iostat version run “ iostat -V”.

The netstat command :

The netstat command displays the contents of various network-related data structures for active connections. The netstat is used to determine the amount of traffic on the network to ascertain whether performance problems are due to network congestion.

  1. To display routing table run “netstat -r”.

2. To display the routing table with network addresses as numbers run “netstat -rn”.

There are other combinations of netstat can also be used with “netstat -i” for interface related info, “netstat -s” for network statistics etc etc…..

If you find this blog useful, share it with your friends and follow me :)

--

--

Pavan Pathak

My goal is to revolutionise people life, through guidance, motivation and providing information which will be helpful for them to kickstart their life…..