Frequent monitoring of the systems we administer allows us to be one step ahead of the problems that may arise in the short, medium or long term, helping the general administration in a completely integral way..
There are hundreds of tools that allow us to see the status of software and hardware with its different parameters but this time we will talk about a utility called Glances which goes much further allowing us to manage the equipment not only locally but also through any web browser , mobile device or other PC making it an integral solution since in some occasions we will not be able to face the equipment to be analyzed and it becomes the ideal solution to access remotely and see the behavior of the system.
What is Glances?
Glances is a tool for comprehensive monitoring of the operating system that can be executed in a multiplatform environment and has been written in Python for optimal development.
The objective with which Glances was created is to offer the administrator or user as much information as possible in a minimum space using the curses, local, or web-based interface. It is important to mention that this data can be dynamically adapted depending on the size of the user interface thus avoiding omitting details..
One of the outstanding features of Glances is that it has the ability to operate in client / server mode. Remote server monitoring can be executed through the terminal, the web interface or the API (XML-RPC and RESTful).
Statistics can also be exported to external files or databases for further administrative management..
As we have mentioned, Glances is written in Python and makes use of libraries to obtain information on the selected system. It is based on an open architecture where developers can add new add-ons or export modules thus increasing the usability and utility analysis.
What does Glances analyze
The components analyzed by Glances are:
- Quicklook (CPU, MEM, LOAD)
Characteristics of Glances
When using Glances we will have the following advantages:
- Glances can be run on multiple platforms such as GNU / Linux, FreeBSD, OS X and Windows.
- Glances has an XML-RPC server and a RESTful JSON API which enables this utility to be used in additional software allowing remote administration.
- It includes a web user interface which allows us to access information from any device.
- By using Glances, it will be possible to export all system statistics to formats such as CSV, InfluxDB, Cassandra, OpenTSDB, StatsD, ElasticSearch or RabbitMQ. Glances also offers a Grafana board dedicated to data.
Requirements to use Glances
The basic requirements to use Glances are:
python 2.7 or> = 3.3 psutil> = 2.0.0
Some additional dependencies are:
Bernhard (for the Riemann export module) bottle (for web server mode) cassandra-driver (for the Cassandra export module) couchdb (for CouchDB export module) docker (for Docker monitoring support), only on Linux elasticsearch (for the Elastic Search export module) hddtemp (for HDD temperature monitoring support), only on Linux influexdb (for InfluxDB export module) kafka-python (for the Kafka export module) matplotlib (for graphic / graphic support) netifaces (for the IP plugin) nvidia-ml-py3 (for the GPU plugin) pika (for RabbitMQ / ActiveMQ export module) potsdb (for the OpenTSDB export module) prometheus_client (for Prometheus export module) py-cpuinfo (for the Quicklook CPU information module) pymdstat (for RAID support), only on Linux pysnmp (for SNMP support) pystache (for the script action function) pyzmq (for the ZeroMQ export module) requests (for ports, cloud add-ons and restful export module) scandir (for the Folders plugin), Only for Python <3.5 statsd (for the StatsD export module) wifi (for the wifi plugin), only on Linux zeroconf (for autodetection mode)
1. Install Glances on Linux
Step 1
To run the Glances utility in the web server mode, it must be installed together with the Python Bootle module, which is a fast, simple and lightweight WSGI micro-framework, we can execute one of the following options:
sudo apt install glances python-bottle (Debian / Ubuntu) sudo yum install glances python-bottle (RHEL / CentOS) sudo dnf install glancespython-bottle (Fedora 22+)
Step 2
Alternatively we have the following installation options:
- If we use PIP we can execute the following:
sudo pip install bottle
- If we want to install dependencies using this method we can execute:
pip install glances [action, browser, cloud, cpuinfo, chart, docker, export, folders, gpu, ip, raid, snmp, web, wifi]
Step 3
To update Glances we will use:
pip install --upgrade glances pip install --upgrade glances
Step 4
To install both dependencies and the latest version ready for production of Glances we must execute one of the following commands:
curl -L https://bit.ly/glances | / bin / bash wget -O- https://bit.ly/glances | / bin / bash
Note
This option only applies in GNU / Linux environments.
Step 5
If we are lovers of using Docker, Glances has an available container which includes the HEAD development version, if we want to use this method we will execute:
- Get the container of Glances:
docker pull nicolargo / glances
- Run the container in console mode:
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock:ro --pid host --network host -it docker.io/nicolargo/glances
Step 6
If we have other operating systems we can execute the following:
FreeBSD
pkg install py27-glances (Install the Glances binaries) cd / usr / ports / sysutils / py-glances / (Install Glances from Ports) make install clean
macOS
brew install glances (Installation using HomeBrew) sudo port install glances (Installation using MacPors)
Windows
We must have Python installed in the system and execute the following:
pip install glances
Android
We will need a rooted device and the Termux application which we obtain for free at the following link:
Termux
Then we will execute the following from it:
apt update apt upgrade apt install clang python python-dev pip install bottle pip install glances
Finally, if we want to install Glances from a resource we can execute:
wget https://github.com/nicolargo/glances/archive/vX.Y.tar.gz -O - | tar xz cd glances- * python setup.py install
2. Enable the firewall for Glances on Linux
Because Glances can be accessed through the web it is necessary that we grant permission to the port for web access.
Step 1
If we use Firewalld we must execute the following lines:
sudo firewall-cmd --permanent --add-port = 61208 / tcp sudo firewall-cmd –reload
Step 2
In case of using UFW we can execute the following:
sudo ufw status sudo ufw enable sudo ufw allow 61208 / tcp sudo ufw reload
3. Use Glances in Linux
Step 1
Glances can be executed locally or remotely, to execute it locally, simply use the following line:
Glances
Step 2
Pressing Enter we will see a complete summary of the system parameters:
Step 3
If we want to run the client / server mode we must use the following line:
glances -s
Step 4
To enable the web access mode, ideal in this tutorial, we must run the following command in the background:
glances -w
Step 5
This action must be left in execution to enable remote access, and as we see, the syntax to access is:
http: // Server_IP: 61208 /
Step 6
If we access from a browser, in this case Google Chrome, we will see all the distribution information where Glances has been installed:
Step 7
We can still access from our Smartphone:
Step 8
As we can see, each category that encompasses Glances will be displayed there.
Glances uses a color scale to determine the priority or status of services which are:
Step 9
The options available with Glances are:
m
Sort the processes by MEM%.
p
Sort the processes by name.
C
Sort the processes by CPU%.
d
Show or hide disk I / O statistics.
to
Sort the processes automatically.
F
Show or hide the statshddtemp file system.
j
Sort the processes by I / O rate.
s
Show or hide sensor statistics.
Y
Show or hide hddtemp statistics.
n
Show or hide network statistics.
x
Eliminate warnings and critical records.
h
Show or hide the help screen.
w
Delete warning records.
We have seen how this practical utility will be of great help for administration tasks in multiple operating systems.