Installing Glances in Ubuntu 24.04 LTS server

Check out the simple steps of this tutorial to learn how to use Python PIP to install Glances’ latest version on Ubuntu 24.04 LTS Noble Linux for monitoring the system resources.

Monitoring servers is a critical job while serving hundreds of people commercially or running some critical application. Therefore, we need a dedicated monitoring system to measure our system performance, and resource usage and give us a real-time view of the system metrics. It will help the admins to troubleshoot various issues, in managing system resources and optimizing the overall performance.

What is an open source Glances software?

The Glances is an open-source system monitoring software meant to give real-time insight into system performance and resources such as CPU usage, RAM consumption, Disk usage, network utilization, and more. It is designed to present all the important information in a single view on the users’ Terminal, furthermore, the users can access it remotely using the Glances web interface.

I think now we are familiar with this tool, let’s see the steps and commands we can use to install Glances on Ubuntu 24.04 LTS or any other previous version such as Ubuntu 22.04, 20.04, or 18.04.

To perform this tutorial, users just need an active internet connection and access to a user with sudo rights…

Step 1: Ubuntu 24.04 Package Update

Well, like as usual before installing some new software on Ubuntu run the system update command. It will update the existing packages and refresh the APT cache.

sudo apt update && sudo apt upgrade

Step 2: Install Python and Pip

We can install the Glances using the APT package manager and default system Ubuntu 24.04 repository, however, the package available through it will not be the latest one. Therefore, we will use the PIP which is a Python package manager that will allow us to install the latest version of Glances on Ubuntu 24.04 in a few commands.

The given command will install Python and PIP along with some other required packages:

sudo apt install python3 python3-pip python3-dev python3-docker gcc lm-sensors wireless-tools

Step 3: Install Glances on Ubuntu 24.04 Using Pip

As we have installed the PIP in the previous step, now we can use its command line to install the Glances, which is the most straightforward method to get this open-source monitoring system on Ubuntu 24.04 Linux.

However, while running the PIP command to install Glances i.e “sudo pip3 install glances” we got an error:

error: externally-managed-environment

× This environment is externally managed
╰─> To install Python packages system-wide, try apt install
    python3-xyz, where xyz is the package you are trying to
    install.
    
    If you wish to install a non-Debian-packaged Python package,
    create a virtual environment using python3 -m venv path/to/venv.
    Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make
    sure you have python3-full installed.
    
    If you wish to install a non-Debian packaged Python application,
    it may be easiest to use pipx install xyz, which will manage a
    virtual environment for you. Make sure you have pipx installed.
    
    See /usr/share/doc/python3.12/README.venv for more information.

note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.
hint: See PEP 668 for the detailed specification.

This means our system doesn’t allow you to install the package through pip which is already available to install through the APT package manager because it doesn’t want you to end up mixing two packages. Hence, use PIPX.

What is PIPx?

pipx is a tool designed for installing and running Python applications in isolated environments. Hence, in running Python packages as standalone applications without interfering with the system-wide Python packages.

sudo apt install pipx

Now, use pipX to install the Glances:

The given command will install a complete package of Glances for all major supported items to be monitored.

pipx install 'glances[all]'

Add the installed bin folder to your PATH environment.

pipx ensurepath

Reload shell session:

source ~/.bashrc
Installing Glances Ubuntu 24.04 using PIPx

Step 4: Check Glances Version

Now, that we have completed the installation, let’s confirm it by checking the version of this monitoring platform.

glances -V
Check Glances version

Step 5: To Run Glances as a standalone server

Once this Linux system monitoring tool is installed on our system, we can start using Glances by just typing the given command in our terminal.

glances

And we will have the process and other details of our system right in front of us:

Glances in Terminal

If you want to customize the settings that can be made in the file /etc/glances/glances.conf (system-wide; root rights required ) or ~ /.config/glances/glances.conf (per user).

Keys to operate glances

Here are some keys that you can press on the keyboard while having Glances running to get a view of various information.

Keysfunction
CSort processes by% CPU usage
MSort processes by% memory usage
PSort processes by name
ISort processes by I / O rate
DShow/hide disk I / O statistics
FShow/hide file system statistics
NShow/hide network statistics
SShow/hide hardware sensors
TShow network I / O combined
UShow cumulative network I / O
WDelete log entries of the WARNING level
XDelete log entries of the WARNING and CRITICAL levels
YShow/hide hard drive temperature
1Global CPU statistics or per core
LShow/hide log entries
BBit / s or Byte / s for network I / O
Q, Esc, Ctrl + C.break up

Step 6: Create a Glances Service file

In a standard way, we need to start the Glances Web server every time manually to access it using the browser locally or remotely. Therefore, we will create a service file for Glances, so that it can run automatically with system boot in the background.

First, create a Symlink to Glance’s executable:

sudo ln ~/.local/bin/glances /usr/local/bin/

Create a service file:

sudo nano /etc/systemd/system/glances.service

Paste the below-given block of text:

Note: Replace “linuxshout” in the given code with your current system username under which the glance service will be running.

[Unit]

Description=Glances
After=network.target

[Service]
ExecStart=/usr/local/bin/glances -w -t 5
User=linuxshout  
Restart=on-abort
RemainAfterExit=yes


[Install]
WantedBy=multi-user.target

Save the file- press Ctrl+X, type Y, and then hit the Enter key.

Reload Daemon:

sudo systemctl daemon-reload

Now, Enable and start the service file:

sudo systemctl enable glances.service
sudo systemctl start glances.service
sudo systemctl status glances.service
Create Glances systemd service file

Step 7: Access Glances Web Interface

As we have created the Glances service file successfully, it will be now running in the background, which means we can access its web interface to get a real-time view of our system resource consumption through any web browser.

For that open any browser on our local system or remote. If you are using a local system or SSH tunnel then can use the localhost along with the port number “61208” to access it.

For example:

http://127.0.0.1:61208/

Whereas, those who have installed Glances on some remote system and want to access it, need to open port “61208” in either the system or the cloud service provider’s firewall. For the local UFW firewall, the command will be:

sudo ufw allow 61208

Now, enter the IP address of the remote glance server along with port 61208. Example

http://192.168.1.10:61208/
Steps to install Glances on Ubuntu 24.04

Server/client mode on Ubuntu 24.04 (optional)

If you want to access the data from another system using a terminal but without using ssh then run the server & client mode of this monitoring tool.

So, first run Glances in server mode on the system that data you want to access remotely, use

glances -s

After that, on your local system use the client mode of Glances and connect to the remote system where the server part of Glances already running via the domain or its IP address.

glances -c @SERVER-IP

This is quite handy if you don’t want to log in to the server but still want to monitor its hardware.

Note: Both Remote and Client computers must have glances installed to get performance data.

Upgrade and Uninstallation, If required (optional)

As we have installed the Glances using the Python Pipx therefore running the APT system update and upgrade of Ubuntu will not update Glances to its latest version. Hence, if you find there is any update available, here is the command to run:

pipx upgrade glances

Whereas, those who don’t require this monitoring tool anymore and want to remove Glances completely from Ubuntu 24.04, can run the given command:

pipx uninstall glances

Remove the service file as well:

sudo rm /etc/systemd/system/glances.service

Other Articles:

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.