Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Linux system Monitoring tool-glances

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

# # 1. Introduction to glances

Glances is a development based on the python language that provides the ability to monitor and analyze 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 keep abreast of the use of system resources in real time, while dynamic monitoring does not consume a lot of system resources, such as CPU resources, which is usually less than 2%. Glances updates the data every two seconds by default. At the same time, glances can also capture the same data to a file to facilitate later analysis and graphics of the report. The file formats supported are .csv spreadsheet format and html format.

Glances can analyze the system's:

CPU usage memory utilization kernel statistics and run queue information disk Imax O speed, transfer and read / write ratio disk adapter network Imax O speed, transfer and read / write ratio page monitoring process monitoring-process information and system resources consumed the most 2. Glances installation source installation based on pip command installation based on epel public network yum source

As the source code installation needs to solve the problem of a large number of dependent packages, there is a great pressure on Xiaobai students to learn, so this article will focus on the installation method based on yum, so that everyone can install quickly and experience the power and efficiency of glances monitoring in time.

Third, install glances based on epel public network source

Since glances requires a python environment to run, we need to install the python environment first. Here I use a script to install python3.7.3, the latest version.

3.1 、 Python3.7.3 installation script #! / bin/bash# # Name: # Author: Bai Shuming#Created Time: 2019-10-1 11:20#Release: # Description:python 3.7.3 installation script # variable source_url= "https://www.python.org/ftp/python/3.7.3/Python-3.7.3.tgz"source_pkg="Python-3.7.3.tgz"source_doc="Python-3.7.3"cpu_ Count= `egrep "flags" / proc/cpuinfo | wc-l` # program check () {["$USER"! = "root"] & & echo "need be root so that" & & exit 1 [!-x / usr/bin/wget] & & echo "not found command: wget" & & exit 1} install_python () {check#1, Download python source packageif! (wget $source_url & > / dev/null); then echo "$source_pkg download fail" exit 1fi#2, Decompression source packageif [- f $source_pkg]; then tar xf $source_pkgelse echo "not found package: $source_pkg" exit 1fi#3, python install preif! (yum-y install gcc-* openssl-* libffi-devel curses-devel lm_sensors sqlite-devel & > / dev/null); then echo "yum install software package fail" exit 1fi#4, configure python install envif [- d $source_doc] Then # 5, python configure cd $source_doc sed-i.bak '212s python configure...please waiting if. / configure-- enable-optimizations-with-openssl=/usr/bin/openssl & > / dev/null Then # 6, python make echo "python make...please waiting" if make-j $cpu_count & > / dev/null; then # 7, python install echo "python install...please waiting" if make install & > / dev/null Then echo "$source_doc install success" else echo "python make install fail" exit 1 fielse echo "python make fail" exit 1 fielse echo "python configure fail" exit 1 fielse echo The "not found $source_doc" exit 1fipost_install} # Post-installation settingspost_install () {# update pip toolpip3 install-- upgrade pip} # function calls install_python & & rm-rf $source_doc3.2, Glances install [root@manager01 ~] # pip install glancesCollecting glances Downloading https://files.pythonhosted.org/packages/32/34/72f9202ad5b7ada314507a50b9ab1fb604d2f468b138679e0a4fedeb91fa/Glances-3.1.0.tar.gz (6.7MB) | ██ | 6.7MB 659kB/s Collecting psutil > = 5.3.0 (from glances) Downloading https://files.pythonhosted.org/packages/1c/ca/5b8c1fe032a458c2c4bcbe509d1401dca9dda35c7fc46b36bb81c2834740 / psutil-5.6.3.tar.gz (435kB) | ██ | 440kB 575kB/s Installing collected packages: psutil Glances Running setup.py install for psutil... Done Running setup.py install for glances... DoneSuccessfully installed glances-3.1.0 psutil-5.6.33.3, temperature monitoring tool installation [root@manager01 ~] # yum-y install lm_sensors3.4, epel public network source installation [root@manager01 ~] # yum install epel*-y [root@manager01 ~] # yum-y install glances IV, glances monitoring 4.1, enable glances monitoring [root@manager01 ~] # glances

Description of the glances work interface:

At the top of the figure above is the usage of CPU, Load (load), Mem (memory usage), and Swap (swap partition). In the middle and upper part of the figure above is the use of network interfaces and Processes (processes). It usually includes the following fields:

% CPU: CPU usage% MEM: percentage of physical memory and total memory occupied by the process VIRT: virtual memory size RES: physical memory value occupied by the process PID: process ID number USER: user name of the process owner NI: process priority S: process state, where S means dormant, R means running, and Z indicates dead state. TIME+: the total CPU time taken by the process after startup IO_R and IO_W: the read and write rate of the process Command: process name

On the left side of the above figure is the network, disk IO, and disk partition usage. In addition, glances can run the tool interactively, and users can use the following keyboard shortcuts:

H: display help Q: leave the program and exit c: sort system processes by CPU real-time load m: sort system processes by memory usage I: sort system processes by Ipico usage p: sort by process name d: display disk read and write status w: delete log files l: display log s: display sensor information f Display system information 1: take turns to show the usage of each CPU kernel (the secondary option is only used on multicore CPU systems) 4.2, Glances usage glances is a command-line tool that includes the following command options:-b: display network connection speed Byte/ seconds-B @ IP | host: bind server-side IP address or hostname-c @ IP | host: connect glances server-C file: set configuration file default is / etc/glances/glances.conf-d: close disk etc/glances/glances.conf O module-e: display sensor temperature -f file: set output file (format is HTML or CSV)-m: close mounted disk module-n: close network module-p PORT: set running port default to 61209-P password: set client / server password-s: set glances operation mode to server-t sec: set screen refresh interval Unit in seconds, default value is 2 seconds, value allowed range: 1 "32767-h: display help information-v: display version information 5, glances Cripple S mode

Glances also supports Cramp S mode monitoring, the monitored machine runs the server, and the monitoring side runs the client side to realize remote monitoring.

Note: glances must be installed in Cramp S mode to implement = =

5.1, server startup

The port used by the server is 61209 by default. If you use the server, please pay attention to turn on the firewall.

5.2. the client accesses [root@node2 ~] # glances-c 192.168.10.1006, other data preservation methods 6.1, and the exported data is CSV spreadsheet [root@manager01 ~] # glances-- export-csv / tmp/1.csv

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report