GLANCES: Monitoring made easy
Knowing about advanced system-monitoring tools like Glances, and when to use them, is precisely why Shashank Sharma is a celebrated Bash-ninja.
Knowing about advanced system-monitoring tools like Glances, and when to use them, is precisely why Shashank Sharma is a celebrated Bash-ninja.
System administrators have long favoured command-line utilities for myriad activities ranging from setup, configuration, and maintenance of the machines under their charge. A necessary part of the job involves keeping tabs on the different machines. On a local installation, tools like top, htop, etc. have long reigned supreme. But if you want all the features of these, and many more, with the added convenience of keeping tabs on remote machines, Glances is just the tool for you.
Whereas utilities like top will help you gauge the CPU and memory usage, Glances goes quite a bit further. It can be used to monitor filesystem I/O, network I/O, and even sensor readouts to display CPU and other hardware temperatures. It can also show you disk usage by hardware device and logical volume, and even provide Docker statistics. Please refer to the Getting started boxout (see opposite) on instructions on how to install Glances.
Monitoring with Glances
Unlike other system-monitoring tools, Glances is capable of presenting a vast array of information. The very first line at the top is called the Header and displays the hostname, OS name and version, the running Linux kernel, IP address and system uptime. The next few lines present much the same information as you’d find on other monitors, such as top, including stats for CPU and memory usage, and load. The default interface might seem a little overwhelming, but that’s understandable considering the vast amount of information that’s on display. Each distinct block of information is referred to as a module, and there’s a module each for CPU, memory, network stats, etc. Thankfully, you can tweak the display with different keyboard shortcuts.
From within the interface, press 1, and look at the top left of the interface. If you’re running a multi-core machine, you’ll notice that instead of combined
statistics for the CPU usage, you now get statistics for each CPU. supports many such keyboard shortcuts to show/hide a variety of information. It’s also possible to sort the displayed processes by memory or CPU usage, etc.
Toggle modules on/off
d: ... show/hide disk I/O stats
f: .... show/hide filesystem stats
s: .... show/hide sensors’ stats
l: .... show/hide alert logs
n: ... show/hide network stats
h: ... show/hide help screen
/: ... enable/disable short process name
Sort processes
a: ... sort automatically
i: .... sort by I/O rate
m: .. sort by MEM%
p: ... sort by name
c: ... sort by CPU%
t: .... sort by time
The sidebar on the left is home to other pertinent information such as disk, filesystem, network, sensors, etc. Each of these modules can be toggled on/off using the d, f, n, and s keys respectively. You can also choose to entirely remove the sidebar from the Glances interface by pressing 2.
You’ll find a complete list of all configured shortcuts by pressing h from within the Glances interface. To return back to Glances, press the h key again.
Although Glances doesn’t need a configuration file to run, you can use one to define your custom settings, such as which modules are to run by default, and the values for different parameters so that the tool can warn you when something is amiss. Depending on your distribution and the chosen installation mode, a sample config file can be found in /usr/local/share/doc/ glances/glances.conf. You can place this config file in the ~/.config/glances/ directory, and Glances will automatically take cues from this config file. Alternatively, you can download the config file from the project’s Github page (https://github.com/ nicolargo/glances).
Remote machines
Apart from monitoring the local machine, you can also use Glances to keep tabs on remote machines. This requires Glances to be installed and running on each of the remote machines. On a remote machine, run
Glances with the glances -s command: glances -s
Glances XML-RPC server is running on 0.0.0.0:61209 Announce the Glances server on the LAN (using 192.168.0.104 IP address)
You can now access this machine from any other machine on the network by running the glances -c
From the previous code block, you’ll also notice that
Glances is running on port 61209. This is only needed if you’re interested in accessing Glances from a web browser. When you run Glances with the glances -w command, you’ll be informed that the Glances Web User Interface is running. You can then access the web interface by pointing your browser to the given IP address and port number. You’ll find the keyboard shortcuts that work on the Glances interface also work in the web interface.
Glances can take some getting used to, and it’s bulkier than some of its counterparts, such as top. But the sheer amount of available information negates the heavier resource usage. Its biggest drawback is that it’s designed strictly as a monitoring tool, which means it can’t be used to kill processes, like you can with top, for instance. But showing alerts, such as for extensive memory usage, coupled with the ability to shape the interface to only show the information you’re interested in makes Glances every bit as suitable for desktop users as administrators.