一 Glances简介
1.1 glances介绍
- Glances是一个跨平台的监控工具,旨在通过curses 或基于Web 的界面呈现大量监控信息。该信息根据用户界面的大小动态调整。
- 它也可以在客户端/服务器模式下工作。远程监控可以通过终端、Web 界面或 API(XML-RPC 和 RESTful)完成。统计数据也可以导出到文件或外部时间/值数据库。
- Glances 是用 Python 编写的,并使用库从您的系统中获取信息。它基于开放式架构,开发人员可以在其中添加新插件或导出模块。
- 更强大的 htop / top 代替者。
1.2 参考文档
- https://glances.readthedocs.io/en/latest/install.html。
- https://nicolargo.github.io/glances/。
- https://github.com/nicolargo/glances。
二 glances 安装
2.1 glances 安装方式
2.2.1 安装要求
python>=2.7
or python>=3.4
2.2.2 自动安装脚本
2.2.2.1 方式一
$ curl -L https://bit.ly/glances | /bin/bash
2.2.2.2 方式二
$ wget -O- https://bit.ly/glances | /bin/bash
2.2.3 基于pip
2.2.3.1 pip命令安装glances
$ pip install glances
$ pip install glances[all]
$ pip install glances[action,browser,cloud,cpuinfo,docker,export,folders,gpu,graph,ip,raid,snmp,web,wifi]
2.2.3.2 pip命令升级glances
$ pip install --upgrade glances
$ pip install --upgrade psutil
$ pip install --upgrade glances[all]
2.2.4 基于源安装
2.2.4.1 ubuntu系统
root@wgs:~
2.2.4.2 centos7系统
[root@wgs ~]
三 glances 使用帮助
点击查看代码
root@wgs:~
usage: glances [-h] [-V] [-d] [-C CONF_FILE] [--modules-list] [--disable-plugin DISABLE_PLUGIN] [--enable-plugin ENABLE_PLUGIN] [--disable-process] [--disable-webui] [--light] [-0] [-1] [-2] [-3] [-4] [-5] [-6] [--disable-history] [--disable-bold] [--disable-bg]
[--enable-irq] [--enable-process-extended] [--export EXPORT] [--export-csv-file EXPORT_CSV_FILE] [--export-csv-overwrite] [--export-json-file EXPORT_JSON_FILE] [--export-graph-path EXPORT_GRAPH_PATH] [-c CLIENT] [-s] [--browser] [--disable-autodiscover]
[-p PORT] [-B BIND_ADDRESS] [--username] [--password] [-u USERNAME_USED] [--snmp-community SNMP_COMMUNITY] [--snmp-port SNMP_PORT] [--snmp-version SNMP_VERSION] [--snmp-user SNMP_USER] [--snmp-auth SNMP_AUTH] [--snmp-force] [-t TIME] [-w]
[--cached-time CACHED_TIME] [--open-web-browser] [-q] [-f PROCESS_FILTER] [--process-short-name] [--stdout STDOUT] [--stdout-csv STDOUT_CSV] [--hide-kernel-threads] [-b] [--diskio-show-ramfs] [--diskio-iops] [--fahrenheit] [--fs-free-space]
[--sparkline] [--theme-white] [--disable-check-update]
optional arguments:
-h, --help show this help message and exit
-V, --version show program's version number and exit
-d, --debug enable debug mode
-C CONF_FILE, --config CONF_FILE
path to the configuration file
--modules-list, --module-list
display modules (plugins & exports) list and exit
--disable-plugin DISABLE_PLUGIN, --disable-plugins DISABLE_PLUGIN
disable plugin (comma separed list)
--enable-plugin ENABLE_PLUGIN, --enable-plugins ENABLE_PLUGIN
enable plugin (comma separed list)
--disable-process disable process module
--disable-webui disable the Web Interface
--light, --enable-light
light mode for Curses UI (disable all but top menu)
-0, --disable-irix task's cpu usage will be divided by the total number of CPUs
-1, --percpu
-2, --disable-left-sidebar
-3, --disable-quicklook
-4, --full-quicklook
-5, --disable-top
-6, --meangpu
--disable-history
--disable-bold
--disable-bg
--enable-irq
-enable-process-extended
--export EXPORT
--export-csv-file EXPORT_CSV_FILE
--export-csv-overwrite
--export-json-file EXPORT_JSON_FILE
--export-graph-path EXPORT_GRAPH_PATH
-c CLIENT, --client CLIENT
-s, --server
--browser
--disable-autodiscover
-p PORT, --port PORT
-B BIND_ADDRESS, --bind BIND_ADDRESS
--username
--password
-u USERNAME_USED
--snmp-community SNMP_COMMUNITY
--snmp-port SNMP_PORT
--snmp-version SNMP_VERSION
--snmp-user SNMP_USER
--snmp-auth SNMP_AUTH
--snmp-force
-t TIME, --time TIME
-w, --webserver
--cached-time CACHED_TIME
--open-web-browser
-q, --quiet
-f PROCESS_FILTER, --process-filter PROCESS_FILTER
--process-short-name
--stdout STDOUT
--stdout-csv STDOUT_CSV
--hide-kernel-threads
-b, --byte
--diskio-show-ramfs
--diskio-iops
--fahrenheit
--fs-free-space
--sparkline
--theme-white
--disable-check-update
Examples of use:
Monitor local machine (standalone mode):
$ glances
Display all Glances modules (plugins and exporters) and exit:
$ glances --module-list
Monitor local machine with the Web interface and start RESTful server:
$ glances -w
Glances web server started on http://0.0.0.0:61208/
Only start RESTful API (without the WebUI):
$ glances -w --disable-webui
Glances API available on http://0.0.0.0:61208/api/
Monitor local machine and export stats to a CSV file (standalone mode):
$ glances --export csv --export-csv-file /tmp/glances.csv
Monitor local machine and export stats to a InfluxDB server with 5s refresh time (standalone mode):
$ glances -t 5 --export influxdb
Start a Glances XML/RCP server (server mode):
$ glances -s
Connect Glances to a Glances XML/RCP server (client mode):
$ glances -c <ip_server>
Connect Glances to a Glances server and export stats to a StatsD server (client mode):
$ glances -c <ip_server> --export statsd
Start the client browser (browser mode):
$ glances --browser
Display stats to stdout (one stat per line):
$ glances --stdout now,cpu.user,mem.used,load
Display CSV stats to stdout (all stats in one line):
$ glances --stdout-csv now,cpu.user,mem.used,load
Disable some plugins (comma separated list):
$ glances --disable-plugin network,ports
Enable some plugins (comma separated list):
$ glances --enable-plugin sensors
四 glances 运行模式
4.1 Standalone Mode
- 更强大的 htop / top 代替者
- 如果要监视本地计算机,请打开控制台/终端并运行glances,按“q”或“ESC”退出
root@wgs:~

