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:

Glances Monitoring Tool on Ubuntu

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:

Glances web access

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.

Share this page:

Suggested articles

0 Comment(s)

Add comment