Linux Server Real-Time Monitoring with Glances

Today I’m going share a tool to monitor any Linux server in real-time. The tool is Glances. Glances is a cross-platform system monitoring tool written in Python. We can install it on our server in some ways. Let’s start.

Table of Contents

  1. Install Python
  2. Install Using Official Script
  3. Install From Repository
  4. Install Using PIP
  5. Glances Usage

Step 1 : Install Python

As Glances is written in Python, we need to install Python on our server. Let’s do this:

# CentOS/RHEL:
sudo yum install python python-devel

# Ubuntu
sudo apt-get install python python-dev

Step 2 : Install Using Official Script

The easiest way to install Glances on a server using their official script. The latest version of Glances will be installed. Just run this command:

sudo curl -L https://bit.ly/glances | /bin/bash
# or,
sudo wget -O- https://bit.ly/glances | /bin/bash

This script supports most of the Linux distributions. If it doesn’t work on your server, then please follow another method.

Step 3 : Install from Repository

Ubuntu Server: Glances is available with the default Ubuntu repository. Just run this command to install:

sudo apt-get install glances

CentOS/RHEL Server: On CentOS/RHEL, Glances is available with EPEL repository. Run the following command on your server:

# RHEL/CentOS 8:
sudo dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm

# RHEL/CentOS 7:
sudo rpm -Uvh https://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/e/epel-release-7-11.noarch.rpm

# RHEL/CentOS 6 (64 Bit):
sudo rpm -Uvh http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

# RHEL/CentOS 6 (32 Bit):
sudo rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm

After that run this command:

sudo yum install glances

Step 4 : Install Using PIP

If you have PIP installed on your server, then you are able to install Glances using PIP. Here’s the command:

sudo pip install glances

Step 5 : Glances Usage

We have successfully installed Glances on our machine. We can run Glances in 3 ways:

  • Standalone Mode
  • Client-Server Mode
  • Web Server Mode

# Standalone Mode: If you want to monitor your local machine, then just run:

glances

You’ll see a screen like this:

# Client-Server Mode: If you want to remotely monitor a machine, then this command on your machine:

glances -s

# Glances server is running on 0.0.0.0:61209

Now from the remote machine, monitor your server by running this command:

glances -c IP_ADDRESS_OF_YOUR_SERVER

# Web Server Mode: To run the glances in web server mode, execute the following command:

glances -w

# Glances web server started on http://0.0.0.0:61208/

If you see an error like Bottle module not found. Glances cannot start in web server modethen install bottle using PIP:

sudo pip install bottle

You can also set the refresh rate of the page. To refresh the page every 20 seconds, just visit like this http://server-ip:61208/20.

The article is over. Thanks for reading.