Posted on
Getting Started

System Monitoring with `vcstat`, `iostat`, and `free`

Author
  • User
    Linux Bash
    Posts by this author
    Posts by this author

Title: Essential Linux Commands for System Monitoring: vmstat, iostat, and free

Introduction: In the vast toolkit of Linux system monitoring utilities, vmstat, iostat, and free are crucial commands that every system administrator should be familiar with. These tools provide real-time system performance data critical for daily operations and troubleshooting issues. This blog post introduces each utility and guides you on how to install and use them across various Linux distributions using apt, dnf, and zypper package managers.

1. Understanding and Using vmstat

What is vmstat? The vmstat (virtual memory statistics) command reports information about processes, memory, paging, block IO, traps, and CPU activity. It’s especially useful for identifying system bottlenecks.

How to Install vmstat:

  • Debian/Ubuntu: vmstat is included in the procps package. Install it using:

    sudo apt-get install procps
    
  • Fedora/RHEL: On these systems, vmstat can be installed with:

    sudo dnf install procps-ng
    
  • openSUSE: Use zypper to install vmstat:

    sudo zypper install procps
    

How to Use vmstat: Run vmstat with

vmstat 1

Here, 1 stands for the time interval in seconds. For a more detailed report every second, adjust the interval as needed.

2. Getting to Know iostat

What is iostat? The iostat command is used for monitoring system input/output device loading by observing the time the devices are active in relation to their average transfer rates. It provides detailed reports on CPU and all attached devices.

How to Install iostat:

  • Debian/Ubuntu:

    sudo apt-get install sysstat
    
  • Fedora/RHEL:

    sudo dnf install sysstat
    
  • openSUSE:

    sudo zypper install sysstat
    

How to Use iostat: To display device utilization every 2 seconds, use:

iostat 2

For a single summary since the last reboot:

iostat

3. Monitoring with free

What is free? The free command provides a quick overview of memory usage in the system, including physical RAM and swap usage.

How to Install free: free is included in the procps or procps-ng package, so if you have installed vmstat through the instructions above, free should already be available on your system.

How to Use free: To check memory usage:

free -m

This command will display the memory usage in megabytes.

Conclusion

Proactive system monitoring is key to maintaining the health of your computing environment. By leveraging vmstat, iostat, and free, you gain invaluable insights into how your system's resources are being utilized, which is integral in predicting potential issues and ensuring efficient performance. Whether your Linux distribution uses apt, dnf, or zypper, these tools are readily accessible and easy to use.

Practice Tips

  • Regularly check your system performance during different times to understand your peak usage patterns.

  • Combine these tools with logging to capture performance history, which can be invaluable during troubleshooting or planning upgrades.

  • Don't forget to check the man pages (man vmstat, man iostat, man free) for more detailed options and deeper insights.

Happy monitoring! May your servers always be optimised and your resource utilization balanced perfectly!