One of my favorit proces-watch + system info tool in linux is htop, the purpose of htop is (taken directly from wikipedia):
htop is an interactive system-monitor process-viewer written for Linux. It is designed as an alternative to the Unix program top. It shows a frequently updated list of the processes running on a computer, normally ordered by the amount of CPU usage. Unlike top, htop provides a full list of processes running, instead of the top resource-consuming processes. Htop uses color and gives visual information about processor, swap and memory status.
To get htop in debian/ubuntu you can do the following in terminal (as root or super-user)
sudo apt-get install htop
For starting htop, you simply write
and you will see the following screen:
I will explain a few things from the htop screenshot, the first thing is the top-left side looking like this:
In this "bar" you can see how much work is done on your processor (indicated as 1 and 2), the 1 and 2 is actually the cores - so if you have more cores than 2, there will be more numbers. As you can see the load on the server is pretty low, 0.7% on core 1 and 0.7% on core 2. An example of high cpu load numbers, would look like this:
This high cpu load example is done by using this:
dd if=/dev/zero of=/dev/null
The next thing in the bar is the memory lane, this memory lane tells you the total memory you have and how much you have used up. In our screenshot we can see that 69mb out of 1024mb is used. An example of high memory usage would look like this:
This high memory "leak" is done by using this:
while :; do _+=( $((++__)) ); done
BEWARE: The shell terminal becomes unresponsive, so you need to shell into a new one (or already have two shells open). This might freeze the system until memory can not be allocated.
The last thing in the bar is the swap space. The purpose of swap space is to act as a temporary ram, meaning that when your physical ram is almost used, the swap space will be used instead. By using the same memory leak example from above, we can use see an example of how swap space is used:
Some servers don't have swap space, but in my opinion it is always good to have. I will show how to create a swap partition at some point.
Now the top-left corner have been explained, now I am going to tell you about the top-corner, which looks like this:
Tasks indicate how many processes is active, and thr means how many threads is active. 1 running means that 1 process is running, and others are sleeping, zombies etc.
Load average is understod like this: 0.08 (a minute ago), 0.29 (5 minutes ago), 0.20 (15 minutes ago).
Uptime is telling how many days the machine have been online (without reboot), and the 01:47:26 indicates how many hours it has been online.
The final thing I am going to talk about is the FX commands, the FX is functionality where you can press a button between F1 and F10, with each doing something different.
The different FX keys does the following: (Taken from man htop)
F1, h, ?
Go to the help screen
Go to the setup screen, where you can configure the meters displayed at the top of the screen, set various display options, choose among color schemes, and select which
columns are displayed, in which order.
Incrementally search the command lines of all the displayed processes. The currently selected (highlighted) command will update as you type. While in search mode,
pressing F3 will cycle through matching occurrences.
Incremental process filtering: type in part of a process command line and only processes whose names match will be shown. To cancel filtering, enter the Filter option
again and press Esc.
Tree view: organize processes by parenthood, and layout the relations between them as a tree. Toggling the key will switch between tree and your previously selected
sort view. Selecting a sort view will exit tree view.
F6, <, >
Select a field for sorting. The current sort field is indicated by a highlight in the header.
Increase the selected process's priority (subtract from 'nice' value). This can only be done by the superuser.
Decrease the selected process's priority (add to 'nice' value)
"Kill" process: sends a signal which is selected in a menu, to one or a group of processes. If processes were tagged, sends the signal to all tagged processes. If none
is tagged, sends to the currently selected process.
That's it for htop this time 🙂