Introduction
Glances is a cross-platform command line tool written in Python to monitor Linux systems. You can use Glances to monitor CPU, Load Average, Memory, Network Interfaces, Disk I/O, Processeser and File System spaces utilization of your Linux system.
Glances uses the psutil library to grab informations from the system. It can be also used in client/server mode for remote monitoring.
In this tutorial, I will explain how to install and use Glances on CentOS 7.
Features
Glances will display:
- Memory information including RAM, swap, and free memory.
- The average CPU load of your system.
- CPU information like user related application, system programs and idle programs.
- Total number of active and sleeping processes.
- Download and upload rates of your network connections.
- Disk I/O read and write details.
- Display currently mounted disk devices.
- Shows the current date and time at bottom.
Requirements
- A server running CentOS v.7
Installing Glances
Glances is not available in the default CentOS 7 repository. You will need to enable the EPEL repository in your “yum” configurations by running the following command:
sudo wget http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm
sudo rpm -ivh epel-release-7-5.noarch.rpm</code></pre>
Once EPEL repository installed, you can install Glances by running the following command:
sudo yum install epel-release
Using Glances
Once installation has finished, you can launch Glances by running the following command:
glances
The output will look something like this:
Press ESC
or Ctrl+C
to exit the Glances terminal.
By default, interval time is set to 1 second. But you can define the custom interval time while running glances from the terminal.
To set the interval time to 2 seconds, run the following command:
glances -t 2
Glances Color Codes
Glances color codes are as follows:
- Green: Okay
- Blue: Caution
- Violet: Warning
- Red: Critical
By default Glances thresholds are set at:
- Caution: 50
- Warning: 70
- Critical: 90
You can customize the thresholds to suit your needs by editing the default /etc/glances/glances.conf
configuration file.
Glances Options
Glances provides a lot of hot keys to find output information while Glances is running. Some of the most useful of these are:
- m: Sort processes by MEM%
- p: Sort processes by name
- c: Sort processes by CPU%
- d: Show/hide disk I/O stats
- a: Sort Processes automatically
- f: Show/hide file system statshddtemp
- i: Sort processes by I/O rate
- s: Show/hide sensors stats
- y: Show/hide hddtemp stats
- l: Show/hide logs
- n: Show/hide network stats
- x: Delete warning and critical logs
- h: Show/hide help screen
- q: Quit
- w: Delete warning logs
Using Glances on Remote Systems
You can use Glances to monitor remote systems. To do this, use the command:
glances -s
The output will look something like this:
You can see glances running on port 61209.
Now, go to the remote machine and execute the following command to connect to a Glances server by specifying IP address as shown below. In this example, 192.168.0.101 is your Glances server IP address.
glances -c -P 192.168.0.101