These two programs, ” htop ” and ” atop “, have the same basic function: list and manage processes. They are equivalent to ” top ” which is installed by default on GNU-Linux systems. Yet “htop” and “atop” have specificities that deserve to be tried.
These two programs are rarely present by default and need to be installed with your package manager.
The keys used are indicated in brackets, for example [ctrl] for the “control” key
“Htop”, interactive and ergonomic program
The launch of “htop” is done simply by entering the name of the program in a console. Running “htop” in root (or with “sudo”) will allow you to list all processes and act including those that belong to other users.
“Htop” can actually be presented as an upgraded version of the classic “top”. From the launch, its colorful interface highlights the important elements and a menu at the bottom of the screen lists the most useful commands.
At the top left of the window you can see graphs showing processor activity and total memory consumption (RAM and SWAP). At the top right, a short summary of system activity: total number of processes, average load, elapsed time since last start.
Below, the window that lists the processes, sorted by default according to the intensity of their use of the processor. The column titles give you information about their contents, the most obvious ones are the PID of the process (its identifier number), the name of the user who owns the process, the priority and the nice coefficient of the process, Related to its use of the memory, its status, the percentage of CPU utilization (CPU%) and memory (MEM%), and of course the name of the command with its possible options. If a line is longer than your display, you can move with the right and left arrows on the keyboard or navigate through the processes with the up and down arrows.
At the bottom of the window, a menu bar lists the shortcuts and the options to which they correspond; For example, pressing the [F5] key will activate the display of the tree processes, [F6] will allow you to choose the sorting criterion (“sort by”), [F9] To send a signal to the selected process (s) (use “man kill” for the signal list and their meaning).
“Htop” is designed to be completely interactive. It makes it very easy to send a signal to a process, to change its execution priority, while controlling the result of these actions on the load of the entire system. Multiple selections can be made with the [space] key, and actions will apply to the entire selection.
The use of the help may seem superfluous; It will teach you the meaning of the different color codes used or the symbols in the status column (use [F1] or [h] to access the help).
The display is fully customizable. The numbers of the information columns, their order, the highlighting of certain processes or a tree view are possible. To access the options, use [F2]. An example of the options screen (the menus at the bottom are contextual and change according to the selected settings):
“Atop”, the “top” of picky administrators
” Atop ” has a very different vocation from “htop”. It differs immediately by … its lack of ergonomics and simplicity!
“Atop” provides information not only on processes, but also on all system hotspots such as disk activity, processor load, network or memory usage (vivid and swap). It allows you to really get an idea of the processes that cause system overloading or profiling a particular application to see what types of resources it uses the most.
“Atop” is divided into two parts:
- The program ” atop ” can be used on demand, simply entering its name in a console. Running “atop” with root permissions allows you to see all processes and act on those belonging to other users or root.
However, on most distributions, the installation of “atop” will also cause the startup (via a script in /etc/init.d) of an “atop” instance that will monitor and record the activity of system. By default, “atop” will save its results in / var / log / or / var / log / atop /. These logs, compressed in binary format, are kept for a variable duration which can be determined either by a “Cron” task or by a program like “logrotate” (as on Debian ). “Atop” then allows to consult the activity logs with the ” -r ” option (see below “atopsar” for more advanced use).
$ Atop -r /var/log/atop.log.1
- The ” atopsar ” program allows to perform a system audit, general or detailed, for a customizable duration and to extract information precisely from the logs created by “atop”.
Use of “atop”
During a manual launch “atop” will first display a summary of the system activity since the last start, before going into monitoring mode of the current processes. Here is an example of the launch screen:
The upper part of the screen shows a detailed summary of the system activity since it was last started. The abbreviations at the beginning of the line indicate the domain concerned (processor, swap, memory, network, disk …), the line presents detailed statistics. All the information presented and the symbols used are detailed in the manual. Here is a short summary of the most common categories:
- PRC “process level totals”, ie total processor occupancy time, system “sys”, user processes “user”, total number of processes “#proc”, number of processes zombie “#zombie” , And the total number of processes that ended during the “#exit” monitoring interval.
- CPU Overall processor usage, followed by lines detailing each active core / processor. Details are given for all active processes “sys”, the percentage consumed by the user processes “user”, the percentage of CPU usage for the “irq”, the percentage of time the processors are unused without any process Is waiting for disk idle input / output, and finally when processes were waiting for disk input / output “wait” (good indicator of a disk bottleneck).
- MEM Use of physical memory (ram), with total memory “tot”, amount of free memory “free”, cache cache, memory usage by the metadata of the “buff” file system, and quantity used by the Kernel for dynamic memory allocation (malloc) denoted “slab”.
- SWP Swap space occupancy.
- DSK Disk activity, one line per active disk. Total percentage of activity time “busy”, reading request “read” and writing “write”, cumulative average time (in milliseconds) to reach the data, latency, and transfer of this data. (Significant bottleneck on slow and / or aging disks).
- NET Detailed activity of network use.
The bottom part of the screen shows the processes that caused a system load during the measurement interval, or that were swapped due to lack of RAM.
The information provided is detailed in the manual. The ” RGROW ” (“Resident Memory Growth”) column, which may be a memory leak indicator, should be used if there are high and continuously growing values on several readings Are recorded.
This preliminary display lasts a few seconds (8), but can be extended for a close scrutiny by using the ” z ” key. The display will then be suspended until the ” z ” key is pressed again .
The second phase consists of real-time monitoring of the system with a display always decomposed into two parts: the statistical table at the top and the list of processes at the bottom.
Resources that experience a peak of activity are colored, blue then red, depending on the size of the load. On capture, this is the case for disk activity.
The display has many organizational options, for example:
- The [ i ] (interval) key is used to change the measurement interval (10-second fault, too slow for some processes).
- The [ ctrl ] [ F ] and [ ctrl ] [ B ] key combinations display the next / previous page.
- The [ c ] (commands) key displays the commands associated with the processes. To return to the general display, press [ g ].
- The [ m ] key displays detailed information about memory usage.
- The [ u ] key will display a cumulative number of resources used per user, [ p ] per program, and [ U ] will target the statistics of a particular user by entering its name. In all of these modes, [ a ] allows you to switch successively from a view of all processes to that of active processes only
- The [ C ], [ M ], [ A ], [ N ], [ D ] keys are used to classify processes by “CPU”, “MEM” , The resource most used as a ranking criterion).”NET” and “DISK”, which use network load and disk usage respectively as a ranking criterion, are not available by default (see “kernel patch” below).
- Finally [ k ] is used to send a signal to a process by indicating its PID.
The help screen, obtained by pressing the [ h ] (help) key, will give you information about all the available options:
“Atop” can also write the result to a log file, compressed in binary format, with the ” -w ” option followed by the path where the logs are stored:
$ Atop -w / home / tux / atoplog 30 3
Here we launch “atop” for a 30-second monitoring sequence, repeated 3 times, with writing the log to the file (created by “atop”) “/ home / tux / atoplog”.
“Atopsar” for a system audit
Delivered with “atop” the program “atopsar” allows to carry out an audit, general or targeted on a few criteria, of the use of the system resources over a period of time customizable. The following example records the activity of the hard drives (option -d ) for 60 seconds, repeated 5 times:
$ Atopsar -d 60 5
The result in image:
You can also use all available monitoring options (option -A ) or combine the monitoring options which are very numerous and perfectly detailed in the manual. For example, for disk monitoring ( -d ), use of the swap space ( -s ), processors ( -c ) and memory ( -m ), during two sessions of 30 seconds :
$ Atopsar -dscm 30 2
Result of the second session only:
“Atopsar” to exploit the newspapers produced by “atop”
“Atop” writes activity logs regularly, and can be instructed to write the result of a one-time use with the “-w” option. To exploit these logs “atopsar” can be used with the ” -r ” (read) option :
$ Atopsar -r /var/log/atop.log.2
If “-r” is not specified, the last log of the day is used. If the ” -A ” option is specified, all the recorded monitoring criteria will be displayed (very long result to be viewed …).
You can specify some criteria to extract from the journal and a range of time, for example:
Atopsar -micd -r /var/log/atop.log.2 -b 15:30 -e 18:30
This will extract from the log “/var/log/atop.log.2″ the activity related to memory, traffic on network interfaces, processor (s) and disks (” -micd “), Between 15h30 (” -b ” for the start time) and 18h30 (” -e ” for the end time).
“Atop” has advanced monitoring functions that require a patch to be applied to the kernel (and therefore its recompilation). This patch, regularly updated, allows to obtain very precise information on the activity disk or network generated by each process.
This patch is absolutely not necessary for normal “atop” operation, but may be interesting to profile the network and disk resource requirements of an application or track down a process that generates peaks of activity slowing down the overall system. See the “Links” section for patch application instructions.