The most commonly used command-line tool for process monitoring on Linux is top, its colorful and feature-rich cousin stop .
To monitor the temperature on Linux, you can use lm sensor. Similarly, there are many utilities that can monitor other real-time metrics, such as disk I/O, network statistics, etc.
Glance It is a system monitoring tool that can link them closely and provide more functions. My favorite is that you can use run Glances on a remote Linux server and monitor system resources on the local system or monitor it through a web browser.
It looks like this The terminal in the screenshot below has been beautified with the Pywal tool, which automatically changes the color according to the wallpaper.
You can also integrate it into something like Grafana Monitor statistics in an intuitive dashboard.
It is written in Python, which means it can be used on most platforms with almost all features.
Explore data in the Grafana dashboard
Let’s take a quick look at the main functions (pun intended) provided by Glances.
- You can monitor more than 15 indicators on the system (including docker containers).
- Flexible usage mode: standalone, client-server, through SSH and Web mode.
- A variety of REST APIs and XML-RPC can be used for integration.
- Support exporting data to different services and databases at any time.
- Highly configurable and adapt to different needs.
- Very comprehensive documentation.
Install Glances on Ubuntu and other Linux distributions
Glances can be found in the official repositories of many Linux distributions. This means that you can easily install it using the distribution’s package manager.
sudo apt install glances
You can also use the snapshot package to install the latest Glances:
sudo snap install glances
Since Glances is based on Python, you can also install it in most Linux distributions using PIP. First install PIP, and then use it to install Glances:
sudo pip3 install glances
If there are no other problems, you can always use the automatic installation script provided by the Glances developer. Although we do not recommend that you run random scripts directly on the system on FOSS. This is entirely your decision.
curl -L https://bit.ly/glances | /bin/bash
You can check how to install Glances in other ways document, You can also install it as a Docker container.
Use Glances to monitor Linux system resources on the local system (standalone mode)
By running this command on the terminal, you can easily start Glances to monitor the local computer.
You can immediately observe that it integrates many different information in one screen. I like that it displays the public IP and private IP of the computer at the top.
Glances is also interactive, which means you can use commands to interact with it at runtime. You can press “S” Display the sensor on the screen; “K” Bring up the TCP connection list; ” 1″ Expand CPU statistics to show individual threads.
You can also use the arrow keys to move through the process list and sort the table by different indicators.
You can start Glances with various command line options. There are more interactive commands. You can find the complete list on their website Comprehensive file.
Press Ctrl + C to exit Glances.
Use Glances to monitor remote Linux systems (client-server mode)
To monitor remote computers, you can use Glances in client-server mode. You need to install Glances on both systems.
On remote Linux systems, you must use the -s option to start browsing in server mode.
On the client system, use this command to start Glances in client mode and connect to the server.
glances -c server_ip_address
You can also SSH to any computer, then start Glances, it works perfectly. More information about the client-server model Here.
Use Glances (Web mode) to monitor Linux system resources in a web browser
The overview can also be run in web mode. This means you can access Glances using a web browser. Unlike the previous client-server model, you do not need to install Glances on the client system.
To start Glances in web mode, use the -w option.
Keep in mind that even if the IP address of the server is actually used on the Linux server, it may display “Glances Web User Interface from http://0.0.0.0:61208”.
The main part is that it uses the 61208 port number, which you can use to access Glances through a web browser. Just type in the IP address of the server and then the port number, for example http://126.96.36.199:61208.
You can also use it on your local system using http://0.0.0.0:61208/, or https://localhost:61208/.
Web mode can also simulate the appearance of the terminal. The web version is built according to responsive design principles and looks good even on mobile phones.
You may want to password protect the Web mode so that only authorized personnel can use it. The default username is glances.
[email protected]:~# glances -w --password Define the Glances webserver password (glances username): Password (confirm): Do you want to save the password? [Yes/No]: n Glances Web User Interface started on http://0.0.0.0:61208/
You can find more information about configuring passwords at: Quick start guide.
Export Glances data to other services
One of the biggest advantages of using Glances is the out-of-the-box support to seamlessly export data to various databases, services, and seamless integration into various data pipelines.
You can export to CSV while monitoring with this command.
glances --export csv --export-csv-file /tmp/glances.csv
“/Tmp/glances.csv” is the location of the file. The data is filled neatly in time series.
You can export to powerful applications such as Prometheus Enable conditional triggers and notifications.
It can directly plug into messaging services such as RabbitMQ, MQTT, and streaming media platforms such as Kafka, and export time series data to databases such as InfluxDB, and use Grafana for visualization.
You can view the entire list of services and export options Here.
Integrate Glances with other services using REST API
This is my favorite feature in the entire stack. Glances not only combines various indicators, but also exposes them via API.
This simple and powerful feature makes it very easy to build custom applications, services and middleware applications for any specific use case.
When you start Glances in web mode, the REST API server will start automatically. To start it in API server only mode, you can use the following command.
glances -w --disable-webui
of REST API The documentation is comprehensive, and the response is easy to integrate with web applications. This makes it easy to build a unified dashboard to monitor multiple servers using the following tools Node red.
Glances also provides an XML-RPC server, you can view the document Here.
Concluding remarks list
Glances use psutil Python library to access different system statistics. I built a simple API server using the same library in 2017 to retrieve CPU usage. I was able to monitor all Raspberry Pis in the cluster using the dashboard built by Node-RED.
Glances can save me some time and provide more features, but unfortunately, I didn’t know it at that time.
At the time of writing, I did try to install Glances on Raspberry Pi, but unfortunately, all installation methods failed with some errors. After success, I will update this article, or write another article, and provide installation steps on the Raspberry Pi.
I hope Glances provides a way to kill processes like top or htop. Hope we can get it in the upcoming version.
I hope this gives you a lot of information about Glances. What system monitoring tools do you use? Let me know in the comments.