Obtaining the load average of your server(s) will shed some light on the system’s CPU usage over time. As a Linux system administrator, it is essential to obtain the load average occasionally, as to determine whether or not your systems are overwhelmed by trying to handle the current work load. Because of the way load averages are reported, it is also easy to determine if the server is being overloaded, which may mean it is time to divide up the work load across load balancing servers, or upgrade your current hardware.
In this tutorial, we will look at some common command line tools that can be used to report on the load average of a Linux system.
uptime are two of the most popular that come to mind for most administrators, but other tools like
vmstat also allow us to track load average over longer periods of time. We will go over these various commands and tools below.
In this tutorial you will learn:
- How to use top, htop, uptime, and vmstat commands
- How to see load average for past 1 minute, 5 minutes, and 15 minutes
- How to see load average since last system reboot
|Category||Requirements, Conventions or Software Version Used|
|System||Any Linux distro|
|Software||top, htop, uptime, vmstat|
|Other||Privileged access to your Linux system as root or via the
# – requires given linux commands to be executed with root privileges either directly as a root user or by use of
$ – requires given linux commands to be executed as a regular non-privileged user
How to obtain Linux’s system load average report
There are a lot of command line and GUI tools that can report the load average on Linux. We have covered some of the most useful methods below. Depending on your scenario, one tool may work better than another. Check out the examples below and employ the tools you find most useful for monitoring the load on your servers.
top command gives us a live view of the system’s load average in addition to services running on the system, the amount of system resources each of those services are using, as well as a summary of the system’s CPU utilization, among other information.
There are three numbers given for the load average. The numbers are the average load over 1, 5, and 15 minutes, respectively. Think of these numbers as percentages – a load of 0.2 means 20%, and a load of 1.00 means 100%.
That should be easy enough to understand, but you may also see load averages greater than 1.00. This is because load average is not a direct measurement of CPU usage, but how much “work” (load) your system is trying to process. For example, a value of 2.50 means that the current load is 250%, and also indicates that the system is overloaded by a whopping 150%.
uptime outputs the system load over the last 1 minute, 5 minutes, and 15 minutes at a quick glance. It also outputs some other handy data – the amount of time since last reboot, the current time, and how many users are logged in.
vmstat command also shows CPU load averags, but unlike the previous commands, it shows load averages since the last server reboot.
vmstat also accepts arguments:
$ vmstat 10 3 procs -----------memory---------- ---swap-- -----io---- -system-- ----cpu---- r b swpd free buff cache si so bi bo in cs us sy id wa 0 0 0 187528 177472 855836 0 0 12 78 2 0 7 2 83 1 0 0 0 203996 177532 855848 0 0 0 107 126 208 4 2 89 1 0 0 0 194108 177540 855856 0 0 0 3 102 166 2 1 96 0
The above vmstat command produced 3 reports with 10 seconds delay. Please note that the first line always contains values for entire server uptime.
Another tool worth mentioning would be
htop, as many system administrators prefer it over
top since it produces a more discernable looking output that is also easy on the eyes. It, too, contains load averages for the system over the past 1 minute, 5 minutes, and 15 minutes:
You can use the appropriate command below to install htop with your system’s package manager.
$ sudo apt install htop
$ sudo dnf install htop
$ sudo pacman -S htop
In this tutorial, we saw how to obtain the load averages on a Linux system. There are a variety of tools that can do the job, including
vmstat, and a slew of others. Remember that load averages can also exceed 100%, indicating that your CPU is overloaded with the tasks in queue.