Introduction to Linux - A Hands on Guide | Linux Bible | Linux From Scratch | A Newbie's Getting Started Guide to Linux | Linux Command Line Cheat Sheet | More Linux eBooks



Thursday, 25 July 2013

Monitor System Processes with "HTOP"


htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop

Most linux users would prefer to use “TOP” in order to observe various process is being run on the system and their CPU usage. There is another utility known as “HTOP” which is much easier to use and does similar tasks as that of “TOP”. It is an ncurses-based application where you can view the processes in a GUI-like environment running in terminal.
    One notable thing in htop is that it displays usage per CPU along with memory and swap usage with a significant text graph printed at the top. You will find this tool much convenient to use and easy to understand. Once you start using HTOP, you might not return to TOP.

 Installation

    TOP comes as a pre-installed package in Linux. To install HTOP in your system, you may either use command line interface (Terminal) or software center.
To install HTOP using terminal, just enter following command:

sudo apt-get install htop

   You may download the binaries related to your Linux distribution from htop download page and install it.

HTOP Output Window

HTOP output window comprises of three segments.

htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop

    Upper segment will show essential system information in the form of three bars. These can be changed using HTOP setup menu.

  • CPU Usage
  • Memory Usage
  • Swap Usage
Middle segment displays all the processes arranged with respect to their CPU usage.

Lower segment will show HTOP menu commands.

Displaying Average CPU Usage

    By default, HTOP will show separate statistics for each CPU core in your system. You may not want these statistics for each individual core, but an average CPU usage instead, to avoid distraction.

To do so, follow the steps below:
  • Press F2 (or S) to access setup menu
  • Select “Meters” from setup
  • select “CPU average” in “Available Meters” using arrow keys
  • Press “F5″ to add “CPU average” under “Left columns”.
  • Select “All CPUs” in “Left columns”
  • To remove it, go to “Left Columns”, select “CPU” and press F9
  • To move this option, press F7 (upwards) or F8 (downwards). 
htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop

Sorting the processes

    The processes enlisted when HTOP is run are sorted with respect to their CPU usage. To sort them with respect to PID, users or any other parameter, press F6 which will show a number of parameters with which you can sort your processes. 

htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop

Killing the Processes

    For killing any process, go to that particular process and hit F9 or “K” key. It will show a “Send signal” menu which displays a set of available signals that are to be sent to the command. To kill a process, select the “SIGKILL” option from the list and hit enter.

htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop

Changing the Nice Value of a Process

    To change the nice value of a process, go to the process and press F7 to reduce the nice value by 1 or press F8 to increase the nice value by 1.

Displaying User Specific Processes

    Pressing 'U' key will show a “Show Processes of” option and a list of users having some processes being executed. Choose any user and hit enter key, that will display all the processes being executed by the selected user.


htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop

    Running a terminal command – sudo htop -u <user_name> will also do the same job.

Displaying Tree View of the Process

    Tree view will be extremely beneficial to recognize the dependencies of the process. Pressing F5 (or 't' key) will show all the processes in tree view. '+' and '-' keys can be used to expand or collapse the process tree.

htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop

Changing the Refresh rate of Output

    The -d option in the htop command allows its users to change the output refresh interval in terms of seconds.

Syntax: sudo htop -d <time>

The Setup Menu 

htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop

    The HTOP setup menu can be accesses using F2 key. The available options in htop setup menu are as follows:
  • Meters – For changing the behavior of meter bars present in the upper section.
  • Display Options – To modify/adjust the htop display options.
  • Colors – For selecting an attractive color theme for your htop output.
  • Columns – It will be extremely useful while debugging a problem.

Displaying lsof Output within htop

To list all the files opened by the process, select the process and press 'L' key.

htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop htop

Scrolling the Processes List

    Unlike TOP, you can scroll the processes in htop output window vertically as well as horizontally. This can be achieved by the use of arrow keys. 'Page Up' and 'Page Down' keys will also work for scrolling the processes list vertically.

Following A Process

    As discussed in earlier part of this article, htop will display the process in a sorted manner with respect to their CPU usage. Due to this reason, processes will continuously keep changing their positions in the htop output list, which will become hectic if you want to observe a specific process.

    To follow a process, select the process and hit 'F' key, which will let you monitor that particular process.

Killing Multiple Processes

    This can be achieved by tagging the processes that you want to kill. Pressing Space bar will change the color indicating that the process is tagged. After tagging those processes, hit F9 key, which will kill all those processes tagged by you. To untag, press the space bar again or you can press 'U' to untag all the processes.

    Thats all about HTOP! Let us know if we miss anything or if there are any corrections to be done.

0 comments:

Post a Comment