Installing Glances on Linux for System Monitoring

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 Glance’s developers alike.

This article explains how to Install Glances on Linux in three different ways:

  • Install Glances on RedHat
  • Install Glances on Ubuntu
  • Install Glances on any Version of Linux using Python.

What is Glances System Monitoring?

Glances is a really cool Linux monitoring tool available on nearly all Linux Distributions. The project’s full title is Glancesโ€”An Eye on Your System. It is a popular Github project written by NicoLargo and maintained by the community.

It is a great tool for monitoring a server. It gives detailed information about CPU, MEM, DISK, and server performance; it can also be hosted as a web server, which is a great feature, allowing system administrators to give developers real-time monitoring of a platform during upgrades or peak season.

Glances provides a comprehensive overview of critical system resources, such as:

  • CPU usage
  • Memory usage
  • Disk I/O
  • Network interface activity
  • Processes

With Glances, you gain valuable insights into the health and performance of your Linux servers, enabling proactive management and troubleshooting.

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.

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

Bash
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.

Bash
wget https://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/e/epel-release-7-11.noarch.rpm

Install the package with RPM.

Bash
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

Bash
yum install glances -y

Glances

Step 4 โ€“ Start Glances

Just type glances on the command line to start the application

Bash
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:

Bash
sudo apt update -y

#Optional
sudo apt upgrade -y

Step 2: Install Glances

Next, install Glances using the following command:

Bash
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:

Bash
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:

Bash
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:

Bash
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

Bash
sudo apt install python3 python3-pip -y

Next, install Glances using pip:

Step 2 – Use Pip to Install Glances

Bash
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:

CommandDescription
AShow/hide sensors’ stats
bSwitch between bit/s or Byte/s for network I/O
BView disk I/O counters per second
cSort processes by CPU usage
dShow/hide disk I/O stats
DEnable/disable Docker stats
eEnable/disable top extended stats
EErase the current process filter
fShow/hide file system and folder monitoring stats
FSwitch between file system used and free space
gGenerate graphs for current history
hShow/hide the help screen
iSort processes by I/O rate
IShow/hide the IP module
lShow/hide log messages
mSort processes by MEM usage
MReset processes summary min/max
nShow/hide network stats
NShow/hide the current time
pSort processes by name
qQuit the current Glances session (also ESC or CTRL-C)
QShow/hide the IRQ module
rReset history
RShow/hide the RAID plugin
sShow/hide process stats
tSort processes by CPU times (TIME+)
TView network I/O as a combination
uSort processes by USER
UView cumulative network I/O
wDelete finished warning log messages
WShow/hide Wifi module
xDelete finished warning and critical log messages
zShow/hide processes stats
0Enable/disable Irix/Solaris mode
1Switch between global CPU and per-CPU stats
2Enable/disable left sidebar
3Enable/disable the quick look module
4Enable/disable all but quick look and load module
5Enable/disable top menu (QuickLook, CPU, MEM, SWAP, LOAD)
6Enable/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)
Elsewhere On TurboGeek:  What is Linux, and Why Should I Use It?

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.

Thanks for taking the time to read this article. if you have any questions or feedback, please write in the comment section below.

Richard.Bailey

Richard Bailey, a seasoned tech enthusiast, combines a passion for innovation with a knack for simplifying complex concepts. With over a decade in the industry, he's pioneered transformative solutions, blending creativity with technical prowess. An avid writer, Richard's articles resonate with readers, offering insightful perspectives that bridge the gap between technology and everyday life. His commitment to excellence and tireless pursuit of knowledge continues to inspire and shape the tech landscape.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

Translate ยป