- 使用交互式的方式运行该工具,用户可以使用如下快捷键:
- h : 显示帮助信息
- q : 离开程序退出
- c :按照 CPU 实时负载对系统进程进行排序
- m :按照内存使用状况对系统进程排序
- i:按照 I/O 使用状况对系统进程排序
- p: 按照进程名称排序
- d : 显示磁盘读写状况
- w : 删除日志文件
- l :显示日志
- s: 显示传感器信息
- f : 显示系统信息
- 1 :轮流显示每个 CPU 内核的使用情况
4.2 glances C/S模式
4.2.1 server端
- 在服务器模式下,您可以使用-B ADDRESS设置绑定地址和-p PORT 指定TCP端口。
- 默认绑定地址是
0.0.0.0
(Glances 会监听所有可用的网络接口),TCP 端口是61209
.
root@server:~
4.2.2 client端
root@client:~
4.3 web server mode
4.3.1 server端
root@server:~
4.3.2 client端
- 浏览器访问 http://@server:61208
- @server 替换成server端的IP
4.3.3 更改页面刷新率
- 10s刷新一次
- http://@server:61208/10
- @server 替换成server端的IP
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 微软正式发布.NET 10 Preview 1:开启下一代开发框架新篇章
· 没有源码,如何修改代码逻辑?
· PowerShell开发游戏 · 打蜜蜂
· 在鹅厂做java开发是什么体验
· WPF到Web的无缝过渡:英雄联盟客户端的OpenSilver迁移实战