Linux provides a wide range of command-line monitoring tools for monitoring various system metrics. We have the top command that monitors various processes, and htop which is an interactive monitoring tool and an improvement of the top command. All these work perfectly fine, but they are limited and don’t provide a complete picture of other equally crucial metrics such as network statistics.
Developed in Python, Glances is a cross-platform tool that provides a user-friendly and elegant overview of the system’s performance.
Key features of the Glances command-line monitoring tool include:
There are a couple of ways of installing the Glances app. Let us go through each of them before we get down to monitoring various metrics.
First off, Glances is available in official repositories of major Linux distributions such as Ubuntu and CentOS.
To install Glances on Ubuntu 18.04 and later versions, use the APT package manager as follows:
$ sudo apt install glances
For CentOS 8 and RHEL 8, first, ensure the EPEL package is installed as follows:
$ sudo dnf install epel-release
$ sudo dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
Once EPEL is in place, install glances from the AppStream repositories using DNF as follows on CentOS and RHEL:
$ sudo dnf install glances
Glances tool can also be installed from snap packages as follows. This is ideal if snap is already enabled on your distribution and you are having problems installing from official repositories on your Linux distribution.
$ sudo snap install glances
Snap packages usually hog a lot of disk space. You might want to check that you have adequate disk space.
And given that Glances is written in Python, you can use pip - which is Python’s package manager to install it. First, ensure that pip is installed on your system. Most systems now use pip3 and once installed, execute the command shown to install glances.
$ sudo pip3 install glances
The Glances monitoring tool provides 3 main monitoring modes: Standalone, Client-server, and web GUI mode.
Without any command-line arguments, glances provides an overview of the local system’s metrics as shown. This is called the standalone mode. As the name suggests, it provides the performance of the system on which it is installed.
$ glances
At the very top, you can see the private and public IPv4 address of the local system and the uptime at the far right corner. Thereafter, other system metrics are displayed including CPU, memory and swap utilization, load average, disk I/O, network statistics, running processes, and file system I/O.
A cool feature in glances is the ability to render the metrics on a web browser. Simply invoke the -w flag as shown and you will be provided with a URL that you will use to access the metrics.
$ glances -w
Afterward, launch your browser, and browse the URL provided. Note that the 0.0.0.0 IP can be replaced by the IP address of the server as follows:
http://192.168.2.103:61208
Here, 192.168.2.103 is the IP address of my server.
Better still, you can restrict access to the web page by setting up a password that will require users to authenticate before accessing the dashboard. To achieve this, add the --password option at the end to prompt for password configuration.
$ glances -w --password
Provide a strong password and confirm it. By default, the username is set to glances. Finally, feel free to choose whether or not to save the password. This is entirely up to you to decide.
The next time you visit the URL, an authentication prompt will require you to authenticate before proceeding any further. So type in glances as the username and provide the password you just set up moments ago and click ‘OK’.
Glances also give you an option to monitor remote systems in a server-client setup.
On the remote system to be monitored, run the following command to initialize it in server mode:
$ glances -s
Head over to the client system and execute the command below where IP-address is the IP of the server:
$ glances -c IP-address
Once again, the statistics will be displayed as shown.
Another useful functionality that glances provides is the ability to export the metrics in the form of a CSV file for further analysis. Here, we are exporting the metrics in the export path /home/james/Documents/, and the name of the file is glances.csv.
$ glances --export csv --export-csv-file /home/james/Documents/glances.csv
As you might have noted, the metrics are color-coded. These colors hold meaning and here is what each color signifies.
That was an overview of the glances monitoring tool. As you have observed, it’s quite a useful tool that lets you intuitively monitor system statistics with the help of the psutil python library which retrieves system information. It’s cross-platform and can work in virtually any computing environment including Linux, Windows. macOS, and Android.
Magento is a free and open-source e-commerce platform written in PHP. It is simple, easy…
ISPConfig is an open-source control panel that allows users to manage multiple servers from a…
As a Linux administrator, you may find it necessary to troubleshoot or test your Simple…
Ubuntu 24.04, like many modern Linux distributions, relies on the NetworkManager for managing network connections.…
Restic is a modern, open-source backup program designed for efficiency, security, and simplicity. It enables…
phpMyAdmin is a popular free tool written in PHP intended to administer MySQL and MariaDB…