How to Monitor Linux System with Glances Command

In the past, we have covered quite a number of command-line monitoring tools in Linux.  These include vmstat, htop and top command to mention a few. The top command is the most widely used command since it comes preinstalled and gives a real-time performance of the system in addition to displaying the running processes. In this guide, we will pay more attention to an intuitive and user-friendly command-line tool known as glances.

Based  in Python, Glances is a free and opensource cross-platform command-line monitoring tool that provides a wealth of information about your system’s performance. You can monitor system metrics such as memory & CPU utilization, network bandwidth, Disk I/O, File systems, and running processes to mention a few.

Glances displays metrics in an intuitive and visually appealing format. It prints out detailed information about metrics such as:

  1. System’s uptime & IP address ( Private & public )
  2. Memory utilization ( Main memory , swap , available memory ).
  3. CPU utilization.
  4. Disk mount points.
  5. Disk I/O & read and write speeds.
  6. CPU load average , date and time
  7. Running processes including active and sleeping processes.
  8. Network bandwidth ( Including upload and download rates ).

How to install Glances on Linux distributions

Glances is not installed by default. Let’s see how we can install Glances in major Linux distributions.

On Ubuntu / Debian / Mint

For newer versions of Ubuntu & Debian, simply type:

$ sudo apt install -y glances

For older versions, Add the PPA

$ sudo apt-add-repository ppa:arnaud-hartmann/glances-stable

Next, update the package lists and install glances as shown.

$ sudo apt update
$ sudo apt install -y glances

On CentOS 8 / RHEL 8

For CentOS & RHEL, first install the EPEL package:

CentOS 8

$ sudo dnf install epel-release

RHEL 8

$ sudo dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm

Thereafter, update the repositories.

$ sudo dnf update

And install glances.

$ sudo dnf install -y glances

Glances is also available as a snap package. Thus, it can be installed  across all Linux systems with snap enabled as shown:

$ sudo snap install glances

In addition, since Glances is written in Python, you can also use the pip package manager to install it as shown. But first ensure pip is installed on your system.

$ pip3 install glances

For other installation procedures  check out this documentation on GitHub.

Monitor system metrics in Standalone mode (local system)

Launching Glances to monitor your local system (standalone mode) is quite a breeze. Simply run the glances command below without any command options.

$ glances

Right off the bat, you can see some system metrics starting with the private & public IP addresses at the very top and the uptime at the top right corner of the terminal. Just below that you can view other system metrics such as CPU & memory utilization, network bandwidth rate, running processes, disk volumes etc.

Glances-Command-Output-Linux

Below is a screenshot from a CentOS 8 system.

Glances-Command-CentOS8

To view these statistics on a web browser, use the -w option as shown. This will generate a link as shown which you will copy to your web browser

$ glances -w

Start-Glances-Web-Browser-Linux

This starts glances on port 61208 and render the statistics on the browser as shown.

Access-Glances-from-browser

You can secure the web GUI, by configuring  a password to allow authorized users only using the –password flag.

$ glances -w --password

The username , by default, is glances

Configure-Password-for-Glances

The next time to try to log in, you will be prompted for a password as shown.

UserName-Password-For-Accessing-Glances

Monitor system metrics in Server mode

The glances command can also be used to monitor a remote host. Just pass the -s option to initialize glances in server mode as seen below.

Start-Glances-in-Server-Mode

From the client PC, run the glances command as shown to access the server’s metrics.

$ glances -c server-IP-address

Below is a screenshot of the server metrics from Windows Command prompt shell.

Access-Glances-Command-Line-Client

Glances alerts

Glances makes it easier to spot and narrow down to an issue through the use of color codes in displaying the system metrics You might be wondering what the are various color-codes imply on the glances , well here’s a breakdown.

  • GREEN: OK (everything is fine)
  • BLUE: CAREFUL (need attention)
  • VIOLET: WARNING (alert)
  • RED: CRITICAL (critical)

The thresholds are configured , by default , as

  • careful=50
  • warning=70
  • critical=90

These are not cast in stone and can be further customized in the glances configuration file at the /etc/glances/glances.conf path.

Glances-Conf-File-Linux

Summary

Glances is a handy tool, and in more ways feels like an improved version of top or htop command. It provides dynamic real time system metrics which can be rendered on a web browser & retrieved remotely on command-line.

$ glances -h

Glances-Help-Linux

Leave a Comment

Your email address will not be published. Required fields are marked *