Checking System Performance - top, htop, And nmon

Lecture description
Ubuntu Server - Managing The System - top
In this lesson, you’ll learn how to see what processes are using system resources with top.
top is like a text based version of Windows Task Manager, and like Task Manager, it refreshes every few seconds so you can see what’s going on on your system real time.
top
The top command is very capable and flexible. There are many pages in the man pages for it. It even has its own table of contents in the man pages!
We’ll look at basic usage and some of the things for you to be aware of when using it in this lesson.
Output
top refreshes every 3 seconds by default, constantly telling you what processes are the top users of CPU and Memory.
You can see, it provides a LOT of information.
We’ll have a look at the output now.
Load average, toward the end of the first line shows you the load average for the last minute, 5 minutes, and 15 minutes.
You can see if this is increasing or decreasing over time.
A load average of 1.00 for a single CPU or single core system means the CPU is at full capacity. A value of greater than 1.00 means things are getting queued and users could experience delays.
If you have a dual-core processor, a number of 2.00 would mean both CPU’s are at full capacity.
Four processors would have 4.0 to be fully utilized.
These numbers may jump to numbers in the 1 to 10 range for brief periods if some system intensive process, like a virus scan, kick off. They should not be above 1.0 (or 1.0 * Number of cores) for extended periods.
If it jumps really high (254 for example), process may start timing out and dying.
Line 2 shows how many tasks are running, and their status.
Possible statuses are:
- Running - Process was running at last polling interval.
- Sleeping - Normal state for a process that was active, but is now waiting for input.
- Stopped - A process is stopping. If you see this, it should clear quickly once the process stops.
- Zombie - Process stopped but couldn’t sent its exit status to its parent. These aren’t good, but aren’t something to likely worry about unless there are a lot of them. It’s also possible that the program that created them is not written well, so you may want to look into that. They sometimes go away on their own, but will go away on rebooting.
Line 3 is CPU activity.
us: refers to user space. Usually commands started by normal users.
sy: system space. Usually kernel routines doing their thing.
ni: time spent on low priority processes.
id: inactivity. CPU idle time. Indicates processor isn’t doing anything.
wa: waiting. Should always be low. If not, you may have a hardware mismatch with your hard drive(s).
hi: hardware interrupt. Time CPU spent communicating with hardware. Could be high at certain times (when reading from a CD or DVD) but should normally be low.
si: software interrupt. Time CPU spent communicating with software. Should be low.
st: stolen time. On a virtualized system, such as one running on a virtualization platform, like VMware ESXi Server, this can go up when many VM’s are working hard at the same time.
Lines 4 and 5 show memory information. Keep an eye on swap space. It should almost always be low.
Under the headings is information about running processes.
You’re familiar with most of the headings.
Here are some you may not have seen before:
PR: priority - a low number means it will get some CPU time soon. rt means real time.
NI: niceness value.
-20 very high priority (don’t assign this to a process manually. It may take over and not let other processes run.
19 very nice (very low priority). Process will be the last to receive CPU time.
Pressing the n key will let you re-nice or change the niceness level of a process you specify.
VIRT: Total amount of memory claimed by the process.
RES: Resident memory size.
SHR: Amount of shared memory.
S: Status - Similar to the statuses with ps.
%CPU and %MEM are the same as with ps, as is command.
Some things to watch closely if your system is having trouble are:
%CPU - us, and sy should be below 1.0 per processor (i.e. below 2.0 for dual core, and below 4.0 for quad core), and wa should be a low number.
See what processes are very high in CPU and memory utilization. If it’s a database server, that is busy doing database transactions, then it’s normal for the database app to be at the top of the list.
If not, see what’s taking the CPU resources.
HTOP
htop is a top-like program, but it is not installed by default.
I like it and you may want to check it out.
Just run:
sudo apt update
sudo apt install htop
And to run htop, just type htop.
NMON
nmon is similar to top and htop, but shows several types of data, such as disk status along with process data.
Learn more from the full course
Ubuntu Linux Fundamentals Linux Server Administration BasicsUpdated for Ubuntu 20.04 - The Latest! Gain essential skills with Linux Server in this 11 hour Beginner's course.
11:18:00 of on-demand video • Updated March 2021
- You will learn what Linux is
- Installing Linux
- Working at the command line and why the Command Line Interface is so simple yet powerful
- Configuring and securing remote access with SSH
- Securing your server, ufw, apt update and upgrade
- Stopping bad guys with Fail2ban
- Installing and securing nginx web server
- Managing users and groups
- How to use the Linux file system