• Glances是一个跨平台的监控工具,旨在通过curses 或基于Web 的界面呈现大量监控信息。该信息根据用户界面的大小动态调整。
  • 它也可以在客户端/服务器模式下工作。远程监控可以通过终端、Web 界面或 API(XML-RPC 和 RESTful)完成。统计数据也可以导出到文件或外部时间/值数据库。
  • Glances 是用 Python 编写的,并使用库从您的系统中获取信息。它基于开放式架构,开发人员可以在其中添加新插件或导出模块。
  • 更强大的 htop / top 代替者。
  • https://glances.readthedocs.io/en/latest/install.html。
  • https://nicolargo.github.io/glances/。
  • https://github.com/nicolargo/glances。
  • python>=2.7 or python>=3.4
  1. $ curl -L https://bit.ly/glances | /bin/bash
  1. $ wget -O- https://bit.ly/glances | /bin/bash
  1. # 按需执行, 三选一即可
  2. $ pip install glances
  3. $ pip install glances[all]
  4. $ pip install glances[action,browser,cloud,cpuinfo,docker,export,folders,gpu,graph,ip,raid,snmp,web,wifi]
  1. # 按需执行,三选一
  2. $ pip install --upgrade glances
  3. $ pip install --upgrade psutil
  4. $ pip install --upgrade glances[all]
  1. root@wgs:~# apt -y install glances
  1. [root@wgs ~]# yum -y install glances
