Installing Glances on Linux for System Monitoring
This article was rechecked for accuracy in September 2024
Glances is a powerful cross-platform monitoring tool for Linux renowned for its real-time insights into system resource usage. This versatile tool, written in Python, offers a command line and a web-based interface, making it indispensable for Linux system administrators and developers alike.
With Glances, you gain valuable insights into the health and performance of your Linux servers, enabling proactive management and troubleshooting. It provides a comprehensive overview of critical system resources, such as:
- CPU usage
- Memory usage
- Disk I/O
- Network interface activity
- Processes
This article explains how to Install Glances on Linux in three different ways:
- Install Glances on RedHat-based systems (CentOS, RHEL, Rocky Linux, AlmaLinux)
- Install Glances on Ubuntu/Debian
- Install Glances on any version of Linux using Python (pip)
Click here for the GitHub site.
How to install Glances on CentOS / Red Hat / Rocky Linux
Here is a quick guide to installing Glances in CentOS 7. Please note that CentOS 7 is nearing its end-of-life (June 30, 2024), and it is recommended to migrate to CentOS 8 or its derivatives (Rocky Linux, AlmaLinux) for new installations.
Step 1 โ Install the Pre-Reqs
It is recommended to complete a yum update
before proceeding; this ensures that any dependencies are at the right level. Next, install wget
if you do not already have it.
yum update -y
yum install wget -y
Step 2 โ Add the Fedora Repo That Contains Glances
Add the Fedora repo to CentOS. This is not a default repository, so you have to add it manually.
wget https://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/e/epel-release-7-11.noarch.rpm
Install the package with RPM.
rpm -ivh epel-release-7-11.noarch.rpm
Step 3 โ Install glances
Now that you have added the required repo,you can use Yum to install glances
yum install glances -y
Step 4 โ Start Glances
Just type glances on the command line to start the application
glances
How to install Glances on Ubuntu / Debian
Step 1: Update the Package List
Before installing any new software, it’s a good practice to update the package list to ensure you are installing the latest version. Open a terminal and run the following command:
sudo apt update -y
#Optional
sudo apt upgrade -y
Step 2: Install Glances
Next, install Glances using the following command:
sudo apt install glances -y
Step 3: Verify the Installation
After the installation is complete, you can verify that Glances was installed correctly by running the following command:
You should see output like this:
glances -V
Glances v3.2.4.2 with PsUtil v5.9.0
Log file: /home/rbailey/.local/share/glances/glances.log
This command should return the version of Glances that is currently installed on your system.
Step 4: Run Glances
Now, you can run Glances to monitor your system. Use the following command to start Glances:
glances
This will open the Glances interface, where you can monitor various system metrics, such as CPU, memory, and disk usage.
Step 5: Exploring Additional Options
Glances offers several additional options and features. You can explore these by using the help command:
This command will display a list of all the available options and how to use them.
Such as:
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
##Example Output:
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 rate (standalone mode):
glances -t 5 --export influxdb
#Start a Glances XML-RPC server (server mode):
glances -s
#Connect Glances to a Glances XML-RPC 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
How to Install Glances using Python Pip
Alternatively, you can install Glances using pip, the Python package installer. First, install pip with the following command:
Step 1 – Install Python and Pip
sudo apt install python3 python3-pip -y
Next, install Glances using pip:
Step 2 – Use Pip to Install Glances
sudo pip3 install glances
This method can be used if you want to install a newer version of Glances that may not be available in the Ubuntu repositories.
Requirements
- python 2.7,>=3.4
- psutil>=5.3.0 (better with the latest version)
Glances Interactive Command-List
Glances offers a wealth of keyboard shortcuts for efficient system monitoring. Here’s a breakdown of the commands:
Automatic Sorting:
- Glances can sort the process list automatically based on system conditions:
- If CPU > 70%, sort by CPU usage.
- If MEM > 70%, sort by MEM usage.
- If CPU iowait > 60%, sort by I/O read and write.
Interactive Commands:
Command | Description |
---|---|
A | Show/hide sensors’ stats |
b | Switch between bit/s or Byte/s for network I/O |
B | View disk I/O counters per second |
c | Sort processes by CPU usage |
d | Show/hide disk I/O stats |
D | Enable/disable Docker stats |
e | Enable/disable top extended stats |
E | Erase the current process filter |
f | Show/hide file system and folder monitoring stats |
F | Switch between file system used and free space |
g | Generate graphs for current history |
h | Show/hide the help screen |
i | Sort processes by I/O rate |
I | Show/hide the IP module |
l | Show/hide log messages |
m | Sort processes by MEM usage |
M | Reset processes summary min/max |
n | Show/hide network stats |
N | Show/hide the current time |
p | Sort processes by name |
q | Quit the current Glances session (also ESC or CTRL-C) |
Q | Show/hide the IRQ module |
r | Reset history |
R | Show/hide the RAID plugin |
s | Show/hide process stats |
t | Sort processes by CPU times (TIME+) |
T | View network I/O as a combination |
u | Sort processes by USER |
U | View cumulative network I/O |
w | Delete finished warning log messages |
W | Show/hide Wifi module |
x | Delete finished warning and critical log messages |
z | Show/hide processes stats |
0 | Enable/disable Irix/Solaris mode |
1 | Switch between global CPU and per-CPU stats |
2 | Enable/disable left sidebar |
3 | Enable/disable the quick look module |
4 | Enable/disable all but quick look and load module |
5 | Enable/disable top menu (QuickLook, CPU, MEM, SWAP, LOAD) |
6 | Enable/disable mean GPU mode/Switch process cmd line/name |
Optional dependencies:
- bernhard (for the Riemann export module)
- bottle (for Web server mode)
- cassandra-driver (for the Cassandra export module)
- couchdb (for the CouchDB export module)
- docker (for the Docker monitoring support) [Linux-only]
- elasticsearch (for the Elastic Search export module)
- hddtemp (for HDD temperature monitoring support) [Linux-only]
- influxdb (for the InfluxDB export module)
- kafka-python (for the Kafka export module)
- netifaces (for the IP plugin)
- nvidia-ml-py3 (for the GPU plugin)
- pika (for the RabbitMQ/ActiveMQ export module)
- potsdb (for the OpenTSDB export module)
- prometheus_client (for the Prometheus export module)
- py-cpuinfo (for the Quicklook CPU info module)
- pygal (for the graph export module)
- pymdstat (for RAID support) [Linux-only]
- pySMART.smartx (for HDD Smart support) [Linux-only]
- pysnmp (for SNMP support)
- pystache (for the action script feature)
- pyzmq (for the ZeroMQ export module)
- requests (for the Ports, Cloud plugins and RESTful export module)
- scandir (for the Folders plugin) [Only for Python < 3.5]
- statsd (for the StatsD export module)
- wifi (for the wifi plugin) [Linux-only]
- zeroconf (for the auto-discover mode)
Using Glances: Web Server Mode, Commands, and More
- Web Server Mode: Glances can be run in web server mode, providing a convenient web interface accessible from any browser. Start it with:
glances -w
- Command-line Interface: Glances offers a rich set of commands and keyboard shortcuts for efficient system monitoring. Type
h
within Glances for a complete list. - Configuration File: Customize Glances behaviour through its configuration file, usually located at
/etc/glances/glances.conf
. This is where you can adjust settings like refresh intervals, warning thresholds, and modules to load. - Export Stats: Glances can export stats to various formats and destinations, including CSV files or external databases like InfluxDB. Refer to the documentation for detailed instructions.
- Upgrading Glances: To ensure you have the latest features and bug fixes, you can upgrade Glances using
pip3 install --upgrade glances
.
Additional Tips for Linux System Administrators
- Glances can be especially helpful when troubleshooting performance issues after a system reboot.
- Familiarize yourself with the systemd service file to manage Glances as a service (e.g.,
/lib/systemd/system/glances.service
). - Explore Glances’ extensive documentation for advanced configuration options and optional features.
- Glances can be extended with plugins. Install the Python-dev package to get started developing your own plugins.
Glances is a versatile and powerful tool for monitoring Linux systems in real-time. By following the installation instructions and exploring its features, you can gain valuable insights into your system’s performance and proactively address any potential issues.
If you have any questions or feedback, feel free to leave a comment below!
Thanks for taking the time to read this article. if you have any questions or feedback, please write in the comment section below.
Recent Comments