Blog

An Introduction to Linux Performance Monitoring Tools

laptop

Linux performance monitoring is an essential component of any server administrator’s responsibilities. Poor server performance means a poor user experience, which often translates into lost revenue and, eventually, lost business. 

There are many SaaS and GUI performance monitoring tools, but your colocated Linux server has a wide array of built-in tools that can help you identify performance issues and track down their root cause. 

In this article, we’ll introduce you to some of the best command line tools for Linux performance monitoring. They’re all free, and they’re probably already installed on your server. If they aren’t, you can install them via your Linux distribution’s package management system. 

Key System Performance Metrics

Let’s begin with a brief overview of the most important metrics to track on your Linux server: 

  • CPU usage: The percentage of time the processor spends executing processes or tasks. Monitoring CPU usage is essential to ensure optimal performance and detect potential bottlenecks or high-load situations. Pay attention to user, system, and idle time to understand how your system resources are utilized.
  • Memory utilization: The amount of physical memory the system uses, including both occupied and free space. Monitoring memory can help identify memory leaks, excessive paging, and other issues impacting an application’s performance.
  • Disk I/O: Input/output operations on the hard drive, including reads and writes. High disk I/O can indicate a storage bottleneck or poor application performance. Look at the I/O wait time, which represents the portion of time the CPU is waiting for disk operations to complete, to gauge the system’s efficiency.
  • Network usage: The rate at which data is transferred over a network interface, including incoming and outgoing traffic. Monitoring network usage helps detect bandwidth bottlenecks, packet loss, and potential network-related performance issues.

Each of these can be broken down into lower-level metrics, but for this article, we’ll concentrate on the top-level metrics and how to use Linux performance monitoring tools to find them. 

Linux Performance Monitoring Tools

The average Linux distribution includes many different performance monitoring tools. Let’s look at six of the most useful, all of which can be run from a server’s command line via an SSH connection. You may need to log in as the root user or run the command with sudo to access the full range of performance monitoring metrics. 

Top and Htop

Top is a real-time system monitor that displays an overview of system processes, including CPU and memory usage. Htop is an enhanced version of top with a more user-friendly interface and additional features. Both can help you identify processes consuming high CPU or memory resources, which can be useful in detecting performance bottlenecks:

  • Memory usage: In top, memory usage is displayed as a percentage in the %MEM column, while htop shows the used memory as a bar graph. You can sort the process list by memory usage to identify the processes consuming the most memory.
  • CPU usage: Both top and htop display CPU usage as a percentage in the %CPU column. Sorting the process list by CPU usage can identify processes responsible for high CPU consumption.

In addition to memory, CPU, and disk usage, top and htop provide valuable information about process states, user ownership, system load averages, and uptime.

Vmstat

Vmstat (virtual memory statistics) reports on system resources, including CPU, memory, and I/O usage. You can use vmstat with an interval (in seconds) to update the statistics continuously. For example, vmstat 5 will display a table with updated CPU, memory, and I/O usage statistics every 5 seconds. Vmstat is useful for detecting issues related to memory leaks or excessive paging.

Iostat

Iostat provides detailed disk I/O statistics, including I/O wait times —  the proportion of time the CPU spends waiting for disk operations to complete while not being able to work on other tasks. Monitoring I/O wait times can help you identify storage bottlenecks. Use iostat with an interval (in seconds) to monitor disk I/O continuously. 

Free

The free command displays the server’s available and used memory. Use free with the -h flag for more human-readable output. For example, free -h will show a table with total, used, and free memory (in gigabytes) for both physical RAM and swap space. Monitoring memory usage using free can help identify memory leaks and optimize system performance.

Iftop

Iftop is a network monitoring tool that focuses on individual connections, displaying real-time network usage statistics for each connection. You can use filters and sorting options to monitor specific connections or interfaces, making it easier to detect bandwidth bottlenecks or packet loss on individual connections.

Nload

Nload is another network monitoring tool that provides a global overview of bandwidth usage for a network interface. It displays live graphs and summaries of total network usage, which is valuable for identifying overall network performance issues and monitoring usage trends over time.

This article has covered only the basics of each tool. To learn more, check out the manual for each utility by typing man $command-name on your server’s command line. You can also get a deeper understanding of each tool from its official documentation.

Facebook
Twitter
LinkedIn
Archives