How to Install Glances on Ubuntu 22.04 or 20.04

Glances is a powerful system monitoring tool that provides real-time information about system resources, including CPU, memory, disk, network usage, and more. It’s a cross-platform monitoring tool that can run on Linux, macOS, and Windows operating systems. Glances are designed to be lightweight, efficient, and easy to use, making them an ideal choice for system administrators and power users. Here are some key features that make Glances stand out:

  • Provides a color-coded interface that indicates the status of various system resources.
  • Supports monitoring multiple systems from a central location with a client-server architecture.
  • Has a web-based interface for monitoring system performance from any web browser.
  • It can be customized to adjust threshold levels and color-coded alerts.
  • Updates are easy with the pip3 package manager.

This guide will demonstrate installing Glances on Ubuntu 22.04 Jammy Jellyfish or Ubuntu 20.04 Focal Fossa using the command line terminal and PIP3.

Step 1: Install Glances on Ubuntu

To begin with, before installing Glances on your Ubuntu system, it is essential to ensure that all existing packages are up to date. You can achieve this by running the following command:

sudo apt update && sudo apt upgrade

Updating the packages will ensure that your system has the latest security updates and is more secure and stable.

Next, you must install Python and Pip, the package installer for Python, on your system. You can do this by running the following command:

sudo apt install python3 python3-dev python3-jinja2 python3-psutil python3-setuptools psensor psensor-server python3-pip lm-sensors -y

This command will install the necessary packages for Glances to function correctly on your Ubuntu system.

Now that you have installed all the necessary packages, you can install the Glances System Monitor on Ubuntu. You can achieve this by using PIP3, the package installer for Python3. To install Glances using PIP3, run the following command:

pip3 install glances

Because the guide has installed Glances using pip3 install glances, you cannot run the glances command; it may be because the directory containing the glances binary is not in your system’s PATH.

Add the directory containing the glances binary to your system’s PATH environment variable to fix this issue. You can do this by adding the following line to your shell’s configuration file (e.g., .bashrc, .zshrc, etc.):

export PATH="$PATH:~/.local/bin"

This line will add the ~/.local/bin directory to your system’s PATH, where pip installs packages by default.

After adding this line to your shell’s configuration file, you can run the following command to reload your shell’s configuration:

source ~/.bashrc

After installing Glances, you can verify the installation by checking the Glances build with the following command:

glances --version

Example output:

joshua@ubuntu-linux:~$ glances --version
Glances v3.3.1.1 with PsUtil v5.9.0
Log file: /home/joshua/.local/share/glances/glances.log

Step 2: Back Up Glances Configuration File

Before you modify the default configuration settings of Glances on an Ubuntu system, it is highly recommended to back up the original configuration file. The configuration file is located at /usr/local/share/doc/glances/glances.conf.

To back up the original configuration file, you can create a copy of the file in a different location using the following command:

cp ~/.local/share/doc/glances/glances.conf ~/.local/share/doc/glances/glances.conf.bak

This command creates a backup copy of the configuration file with the name glances.conf.bak in the same directory as the original file.

If the Glances configuration file is not located in the command above, modify it and use the following find command to locate the exact path in case it changes:

find / -name glances.conf

Once you have backed up the configuration file, you can modify the settings as desired. You can open the configuration file using a text editor and make the necessary changes to do this.

It is important to note that modifying the configuration file can significantly impact Glances’s performance and functionality. Therefore, making small and gradual changes is recommended, testing each change thoroughly and keeping a record of the changes made in case you need to revert to the original configuration settings.

Additional Commands & Tips

Glances Color-Coded Alters Explained

Glances provide color-coded alerts to indicate the status of various system resources. The color scheme in the alerts helps quickly identify a resource’s state, whether normal, warning, or critical. This visual cue makes it easy for system administrators to monitor system resources and take corrective action when necessary.

Default colors:

  1. GREEN: OK (good)
  2. BLUE: CAREFUL (attention)
  3. VIOLET: WARNING (alert)
  4. RED: CRITICAL (critical)

