Glances is a powerful system monitoring tool that provides real-time information about various system resources. It is an open-source, cross-platform tool that is widely used by system administrators and developers. In this article, we will guide you through the process of installing and using Glances on Ubuntu 22.04.
Glances is a Python-based system monitoring tool that provides a comprehensive overview of system resources such as CPU, memory, disk I/O, network interface, and more. It offers both a command-line interface and a web-based interface, making it accessible for users with different preferences.
Before we proceed with the installation, make sure you have the following:
- A server running Ubuntu 22.04
- Root access to the server
2. Installing Glances
Glances is included in the default Ubuntu repository, making the installation process straightforward. Open the terminal and run the following command to install Glances:
sudo apt-get install glances -y
Once the installation is complete, you can verify the installed version of Glances by running:
You should see the output displaying the Glances version and the psutil library version it uses.
3. Launching Glances Command Interface
Glances provides a command-line interface that allows you to monitor system resources directly from the terminal. To launch the Glances command interface, simply run the following command:
Upon running the command, you will see a screen displaying various system-related information. Each piece of information is color-coded to indicate its status. Green represents normal operation, blue indicates caution, violet signifies a warning, and red indicates a critical state.
You can navigate through the information using keyboard shortcuts. Press ‘q’ to quit the Glances interface.
4. Customizing Glances Thresholds
Glances allows you to customize the thresholds for different system resources. By modifying the configuration file, you can set different thresholds for CPU, memory, swap, and disk utilization. To customize these thresholds, open the Glances configuration file using a text editor:
sudo nano /etc/glances/glances.conf
Inside the file, you will find sections for each resource type, such as CPU, memory, and swap. Adjust the thresholds as per your requirements by changing the values next to the ‘careful’, ‘warning’, and ‘critical’ variables.
Save the changes and exit the text editor. The new thresholds will take effect the next time you launch Glances.
5. Keyboard Shortcuts in Glances
Glances provides several keyboard shortcuts to help you navigate and filter the information displayed. Here are some commonly used shortcuts:
- ‘m’: Sort processes by memory usage
- ‘p’: Sort processes by name
- ‘c’: Sort processes by CPU usage
- ‘i’: Sort processes by I/O rates
- ‘n’: Show/hide network stats
- ‘x’: Delete warning and critical logs
- ‘d’: Show/hide disk I/O stats
- ‘a’: Automatically sort processes
- ‘f’: Show/hide file system stats
- ‘hddtemp’: Show/hide HDD temperature stats
- ‘l’: Show/hide logs
- ‘h’: Show/hide help screen
- ‘q’: Quit Glances
- ‘w’: Delete warning logs
You can exit the Glances interface by pressing ‘Ctrl+C’. To view all available options, you can run the following command:
6. Running Glances in Web Server Mode
Apart from the command-line interface, Glances also offers a web-based interface that allows you to monitor system resources through a web browser. To run Glances in web server mode, follow these steps:
First, create a systemd service file for Glances web server mode:
sudo nano /usr/lib/systemd/system/glancesweb.service
Add the following lines to the file:
[Unit] Description = Glances in Web Server Mode After = network.target [Service] ExecStart = /usr/bin/glances -w -t 5 [Install] WantedBy = multi-user.target
Save the file and reload the systemd daemon:
sudo systemctl daemon-reload
Next, start the Glances service and enable it to start at system reboot:
sudo systemctl start glancesweb sudo systemctl enable glancesweb
You can check the status of the Glances web service by running:
sudo systemctl status glancesweb
If everything is successful, you should see the service as active and running.
To access the Glances web interface, open your web browser and enter the following URL:
Replace ‘your-server-ip’ with the actual IP address of your server. You should now see the Glances web interface, where you can use the same keyboard shortcuts as in the command-line interface to filter and navigate through the information.
In this article, we have discussed how to install and use Glances, a powerful system monitoring tool, on Ubuntu 22.04. Glances provides valuable insights into various system resources and allows you to monitor them in real-time. Whether you prefer the command-line interface or the web-based interface, Glances offers a user-friendly and customizable experience.
By following the installation steps and exploring the features of Glances, you can efficiently monitor your system resource usage and ensure optimal performance. Remember to customize the thresholds according to your requirements and make use of the keyboard shortcuts to navigate through the information effectively.
If you are looking for reliable and scalable cloud hosting solutions, consider Shape.host. With their Cloud VPS services, you can enjoy the benefits of high-performance virtual servers and excellent customer support. Visit Shape.host today to learn more.