Linux Format

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 administra­tors have long favoured command-line utilities for myriad activities ranging from setup, configurat­ion, and maintenanc­e of the machines under their charge. A necessary part of the job involves keeping tabs on the different machines. On a local installati­on, tools like top, htop, etc. have long reigned supreme. But if you want all the features of these, and many more, with the added convenienc­e 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 temperatur­es. 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 instructio­ns on how to install Glances.

Monitoring with Glances

Unlike other system-monitoring tools, Glances is capable of presenting a vast array of informatio­n. 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 informatio­n 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 overwhelmi­ng, but that’s understand­able considerin­g the vast amount of informatio­n that’s on display. Each distinct block of informatio­n 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 informatio­n. 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 automatica­lly

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 informatio­n such as disk, filesystem, network, sensors, etc. Each of these modules can be toggled on/off using the d, f, n, and s keys respective­ly. 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 configurat­ion 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 distributi­on and the chosen installati­on 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 automatica­lly take cues from this config file. Alternativ­ely, 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 command. When you specify the IP address of the remote machine, Glances will display the statistics for that machine.

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 counterpar­ts, such as top. But the sheer amount of available informatio­n 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 informatio­n you’re interested in makes Glances every bit as suitable for desktop users as administra­tors.

 ??  ?? Many shortcuts affect the info displayed. Pressing f will enable/disable the filesystem module, F shows the used/ free space in the filesystem module.
Many shortcuts affect the info displayed. Pressing f will enable/disable the filesystem module, F shows the used/ free space in the filesystem module.
 ??  ?? Colours are used to identify elements as okay (green), careful (blue), warning (magenta) and critical (red). Here, magenta and red are used to identify the low disk space.
Colours are used to identify elements as okay (green), careful (blue), warning (magenta) and critical (red). Here, magenta and red are used to identify the low disk space.

Newspapers in English

Newspapers from Australia