The default threshold levels for system resources in Glances are set as follows:

  • CPU usage: The normal threshold is set at 80%, the warning threshold is set at 90%, and the critical threshold is set at 95%.
  • Memory usage: The normal threshold is set at 80%, the warning threshold is set at 90%, and the critical threshold is set at 95%.
  • Network usage: The normal threshold is set at 1000Kbps, the warning threshold is set at 5000Kbps, and the critical threshold is set at 10000Kbps.

It is important to note that these default thresholds are customizable. Users can adjust these thresholds to suit their specific system environment and need better.

To modify the threshold levels for the color-coded alerts, you need to open the main configuration file located at /usr/local/share/doc/glances/glances.conf. You can do this using a text editor, such as the nano editor, by running the following command:

sudo nano ~/.local/share/doc/glances/glances.conf

By opening the main configuration file located at /usr/local/share/doc/glances/glances.conf using a text editor, you can access and modify various settings related to the color-coded alerts in Glances. This includes customizing the thresholds for system resource usage and modifying other parameters that affect the behavior of the color-coded alerts.

Example:

example of glances configuration files on ubuntu 22.04 or 20.04 lts

Once you have located the settings options related to the color-coded alerts in the Glances configuration file, you can modify them by adjusting the corresponding numerical values. It is important to note that the default values are typically suitable for most user setups. Therefore, you should only modify them if you strongly disagree with the default settings.

After making the desired changes, you can save the modified configuration file by pressing “CTRL+O” and exit the text editor by pressing “CTRL+X”. Doing so will save and apply your changes to the Glances configuration.

Glances Terminal Command Options

Glances provide a variety of terminal commands that can be useful in day-to-day operations. Here are ten quick examples of Glance’s terminal commands:

Start Glances in terminal mode.

glances

Start Glances in web server mode.

glances -w

Start Glances in CSV output mode.

glances -C

Start Glances in JSON output mode.

glances -J

Display system information for a specific process by name.

glances -p <process_name>

Display information for a specific process by PID.

glances -P <PID>

Display information for a specific process by the user.

glances -u <user_name>

Display information for a specific process by name and sort by CPU usage.

glances -p <process_name> --sort-by cpu_percent

Start Glances in quiet mode.

glances -q

Help on Glance’s command line options.

glances --help

These are just a few examples of the many commands and options available to customize Glances. Using these commands and options, you can tailor Glances to meet your needs and preferences.

Run Glances in Web Browser

Glances allow you to monitor your system performance and resource usage through a web browser without installing additional dependencies. To initiate the Glances web interface, run the following command in the terminal:

glances -w

After running the command, you may see a message in the terminal that displays “Glances Web User Interface started on http://0.0.0.0:61208”. However, do not be alarmed if you see the IP address “0.0.0.0” instead of your server’s IP address. The IP address “0.0.0.0” serves as a placeholder, indicating that the web interface can be accessed from any device on the same network. To access the web interface, replace “0.0.0.0” with the server’s IP address and the default port number, 61208.

To add password protection to the web interface, use the following command to set a password:

glances --web-password=yourpassword

Note that you must replace ‘your password’ with the password you want to set. This will enable password protection for the web interface and prompt users to enter the password before accessing the web interface.

Access the Glances web interface in a browser; you can enter the IP address of the server running Glances and the default port 61208 in the address bar of your web browser. For example: “http://192.168.1.100:61208” This will open the web interface in your browser, where you can monitor your system performance and resource usage.

http://<ip address>:61209

Make sure to replace ‘yourpassword’ with your desired password. This will prompt users to enter the password before accessing the web interface.

To access the Glances web interface, enter the server’s IP address and the default port 61208 in the address bar of your web browser. For example, “http://192.168.1.100:61208”. This will open the web interface in your browser, where you can monitor your system performance and resource usage.

If you want to keep Glances running in the background on your primary client, you can use the following command:

glances -w &

