Glances is a real-time system monitoring tool written in Python language. It monitors system resources, including CPU, Memory, Load, Disk I/O, Processes, File System space, Network interface, and more. It also offers a web-based interface that allows you to monitor system resources from the remote system over the internet.

Glances Features

Glances monitors and display the information about:

  • RAM, Swap, and free memory usage.
  • Average CPU load of the system.
  • Total active and sleeping processes.
  • Disk I/O.
  • Display file system space.
  • Display current date and time.

In this guide, we will show you how to monitor system resources with Glances on Ubuntu 20.04.

Prerequisites

  • A server running Ubuntu 20.04.
  • A root password is configured on the server.

Install Glances

By default, Glances is included in the Ubuntu default repository. You can install it with the following command:

apt-get install glances -y

After installing Glances, verify the installed version of Glances using the following command:

glances --version

You should see the following output:

Glances v3.1.3 with psutil v5.5.1

Now, run the Glances using the following command:

glances

You should see the following screen:

<img alt="Glances Monitoring Tool on Ubuntu" data-ezsrc="https://kirelos.com/wp-content/uploads/2021/06/echo/p1.png60c76cec40dc5.jpg" ezimgfmt="rs rscb3 src ng ngcb3" height="414" loading="lazy" src="data:image/svg xml,” width=”750″>

You should see all the system-related information on a single page with different colors in the above screen.

An explanation of each color code is shown below:

  • Green: Everything is going well.
  • Blue: Caution.
  • Violeta: Warning.
  • Red color: Critical.

Keyboard Shortcuts of Glances

After running Glances, you can use the following keyboard shortcuts to display the information in a more orderly and clear way:

  • m: Sort processes by MEM%
  • p: Sort processes by name
  • c: Sort processes by CPU%
  • i: Sort processes by I/O rate
  • s: Show/hide sensors stats
  • n: Show/hide network stats
  • x: Delete warning and critical logs
  • d: Show/hide disk I/O stats
  • a: Sort Processes automatically
  • f: Show/hide file system statshddtemp
  • y: Show/hide hddtemp stats
  • l: Show/hide logs
  • h: Show/hide help screen
  • q: Quit
  • w: Delete warning logs

Run Glances in Web Server Mode

Run a Glances in web server mode will allow you to monitor your system resources through the web browser.

First, create a systemd service file to run Glances in a web server mode:

nano /usr/lib/systemd/system/glancesweb.service

Add the following lines:

[Unit]
Description = Glances in Web Server Mode
After = network.target

[Service]
ExecStart = /usr/bin/glances  -w  -t  5

[Install]
WantedBy = multi-user.target

Save and close the file then reload the systemd daemon with the following command:

systemctl daemon-reload

Next, start the Glances service and enable it to start at system reboot:

systemctl start glancesweb

systemctl enable glancesweb
systemctl status glancesweb

You should see the following output:

? glancesweb.service - Glances in Web Server Mode
     Loaded: loaded (/lib/systemd/system/glancesweb.service; disabled; vendor preset: enabled)
     Active: active (running) since Wed 2021-06-09 05:11:37 UTC; 34s ago
   Main PID: 31150 (glances)
      Tasks: 1 (limit: 4691)
     Memory: 36.3M
     CGroup: /system.slice/glancesweb.service
             ??31150 /usr/bin/python3 /usr/bin/glances -w -t 5

Jun 09 05:11:37 ubuntu2004 systemd[1]: Started Glances in Web Server Mode.

At this point, Glances is started and listen on port 61208. You can check the listening port with the following command:

ss -antpl | grep 61208

You should see the following output:

LISTEN    0         5                  0.0.0.0:61208            0.0.0.0:*        users:(("glances",pid=31150,fd=7))                                             

Now, open your web browser and access the Glances using the URL http://your-server-ip:61208. You should see the following page:

<img alt="Glances web access" data-ezsrc="https://kirelos.com/wp-content/uploads/2021/06/echo/p2.png60c76cec89246.jpg" ezimgfmt="rs rscb3 src ng ngcb3" height="394" loading="lazy" src="data:image/svg xml,” width=”750″>

You can now use different keyboard shortcuts to filter the output.

Conclusion

Congratulations! you have successfully installed Glances on Ubuntu 20.04 server. You can now easily monitor your system resource usage from the command-line or web browser.

<img alt="Hitesh Jethva" data-ezsrc="https://kirelos.com/wp-content/uploads/2021/06/echo/hitesh-80.jpg" ezimgfmt="rs rscb3 src ng ngcb3" src="data:image/svg xml,”>

About Hitesh Jethva

Over 8 years of experience as a Linux system administrator. My skills include a depth knowledge of Redhat/Centos, Ubuntu Nginx and Apache, Mysql, Subversion, Linux, Ubuntu, web hosting, web server, Squid proxy, NFS, FTP, DNS, Samba, LDAP, OpenVPN, Haproxy, Amazon web services, WHMCS, OpenStack Cloud, Postfix Mail Server, Security etc.