Glances is an advanced system monitoring tool that provides real-time statistics on your server's performance. This article explains how to install Glances on an Ubuntu VPS and demonstrates its usage to monitor CPU, memory, disk, and network activity. Glances helps maintain optimal performance for your server.
8 min
Edited:12-10-2024
Glances is an open-source, cross-platform system monitoring tool that provides an all-in-one dashboard for real-time insights into your server’s performance. It displays key metrics such as CPU usage, memory consumption, disk I/O, network bandwidth, and process information. Glances is highly efficient, adapting its display to the available terminal size, and it can be accessed remotely via the web or through API integration. The key advantage of Glances is its simplicity and versatility, allowing both novice and experienced system administrators to monitor server health efficiently. It provides detailed statistics in a single window, which can be customized to suit different environments.
1 - Real-Time Monitoring: Glances offers real-time data on CPU, memory, disk, network, and processes, allowing administrators to track server health continuously.
2 - Cross-Platform: It works on many platforms, including Linux, Windows, and macOS.
3 - Remote Monitoring: Glances supports monitoring a server remotely via a web interface or API.
4 - Plugins and Extensions: It supports a range of plugins that extend its capabilities, such as monitoring Docker containers and system sensors.
5 - Custom Alerts: You can set up thresholds and alerts for critical system metrics to take action when resources run low.
Installing Glances on your Ubuntu VPS is simple. Here’s how to do it:
As always, begin by updating your system’s package list to ensure you have the latest versions of packages and security patches:
1. sudo apt update
2. sudo apt upgrade
Before installing Glances, make sure the required dependencies are installed, including python3-pip for managing Python packages:
1. sudo apt install python3-pip
There are several ways to install Glances, but the easiest method is using Python’s package manager pip. To install Glances, use the following command:
1. sudo pip3 install glances
To enable additional system sensors such as temperature monitoring, you can install the psutil package:
1. sudo pip3 install glances[all]
This will enable all optional plugins that may not be included in the default installation.
Once the installation is complete, you can start Glances by simply typing:
1. glances
This will launch the Glances monitoring interface in your terminal.
Now that Glances is installed, let’s go through some key features and commands to use it effectively for monitoring your VPS.
When you launch Glances, you’ll see a comprehensive dashboard displaying various system metrics:
CPU: Displays CPU usage for each core, system load, and related data.
Memory: Shows total, used, free, and swap memory usage.
Disk I/O: Displays read/write speed for disks and storage devices.
Network: Shows real-time network traffic (upload/download speeds) and active connections.
Processes: Lists the most resource-hungry processes in real-time, including CPU and memory usage.
You can interact with Glances and customize the data displayed using the following keyboard shortcuts:
h: Displays the help menu, which lists all available commands.
q: Quit Glances.
s: Sort the process list by various metrics (e.g., CPU, memory, disk I/O).
l: Display disk I/O statistics.
m: Display network statistics.
c: View CPU statistics.
1: Toggle between global and per-core CPU usage.
One of the most powerful features of Glances is the ability to monitor a server remotely using a web interface. To enable this feature, run Glances in server mode:
1. glances -w
This interface allows you to view the same monitoring data in a graphical format, which can be useful for remote management.
Glances allows you to set thresholds for critical system metrics, such as CPU usage or memory consumption, so that it can display alerts when these metrics cross a certain limit. This is done by editing the configuration file located at /etc/glances/glances.conf.
Here’s an example of setting an alert when CPU usage exceeds 90%:
1. [cpu]
2. max=90
Glances will now display a warning when the CPU usage goes above 90%.
If you want Glances to run in the background continuously and provide metrics for external services, you can run it in daemon mode. Use the following command:
1. glances -d
This starts Glances as a background process. You can then access Glances via the web interface or API for remote monitoring.
Glances can also be accessed programmatically through its RESTful API, allowing you to integrate it with custom monitoring solutions. To enable the API, run:
1. glances --export api
The API allows you to fetch real-time system data in JSON format by accessing:
1. http://your-server-ip:61208/api/3
This can be useful for integrating Glances with other monitoring tools like Grafana or Nagios.
You can customize the behavior and display of Glances by modifying the glances.conf configuration file located in /etc/glances/. You can specify various display options, set thresholds for alerts, and enable or disable specific modules (such as Docker monitoring).
If you want to only display processes consuming more than 10% of CPU, you can add the following to the configuration file:
1. [processlist]
2. cpu_careful=10
After saving the changes and restarting Glances, only processes consuming more than 10% of CPU will be displayed.
Glances is a powerful, real-time system monitoring tool for managing your Ubuntu VPS. It provides a comprehensive overview of critical system metrics, helping you maintain optimal performance. Whether you use it from the command line, web interface, or API, Glances makes monitoring easy and efficient, allowing you to act on potential performance bottlenecks before they impact your server. By following this guide, you’ve installed Glances, learned the basics of its interface, and explored several advanced features for monitoring and managing your VPS effectively.
14-10-2024
This article offers a detailed guide on installing and configuring IPTables on an Ubuntu VPS. IPTables is a powerful firewall tool that helps secure your server by controlling inbound and outbound traffic. Learn how to set up rules for traffic filtering, configure basic security policies, and apply custom rules to protect your VPS.
IPtables
security
12 min
This article offers a comprehensive guide on installing and configuring ModSecurity, a powerful web application firewall (WAF), on an Ubuntu VPS. Learn how to secure your server by filtering and monitoring HTTP requests, set up ModSecurity with Nginx or Apache, and apply rules to protect against common web attacks.
Modsecurity
security
10 min
14-10-2024
This article provides a comprehensive guide on installing and configuring PHP-FPM (FastCGI Process Manager) on an Ubuntu VPS. Learn how to optimize PHP performance for your web applications by configuring PHP-FPM with Nginx or Apache, managing pools, and fine-tuning settings for efficient processing of PHP scripts.
PHP-FPM
speed
optimise
12 min