To detach the process from the terminal, use the “disown” command as follows:

disown %1

This removes the process from the shell’s job control and enables it to run independently of the terminal. If you need to stop the Glances process from running in the background, use the following command:

pkill -f glances

This command will kill all active Glances processes running in the background, including other processes containing the string “glances” in their command.

Run Glances Client Mode

Glances client-server architecture is an essential feature that enables you to monitor multiple remote servers from a central location. Glances must be installed on all servers you want to monitor to use this feature.

To start Glances in server mode on the server machine, run the following command:

glances -s <ip:port>

For instance, if the server’s IP address is 192.168.1.100 and the port is 61208, use the following command:

glances -s 192.168.1.100:61208

To start Glances in client mode on the client machine, run the following command:

glances -c <ip:port>

For example, if the server’s IP address is 192.168.1.100 and the port is 61208, use the following command:

glances -c 192.168.1.100:61208

This will connect Glances to the server and display real-time information about the server’s system performance and resource usage.

Note that the IP address and port of the server can be obtained by checking the output of the command “glances -s ip:port” executed on the server machine.

You can also connect to a server with a password using the “–client-password” option as follows:

glances --client-password=<your_password> -c <ip:port>

By doing so, you can securely monitor the performance of multiple systems from a central location using Glances.

Update Glances with PIP3

To update Glances to the latest version, run the following command:

pip3 install --upgrade glances

Running this command within a virtual environment is advisable to avoid conflicts with other installed packages.

You may also need to upgrade the “psutil” package using the following command:

pip3 install --upgrade psutil

If you want to perform a more comprehensive update, use the following command:

pip3 list --outdated

Executing the command “pip3 list –outdated” will show a list of all outdated packages, including Glances if it was installed with PIP3, along with multiple other packages. From this list, you can update each package to its latest version by running the following command with the package name:

pip3 install  --upgrade <package_name>

By updating each package, including Glances, to its latest version, you can ensure that the system monitoring tool and its dependencies are up-to-date with the latest features and bug fixes.

Remove (Uninstall) Glances

To remove or uninstall Glances from your system, you can execute the following command:

pip3 uninstall glances

Alternatively, you can use the command:

pip3 remove glances

Both commands will remove the Glances package and all its dependencies from your system. If you installed Glances using a virtual environment, you should activate the virtual environment before running either command.

In addition to removing the Glances package, it’s also recommended to check for any configuration files or add files or folders created during the installation. You can use the command:

pip3 show glances

This command will display the package’s location, and you can remove any associated files.

It’s essential to note that uninstalling Glances will remove all the data and configurations set up during installation. To retain this data, it’s recommended to back it up before uninstalling the program.

Conclusion

In conclusion, installing Glances with PIP3 on Ubuntu provides an efficient system monitoring tool that offers real-time performance and resource usage data. Users can quickly set up Glances and begin monitoring their system’s processes by following the simple installation steps. Glances’ customizable threshold levels and color-coded alerts make it easy for users to identify potential issues and take corrective action. Furthermore, with its client-server architecture, Glances allows for the remote monitoring of multiple servers from a central location. Overall, installing Glances with PIP3 on Ubuntu is a straightforward process that provides valuable insights into system performance, making it a valuable addition to any system administrator’s toolkit.

Additional Resources and Links

To broaden your knowledge of Glances and assist with its installation on Ubuntu, the following official resources and documentation are provided:

  • Glances Official Website: Visit the official website to explore Glances’ features, updates, and news directly from the developers.
  • Glances GitHub Repository: Access the source code, contribute, or report issues on the Glances GitHub repository.
  • Ubuntu Official Documentation: Gain comprehensive knowledge about Ubuntu, its features, and system administration through the official documentation.
  • Ubuntu Wiki: The Ubuntu Wiki offers a wealth of information on various topics, including troubleshooting, community support, and development.
  • Glances Documentation: Consult the Glances documentation to understand its usage, options, and configuration in depth.

Your Mastodon Instance
Share to...