Glances System Monitor is free, an open-source command-line tool for process monitoring, system resources such as CPU, Disk I/O, File System, Load Average, Memory, Network Interfaces and processes. Glances are built with Python language. Glances support cross-platform monitoring, which can be used with a web-based interface.
One of the excellent features Glances supports is setting thresholds in the program. You can set careful, warning, and critical in the configuration file, which will then relay information in colors that can show alerts to systems resources bottlenecks, system resources issues, and much more. Glances, by default, comes with a pre-set list of colors, but you can modify and add additional configs.
The following tutorial will demonstrate how to install Glances System Monitor on AlmaLinux 8 workstation or server using the command line console, create a systemd service file, create a web service and secure with firewalls, and lastly, some basic commands and maintenance tips.
Table of Contents
First, run a quick update to ensure all your packages are up-to-date to avoid conflicts during the tutorial and installation.
sudo dnf upgrade --refresh
Install Glances System Monitor
By default, Glances is not available on Appstream compared to some other distributions, and you will need to import the EPEL repository using the following command.
sudo dnf install epel-release epel-next-release -y
Before you continue, install the dependencies required to install and use Glances.
sudo dnf install python3 python3-jinja2 python3-psutil python3-setuptools hddtemp python3-pip lm_sensors -y
Next, install Glances using the DNF package manager by executing the following installation command.
sudo dnf install glances -y
Once installed, verify the version, which will check to see if it was installed successfully.
Now you would have noticed the path
/usr/bin/glances/ being used in the version output. Next, create a systemd service before installing the PIP bottle module.
sudo pip3 install bottle
Now, create the following service file using nano or the text editor of your choice.
sudo nano /etc/systemd/system/glances.service
Next, copy and paste the following.
[Unit] Description=Glances After=network.target [Service] ExecStart=/usr/bin/glances -w Restart=on-abort RemainAfterExit=yes [Install] WantedBy=multi-user.target
For users that used the nano editor, use
CTRL+O it to save and
CTRL+X to exit.
Now, enable the Glances system immediately and on system start.
sudo systemctl enable glances --now
Verify the status of the software by using the following
systemctl status command.
systemctl status glances
How To Use Glances Monitoring System
Once you have installed the program, familiar wise yourself with some of the basic commands that the tutorial will now cover.
To open Glances, use the following command.
Example terminal look:
To exit the Glances, use the following command.
Next, you can alternatively open Glances using a timer to help systems in intensive tasks. By default, the timer is 1, but you can change this as an example:
glances -t 3
This now changes the default time delay from 1 second to 3 seconds. However, you can set this much higher if required.
To bring up the help command, enter the following.
usage: glances [-h] [-V] [-d] [-C CONF_FILE] [--modules-list] [--disable-plugin DISABLE_PLUGIN] [--enable-plugin ENABLE_PLUGIN] [--disable-process] [--disable-webui] [--light] [-0] [-1] [-2] [-3] [-4] [-5] [-6] [--disable-history] [--disable-bold] [--disable-bg] [--enable-irq] [--enable-process-extended] [--export EXPORT] [--export-csv-file EXPORT_CSV_FILE] [--export-csv-overwrite] [--export-json-file EXPORT_JSON_FILE] [--export-graph-path EXPORT_GRAPH_PATH] [-c CLIENT] [-s] [--browser] [--disable-autodiscover] [-p PORT] [-B BIND_ADDRESS] [--username] [--password] [-u USERNAME_USED] [--snmp-community SNMP_COMMUNITY] [--snmp-port SNMP_PORT] [--snmp-version SNMP_VERSION] [--snmp-user SNMP_USER] [--snmp-auth SNMP_AUTH] [--snmp-force] [-t TIME] [-w] [--cached-time CACHED_TIME] [--open-web-browser] [-q] [-f PROCESS_FILTER] [--process-short-name] [--stdout STDOUT] [--stdout-csv STDOUT_CSV] [--hide-kernel-threads] [-b] [--diskio-show-ramfs] [--diskio-iops] [--fahrenheit] [--fs-free-space] [--sparkline] [--theme-white] [--disable-check-update] optional arguments: -h, --help show this help message and exit -V, --version show program's version number and exit -d, --debug enable debug mode -C CONF_FILE, --config CONF_FILE path to the configuration file --modules-list, --module-list display modules (plugins & exports) list and exit --disable-plugin DISABLE_PLUGIN, --disable-plugins DISABLE_PLUGIN disable plugin (comma separed list) --enable-plugin ENABLE_PLUGIN, --enable-plugins ENABLE_PLUGIN enable plugin (comma separed list) --disable-process disable process module --disable-webui disable the Web Interface --light, --enable-light light mode for Curses UI (disable all but top menu) -0, --disable-irix task's cpu usage will be divided by the total number of CPUs -1, --percpu start Glances in per CPU mode -2, --disable-left-sidebar disable network, disk I/O, FS and sensors modules -3, --disable-quicklook disable quick look module -4, --full-quicklook disable all but quick look and load -5, --disable-top disable top menu (QL, CPU, MEM, SWAP and LOAD) -6, --meangpu start Glances in mean GPU mode --disable-history disable stats history --disable-bold disable bold mode in the terminal --disable-bg disable background colors in the terminal --enable-irq enable IRQ module --enable-process-extended enable extended stats on top process --export EXPORT enable export module (comma separed list) --export-csv-file EXPORT_CSV_FILE file path for CSV exporter --export-csv-overwrite overwrite existing CSV file --export-json-file EXPORT_JSON_FILE file path for JSON exporter --export-graph-path EXPORT_GRAPH_PATH Folder for Graph exporter -c CLIENT, --client CLIENT connect to a Glances server by IPv4/IPv6 address or hostname -s, --server run Glances in server mode --browser start the client browser (list of servers) --disable-autodiscover disable autodiscover feature -p PORT, --port PORT define the client/server TCP port [default: 61209] -B BIND_ADDRESS, --bind BIND_ADDRESS bind server to the given IPv4/IPv6 address or hostname --username define a client/server username --password define a client/server password -u USERNAME_USED use the given client/server username --snmp-community SNMP_COMMUNITY SNMP community --snmp-port SNMP_PORT SNMP port --snmp-version SNMP_VERSION SNMP version (1, 2c or 3) --snmp-user SNMP_USER SNMP username (only for SNMPv3) --snmp-auth SNMP_AUTH SNMP authentication key (only for SNMPv3) --snmp-force force SNMP mode -t TIME, --time TIME set refresh time in seconds [default: 3 sec] -w, --webserver run Glances in web server mode (bottle needed) --cached-time CACHED_TIME set the server cache time [default: 1 sec] --open-web-browser try to open the Web UI in the default Web browser -q, --quiet do not display the curses interface -f PROCESS_FILTER, --process-filter PROCESS_FILTER set the process filter pattern (regular expression) --process-short-name force short name for processes name --stdout STDOUT display stats to stdout, one stat per line (comma separated list of plugins/plugins.attribute) --stdout-csv STDOUT_CSV display stats to stdout, csv format (comma separated list of plugins/plugins.attribute) --hide-kernel-threads hide kernel threads in process list (not available on Windows) -b, --byte display network rate in byte per second --diskio-show-ramfs show RAM Fs in the DiskIO plugin --diskio-iops show IO per second in the DiskIO plugin --fahrenheit display temperature in Fahrenheit (default is Celsius) --fs-free-space display FS free space instead of used --sparkline display sparklines instead of bar in the curses interface --theme-white optimize display colors for white background --disable-check-update disable online Glances version ckeck Examples of use: Monitor local machine (standalone mode): $ glances Display all Glances modules (plugins and exporters) and exit: $ glances --module-list Monitor local machine with the Web interface and start RESTful server: $ glances -w Glances web server started on http://0.0.0.0:61208/ Only start RESTful API (without the WebUI): $ glances -w --disable-webui Glances API available on http://0.0.0.0:61208/api/ Monitor local machine and export stats to a CSV file (standalone mode): $ glances --export csv --export-csv-file /tmp/glances.csv Monitor local machine and export stats to a InfluxDB server with 5s refresh time (standalone mode): $ glances -t 5 --export influxdb Start a Glances XML/RCP server (server mode): $ glances -s Connect Glances to a Glances XML/RCP server (client mode): $ glances -c <ip_server> Connect Glances to a Glances server and export stats to a StatsD server (client mode): $ glances -c <ip_server> --export statsd Start the client browser (browser mode): $ glances --browser Display stats to stdout (one stat per line): $ glances --stdout now,cpu.user,mem.used,load Display CSV stats to stdout (all stats in one line): $ glances --stdout-csv now,cpu.user,mem.used,load Disable some plugins (comma separated list): $ glances --disable-plugin network,ports Enable some plugins (comma separated list): $ glances --enable-plugin sensors
Alerts in Glances
As mentioned at the start of the tutorial, Glances has the color for alerts. The following describes what they are.
- GREEN: OK (good)
- BLUE: CAREFUL (attention)
- VIOLET: WARNING (alert)
- RED: CRITICAL (critical)
The thresholds that default settings are as follows.
The default configuration can be changed. To do this, open up the file located at
/etc/glances/glances.conf. But firstly, let’s make a backup of the original configuration file for safekeeping which you can revert to if you make a mistake and need a fresh copy.
sudo cp /etc/glances/glances.conf /etc/glances/glances-bkup.conf
Next, open up the main configuration file using the nano text editor.
sudo nano /etc/glances/glances.conf
Copy and paste the following under Global.
[cpu] disable=False refresh=3 user_careful=50 user_warning=70 user_critical=90 iowait_careful=50 iowait_warning=70 iowait_critical=90 system_careful=50 system_warning=70 system_critical=90 steal_careful=50 steal_warning=70 steal_critical=90
For example, you would like to change the user CPU usage warning options.
user_careful=50 user_warning=70 user_critical=90
Change to (Increased example):
user_careful=70 user_warning=80 user_critical=90
Additionally, you can even edit the
[global] settings as follows below, pretty straightforward with
[global] # Refresh rate (default is a minimum of 2 seconds) # Can be overwrite by the -t <sec> option # It is also possible to overwrite it in each plugin sections refresh=2 # Does Glances should check if a newer version is available on PyPI ? check_update=false # History size (maximum number of values) # Default is 28800: 1 day with 1 point every 3 seconds history_size=28800
As mentioned above, the tutorial has increased the warning signs. However, you can set your own and increase or even lower what you think is appropriate for your environment and use case. Additionally, more settings can be imported to the
glances.conf file as well from the wiki; the list is extensive.
Using the nano text editor, use CTRL+O and CTRL+X to save and exit the file.
Ideally, you should restart the service also using the following command.
sudo systemctl restart glances
The following list commands you can use in Glances to configure, find and show what you are looking for.
|a||Sort processes automatically|
|c||Sort processes by CPU%|
|m||Sort processes by MEM%|
|p||Sort processes by name|
|i||Sort processes by I/O rate|
|d||Show/hide disk I/O stats|
|f||Show/hide file system statshddtemp|
|n||Show/hide network stats|
|s||Show/hide sensors stats|
|y||Show/hide hddtemp stats|
|b||Bytes or bits for network I/O|
|w||Delete warning logs|
|x||Delete warning and critical logs|
|1||Global CPU or per-CPU stats|
|h||Show/hide this help screen|
|t||View network I/O as combination|
|u||View cumulative network I/O|
|q||Quit (Esc and Ctrl-C also work)|
How to Run In Web Browser
For users that require remote monitoring, Glances can do this as all required dependencies are installed by default.
To initiate the browser function in the program, do the following.
Note that you will most likely see in the terminal display “Glances Web User Interface started on http://0.0.0.0:61208” when entering this command. This may look a little confusing, using the server’s IP address.
You can set a password for the web-based monitor by typing the following command.
glances -w --password
To open the web browser for the program, enter your IP server address with the default port 61208 as an example.
For your primary client, you can keep glances running in the background with the following command.
glances -w &
The above creates a background running process. Now you must disown the current state.
If you need to kill the processors in background mode, type the following to kill all active glances sessions.
How to Run Client-Server Mode
Another great feature of the Glances program is that it provides client-server architecture. This means you can run glances on multiple remote servers and connect them to your primary client, and all servers must have Glances installed.
Log in to the remote server start the glance program in server-side mode.
After you have finished starting server-side monitoring on all the required servers you need, go to your client system and connect to the system’s IP address running the server-client mode with the following command.
glances -c server-IP-address:61208
By default, no rules are set up for Glances with the system firewall. For users that will have Glances publically accessible, this should be set up to avoid disaster and hacking of your server. Below are some basic firewalld options to create allow rules essential to stop attacks.
First, add a new dedicated zone for Glances firewalld policy:
sudo firewall-cmd --permanent --new-zone=glances
Next, specify the allowed IP addresses permitted to access the Glances.
sudo firewall-cmd --permanent --zone=glances --add-source=188.8.131.52
Replace 184.108.40.206 with the IP address that will be added to the allow list.
Optionally, you can list a subnet.
sudo firewall-cmd --permanent --zone=glances --add-source=220.127.116.11/24
Now open the port of the Glances. By default, this is TCP port 61208.
sudo firewall-cmd --permanent --zone=glances --add-port=61208/tcp
Note you can change the default port in your configuration file if you change the firewall port open rule above to the new value.
After running those commands, reload the firewall to implement the new rules:
sudo firewall-cmd --reload
Example output if successful:
Comments and Conclusion
In the tutorial, you have learned how to install the Glances System Monitor on AlmaLinux 8, a step above the default “top” package for monitoring system resources and processors that ship with default Linux installations. This package is ideal, especially if you want a better system overview. It covers much more information and presents it in color codes to signal what the data in front of you means and how it affects your server.
The extra benefit of remote monitoring makes this one of the more popular options for simple server monitoring. It continues to get better with an active development continuing to this day.