The Swiss Army Knife of Linux system real-time monitoring - Glances

Earlier, we mentioned that there are many Linux  system monitoring tools that can be used to monitor system performance . But we estimate that perhaps more users will prefer the tool (top command) that comes with most Linux distributions.

The top command is a real-time task manager under Linux, and is also a common system monitoring tool used to find system performance bottlenecks in GNU/Linux distributions and help us make correct operations. It has an extremely clean interface and comes with a handful of useful options that can help us quickly understand system performance.

However, sometimes it may be difficult to find an application or process that takes up a lot of system resources through her. Because the top command by itself doesn't help us highlight programs that eat too much CPU, memory, or other resources.

In order to achieve this goal, here we will introduce a super awesome system monitoring program - Glances. She can automatically highlight programs that utilize the highest system resources and provide as much information as possible to Linux/Unix servers.

What are Glances?

Glances is a curses-based cross-platform command-line system monitoring tool written in Python and using the psutil library to scrape information from the system. With Glances, we can monitor CPU, load average, memory, network traffic, disk I/O, other processors and file system space utilization.

Glances is a GPL licensed free software for monitoring GNU/Linux and FreeBSD operating systems.

Glances also provides many useful options. One of the main functions we can see in the configuration file is to set key values ​​and corresponding labels (careful [caution], warning [warning] and critical [serious]), and then she will automatically help us mark them with different colors Information that the system has reached a bottleneck.

Glances main features

  • CPU information (user-related applications, system kernel programs and idle programs)
  • Total memory information, including physical memory, swap space, free memory, etc.
  • Average CPU load for the previous 1 minute, 5 minutes and 15 minutes
  • Downlink and uplink speed of the network link
  • The total number of processors, and their active status
  • Hard disk I/O related (read and write) speed details
  • Disk usage of the currently mounted device
  • Process names with high CPU and memory usage, and locations of associated applications
  • Show current date and time at bottom
  • Processes consuming the highest system resources are highlighted in red

Here is a screenshot of Glances in use:

Glances View

Glances View

Install Glances on Linux/Unix Systems

Although this tool was released late, you can still install it from the EPEL repositories on Red Hat systems  . Install with the following command in the terminal:

For RHEL/CentOS/Fedora distributions

  1. #yum install -y glances

For Debian/Ubuntu/Linux Mint distributions

  1. $ sudo apt-add-repository ppa:arnaud-hartmann/glances-stable
  2. $ sudoapt-get update
  3. $ sudoapt-get install glances

How to use Glances

First, you need to enter the following command in the terminal

  1. # glances

Glances Preview – Ubuntu 13.10

Glances Preview – Ubuntu 13.10

Press 'q' ('ESC' and 'Ctrl-C' also work) to exit the Glances terminal. Here is another screenshot taken from CentOS 6.5:

Glances Preview – CentOS 6.5

Glances Preview – CentOS 6.5

The default refresh rate of Glances is 1 (seconds), but you can manually define its refresh rate by specifying parameters in the terminal

  1. # glances -t 2

Meaning of Colors in Glances

Glances will use the following colors to represent states:

  • Green: OK (everything is OK)
  • Blue: CAREFUL (requires attention)
  • Purple: WARNING
  • Red: CRITICAL (critical)

The threshold can be set in the configuration file. Generally, the threshold is set to (careful=50, warning=70, critical=90) by default.

We can customize it in the configuration file (by default /etc/glances/glances.conf) according to our needs.

Options for Glances

In addition to many command-line options, Glances also provides more shortcuts to toggle output information options at runtime. Here are some examples:

  • a – Automatically sort processes
  • c – Sort processes by CPU percentage
  • m – sort processes by memory percentage
  • p – Sort processes alphabetically by process name
  • i – Sort processes by read and write frequency (I/O)
  • d – show/hide disk I/O statistics
  • f - show/hide file system statistics
  • n – show/hide network interface statistics
  • s – show/hide sensor statistics
  • y – show/hide hard disk temperature statistics
  • l – show/hide log (log)
  • b – Toggle network I/O units (Bytes/bits)
  • w - delete warning log
  • x - remove warning and critical logs
  • 1 – Toggle global CPU usage and per-CPU usage
  • h - show/hide this help screen
  • t – browse network I/O in combination
  • u – Browse network I/O in cumulative form
  • q - quit ('ESC' and 'Ctrl&C' also work)

Using Glances Remotely

You can even monitor remote systems with Glances. To use 'glances' on a remote system, run the 'glances -s' (-s start server/client mode) command on the server.

  1. # glances -s
  2.  
  3. Define the password for the Glances server
  4. Password:
  5. Password(confirm):
  6. Glances server is running on 0.0.0.0:61209

Note: After you execute the 'glances' command, she will ask you to set a password for the Glances server.

When you're done, you'll see the message "Glances server is running on 0.0.0.0:61209" (Glances server is running on port 61209 on 0.0.0.0).

When the Glances server starts, execute the following command locally to specify the server IP address or hostname to link to.

Note: Here '172.16.27.56' is the IP address of my Glances server.

  1. # glances -c -P 172.16.27.56

Here are some things you must know when using the server/client pattern:

* In server mode, you can use `-B address` to set the binding address, and you can also use `-p port` to bind the listening TCP port
* In client mode, you can specify the server port with the same `-p port`
* The default bind address is 0.0.0.0, but doing so will listen on the specified port on all network interfaces
* In server/client mode, the limit threshold will be determined by the server settings
* You can also use `-P password` on the command line to set a password for the server side

Summarize

Glances is a tool that provides too much information on system resources for most users. But if you are a system administrator who wants to quickly get the overall status of the system just from the command line, then this tool is definitely a must-have tool for you.

Translator's Note

  1. Please don't confuse glances (the tool in this article) and glance (an OpenStack tool) packages
  2. The glances in the Ubuntu official Extra source cannot be used normally due to the problem of the python library moving, but it can be temporarily fixed by establishing a soft link: sudo ln -s /usr/lib/python2.7/dist-packages/glances /usr/share /pyshared/glances

via: http://www.tecmint.com/glances-an-advanced-real-time-system-monitoring-tool-for-linux/

Translator: VizV  Proofreading: wxy

 This article was originally translated by  LCTT , and was launched by Linux China  with honor

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325160953&siteId=291194637