I. Introduction to Glances

Glances is a Python language that provides monitoring and analysis of performance data for Linux or UNIX performance. Glances displays important system information on the user’s terminal and updates it dynamically so that the administrator can master the usage of system resources in real time. However, dynamic monitoring does not consume a large amount of system resources, such as CPU resources, which usually consumes less than 2%. By default, Glances updates data every two seconds. At the same time, Glances can also capture the same data into a file, which is convenient for later analysis and graph drawing of the report. CSV spreadsheet format and HTML format are supported.

Making address: https://github.com/nicolargo/glances

Glances has the following functions:

  • CPU utilization

  • Memory usage

  • Kernel statistics and run queue information

  • Disk I/O speed, transfer, and read/write ratios

  • Disk adapter

  • Network I/O speed, transmission, and read/write ratios

  • Page to monitor

  • Process monitoring – The process that consumes the most resources

  • Computer information and system resources


rendering

Ii. Glances installation method

  • The source code to install

  • PIP command installation

  • Yum install


Source code installation is more complex, may encounter dependency problems difficult to solve; Both PIP and YUM installations are optional. Document manual: https://glances.readthedocs.io/en/latest/index.html


3. Install Glances

Glances is generally integrated into the official software sources of most Linux distributions and can be installed directly using the system’s package managers (such as apt-get, yum) :

sudo apt-get install glancesCopy the code


yum install epel* -yyum -y install glancesCopy the code


It can also be installed using Python’s package manager (PIP command) :

pip install glancesCopy the code


Install the temperature monitoring tool


Lm_sensors software helps us to monitor motherboard, CPU operating voltage, fan speed, temperature, etc. These data we usually in the motherboard BIOS can also see. When the machine is running, we can monitor the temperature change of CPU at any time by lM_sensors, which can prevent the protection from burning out due to CPU overheating. Data monitored by lM_sensors software can be called and displayed by GLances

.


yum -y install lm_sensorsCopy the code


In fact, these open source software installation is very simple, almost 100% foolproof, no big problem.


4. Use of Glances

Glances has 4 color markers to indicate different levels of urgency:

  • Green: OK

  • Blue: CAREFUL

  • Purple: WARNING

  • Red: CRITICAL

Green indicates good performance; (The CPU usage, disk space usage, and memory usage are lower than 50%, and the system load is lower than 0.7.)


Blue indicates that there are some minor problems with system performance, and users should start paying attention to system performance. In this case, the CPU usage, disk usage, and memory usage are between 50% and 70%, and the system load is between 0.7-1.


Magenta means performance alarm, should take measures such as backup data; (In this case, the CPU usage, disk usage, and memory usage are between 70% and 90%, and the system load is between 1 and 5.)


Red indicates that the system may break down due to a serious performance problem. (The CPU usage, disk usage, and memory usage are greater than 90%, and the system load is greater than 5.)

Glances usage method

Glances is a command line tool that includes the following command options:

  • -b: displays the network connection speed Byte/ second

  • – B | @ IP host: binding the server IP address or host name

  • | – c @ IP host: connection glances server side

  • – C file: set up the default configuration file is/etc/glances glances. Conf

  • -d: shuts down the disk I/O module

  • -e: displays the sensor temperature

  • -f file: Sets the output file (in HTML or CSV format).

  • -m: shuts down the mounted disk module

  • -n: Disables the network module

  • -p PORT: Sets the running PORT. The default PORT is 61209

  • -p password: sets the client/server password

  • -s: Sets the Glances running mode to server

  • -t SEC: sets the screen refresh interval, in seconds. The value ranges from 1 to 32767

  • -h: Displays the help information

  • -v: displays the version information

Description of GLances working interface: In the upper part of the figure, CPU, Load, Mem and Swap are used. In the middle and top of the diagram are network interfaces and Processes. Usually includes the following fields:

  • VIRT: indicates the virtual memory size

  • RES: physical memory occupied by the process

  • %CPU: indicates the CPU usage of the process

  • %MEM: The percentage of physical memory and total memory occupied by the process

  • PID: indicates the ID of a process

  • USER: indicates the USER name of the process owner

  • TIME+: indicates the total CPU TIME occupied by the process after it starts

  • IO_R and IO_W: read/write I/O rates of processes

  • NAME: indicates the process NAME

  • NI: Indicates the process priority

  • S: indicates the process status, where S indicates hibernation, R indicates running, and Z indicates dead.


In addition, Glances can use an interactive way to run the tool, users can use the following shortcuts:

  • H: Displays help information

  • Q: Exit The program exits

  • C: Sorts system processes according to the real-time CPU load

  • M: Sort system processes by memory usage

  • I: Sorts system processes by I/O usage

  • P: Sort by process name

  • D: Displays the disk read and write status

  • W: Deletes log files

  • L: Displays logs

  • S: Displays sensor information

  • F: Displays system information

  • 1: displays the usage of each CPU core in turn


5. Glances C/S model

Glances also supports C/S mode monitoring. The monitored machine runs the server, and the monitoring terminal runs the client to realize remote monitoring. Glances service can be installed on both ends.

Server startup

The default port used by the server is 61209. Run the following command to start the port:

glances -s-b 192.168.1.253 Glances server is running on 192.168.1.253:61209Copy the code

Client access

192.168.1.253 glances - cCopy the code


You can also use username and password for access. The default username is glances, and if you want to change it, you can use –username instead. Here’s the official transcript:

In client/server mode, limits are set by the server side.

You can set a password to access to the server using the --password. By default, the username is glances but you can change it with --username.

glances -s --usernameDefine the Glances server username: testDefine the Glances server password (test username):Password (confirm):Do you want to save the password? [Yes/No]: YesGlances XML-RPC server is running on 0.0.0.0:61209Copy the code


The client connection mode is as follows:Copy the code
Copy the code
Glances - c 192.168.1.253 - the usernametestCopy the code


Copy the code

Glances WebServer mode

In Glances WebServer mode, the client can access the running status of the remote server only through the browser. Just install Python’s Bottle module:

pip install bottleCopy the code

After the installation, run the glances -w command to enable the WebServer mode. On the client, use a browser to access http://SERVER_IP:61208/.

Its WEB mode can also be viewed on a mobile phone, as shown below.

Source official documents

Other advanced applications

To export data in CSV format, run the following command:

glances --export-csv /tmp/1.csvCopy the code


Glances can also work with Open-source software such as InfluxDB and Grafana to build a monitoring platform that, like other monitoring software, can generate real-time and graphical data display.

Interested friends can play in the test environment, a good, powerful tool.

What performance tools do you have to use?

Welcome to leave a message to share with us!

Key words: 1024 You can get a copy of the latest finishing 2TB technology dry goods: Including system operation and maintenance, database, Redis, MogoDB, e-book, Java foundation course, Java practice project, architect comprehensive tutorial, architect practice project, big data, Docker container, ELK Stack, machine learning, BAT interview intensive video, etc.