点击查看代码
  1. root@wgs:~# glances -h
  2. 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]
  3. [--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]
  4. [-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]
  5. [--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]
  6. [--sparkline] [--theme-white] [--disable-check-update]
  7. optional arguments:

  8. -h, --help show this help message and exit

  9. -V, --version show program\'s version number and exit

  10. -d, --debug enable debug mode

  11. -C CONF_FILE, --config CONF_FILE

  12. path to the configuration file

  13. --modules-list, --module-list

  14. display modules (plugins & exports) list and exit

  15. --disable-plugin DISABLE_PLUGIN, --disable-plugins DISABLE_PLUGIN

  16. disable plugin (comma separed list)

  17. --enable-plugin ENABLE_PLUGIN, --enable-plugins ENABLE_PLUGIN

  18. enable plugin (comma separed list)

  19. --disable-process disable process module

  20. --disable-webui disable the Web Interface

  21. --light, --enable-light

  22. light mode for Curses UI (disable all but top menu)

  23. -0, --disable-irix task\'s cpu usage will be divided by the total number of CPUs

  24. -1, --percpu #start Glances in per CPU mode

  25. -2, --disable-left-sidebar

  26. #禁用网络、磁盘 I/O、FS 和传感器模块

  27. -3, --disable-quicklook

  28. #禁用快速查看模块

  29. -4, --full-quicklook #禁用除快速查看和加载之外的所有功能

  30. -5, --disable-top #禁用顶部菜单(QL、CPU、MEM、SWAP 和 LOAD)

  31. -6, --meangpu #start Glances in mean GPU mode

  32. --disable-history #禁用统计历史

  33. --disable-bold #在终端中禁用粗体模式

  34. --disable-bg #禁用终端中的背景颜色

  35. --enable-irq #启用 IRQ 模块

  36. -enable-process-extended

  37. #启用顶级进程的扩展统计信息

  38. --export EXPORT #启用导出模块(逗号分隔列表)

  39. --export-csv-file EXPORT_CSV_FILE

  40. #CSV 导出器的文件路径

  41. --export-csv-overwrite

  42. #覆盖现有的 CSV 文件

  43. --export-json-file EXPORT_JSON_FILE

  44. #JSON 导出器的文件路径

  45. --export-graph-path EXPORT_GRAPH_PATH

  46. # 图形导出器的路径

  47. -c CLIENT, --client CLIENT

  48. #通过 IPv4/IPv6 地址或主机名连接到 Glances 服务器

  49. -s, --server #在服务器模式下运行 Glances

  50. --browser #启动客户端浏览器(服务器列表)

  51. --disable-autodiscover

  52. #禁用自动发现功能

  53. -p PORT, --port PORT #定义客户端/服务器 TCP 端口 [默认:61209]

  54. -B BIND_ADDRESS, --bind BIND_ADDRESS

  55. #将服务器绑定到给定的 IPv4/IPv6 地址或主机名

  56. --username #定义客户端/服务器用户名

  57. --password #定义客户端/服务器密码

  58. -u USERNAME_USED #使用给定的客户端/服务器用户名

  59. --snmp-community SNMP_COMMUNITY

  60. #SNMP community

  61. --snmp-port SNMP_PORT

  62. #SNMP端口

  63. --snmp-version SNMP_VERSION

  64. #SNMP 版本(1、2c 或 3)

  65. --snmp-user SNMP_USER

  66. #SNMP 用户名(仅适用于 SNMPv3)

  67. --snmp-auth SNMP_AUTH

  68. #SNMP 认证密钥(仅适用于 SNMPv3)

  69. --snmp-force #强制 SNMP 模式

  70. -t TIME, --time TIME #以秒为单位设置刷新时间 [默认:3 秒]

  71. -w, --webserver #在网络服务器模式下运行 Glances

  72. --cached-time CACHED_TIME #设置服务器缓存时间 [默认:1 秒]

  73. --open-web-browser #尝试在默认 Web 浏览器中打开 Web UI

  74. -q, --quiet #不显示curses界面

  75. -f PROCESS_FILTER, --process-filter PROCESS_FILTER

  76. #设置进程过滤模式(正则表达式)

  77. --process-short-name #强制进程名称的简称

  78. --stdout STDOUT #向标准输出显示统计数据,每行一个统计数据(插件/plugins.attribute 的逗号分隔列表)

  79. --stdout-csv STDOUT_CSV #将统计信息显示为标准输出,csv 格式(插件/plugins.attribute 的逗号分隔列表)

  80. --hide-kernel-threads #在进程列表中隐藏内核线程(在 Windows 上不可用)

  81. -b, --byte #以每秒字节数显示网络速率

  82. --diskio-show-ramfs #在 DiskIO 插件中显示 RAM Fs

  83. --diskio-iops #在 DiskIO 插件中显示每秒 IO

  84. --fahrenheit #以华氏度显示温度(默认为摄氏度)

  85. --fs-free-space #显示 FS 可用空间而不是已用空间

  86. --sparkline #在curses界面中显示迷你图而不是条形图

  87. --theme-white #优化白色背景的显示颜色

  88. --disable-check-update #禁用在线 Glances 版本检查

  89. Examples of use:

  90. Monitor local machine (standalone mode):

  91. $ glances

  92. Display all Glances modules (plugins and exporters) and exit:

  93. $ glances --module-list

  94. Monitor local machine with the Web interface and start RESTful server:

  95. $ glances -w

  96. Glances web server started on http://0.0.0.0:61208/

  97. Only start RESTful API (without the WebUI):

  98. $ glances -w --disable-webui

  99. Glances API available on http://0.0.0.0:61208/api/

  100. Monitor local machine and export stats to a CSV file (standalone mode):

  101. $ glances --export csv --export-csv-file /tmp/glances.csv

  102. Monitor local machine and export stats to a InfluxDB server with 5s refresh time (standalone mode):

  103. $ glances -t 5 --export influxdb

  104. Start a Glances XML/RCP server (server mode):

  105. $ glances -s

  106. Connect Glances to a Glances XML/RCP server (client mode):

  107. $ glances -c <ip_server>

  108. Connect Glances to a Glances server and export stats to a StatsD server (client mode):

  109. $ glances -c <ip_server> --export statsd

  110. Start the client browser (browser mode):

  111. $ glances --browser

  112. Display stats to stdout (one stat per line):

  113. $ glances --stdout now,cpu.user,mem.used,load

  114. Display CSV stats to stdout (all stats in one line):

  115. $ glances --stdout-csv now,cpu.user,mem.used,load

  116. Disable some plugins (comma separated list):

  117. $ glances --disable-plugin network,ports

  118. Enable some plugins (comma separated list):

  119. $ glances --enable-plugin sensors

  • 更强大的 htop / top 代替者
  • 如果要监视本地计算机,请打开控制台/终端并运行glances,按“q”或“ESC”退出
  1. root@wgs:~# glances

  • 使用交互式的方式运行该工具,用户可以使用如下快捷键:
    •  h : 显示帮助信息
    • q : 离开程序退出
    • c :按照 CPU 实时负载对系统进程进行排序
    • m :按照内存使用状况对系统进程排序
    •  i:按照 I/O 使用状况对系统进程排序
    • p: 按照进程名称排序
    • d : 显示磁盘读写状况 
    • w : 删除日志文件
    • l :显示日志
    • s: 显示传感器信息
    • f : 显示系统信息
    • 1 :轮流显示每个 CPU 内核的使用情况
  • 在服务器模式下,您可以使用-B ADDRESS设置绑定地址和-p PORT 指定TCP端口。
  • 默认绑定地址是0.0.0.0(Glances 会监听所有可用的网络接口),TCP 端口是61209.
  1. root@server:~# glances -s
  1. #@server 替换成自己server端IP
  2. root@client:~# glances -c @server
  1. root@server:~# glances -w
  • 浏览器访问 http://@server:61208
  • @server 替换成server端的IP 
  • 10s刷新一次
  •  http://@server:61208/10
  • @server 替换成server端的IP 

版权声明:本文为wangguishe原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/wangguishe/p/15261358.html