点击上方蓝字
关注大侠之运维
话不多说,先来张图看下

glances是用python编写的一个实时监控工具,是用psutil库从系统中获取相关的监控信息
可以说在一个屏下尽可能的展示足够多的信息,另外对系统性能的使用也可以接受,不到2%,这款工具的监控信息还可以通过web界面展示,也提供了api接口可以取拉去对应的信息,可玩性,实用性上还是不错的.
相关的监控数据也可以导出为csv,也可以输出到influxdb这类时序库中
安装
可以通过pip安装,也可以通过yum安装
都是直接命令安装就好
pip install glances
如果需要web功能或者导出模块 可以通过 如下方式
pip install glances[all]
yum 安装的话,直接常规命令安装就好
yum install glances -y
快速入门
直接执行glances可以展示文章开头的界面
[root@test-3 bin]# ./glances --stdout cpu.user,mem.used,loadcpu.user: 15.4mem.used: 1896566784load: {'min1': 0.11, 'min5': 0.19, 'min15': 0.18, 'cpucore': 4}cpu.user: 9.7mem.used: 1898405888load: {'min1': 0.11, 'min5': 0.19, 'min15': 0.18, 'cpucore': 4}cpu.user: 9.7mem.used: 1898405888load: {'min1': 0.11, 'min5': 0.19, 'min15': 0.18, 'cpucore': 4}
可以监控远端的主机.现在服务端执行
glances -s
然后在客户端执行
glances -c @server
如果要通过web页面去展示的话,可以通过glances -w
需要提前装bottle模块


如果安全考虑,可以配置密码 通过 --password
[root@test-3 bin]# ./glances -w --passwordDefine the Glances webserver password (glances username):Password (confirm):Do you want to save the password? [Yes/No]: yesGlances Web User Interface started on http://0.0.0.0:61208/

支持输出类型
可以看到除了csv外,还有很多的输出支持

这个监控还做了多个终端的适配,可以在手机上展示,也可以在平板\笔记本上展示


命令参考
usage: glances [-h] [-V] [-d] [-C CONF_FILE] [-3] [-4] [--disable-cpu][--disable-mem] [--disable-swap] [--disable-load][--disable-network] [--disable-ip] [--disable-diskio][--disable-fs] [--disable-sensors] [--disable-hddtemp][--disable-raid] [--disable-docker] [-2] [--disable-process][--disable-log] [--disable-bold] [--enable-process-extended][--enable-history] [--path-history PATH_HISTORY][--export-csv EXPORT_CSV] [--export-influxdb][--export-opentsdb] [--export-statsd] [--export-rabbitmq][-c CLIENT] [-s] [--browser] [--disable-autodiscover] [-p PORT][-B BIND_ADDRESS] [--password][--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] [-q][-f PROCESS_FILTER] [--process-short-name] [-0][--hide-kernel-threads] [--tree] [-b] [--fahrenheit] [-1][--fs-free-space] [--theme-white]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_FILEpath to the configuration file-3, --disable-quicklookdisable quick look module-4, --full-quicklook disable all but quick look and load--disable-cpu disable CPU module--disable-mem disable memory module--disable-swap disable swap module--disable-load disable load module--disable-network disable network module--disable-ip disable IP module--disable-diskio disable disk I/O module--disable-fs disable filesystem module--disable-sensors disable sensors module--disable-hddtemp disable HD temperature module--disable-raid disable RAID module--disable-docker disable Docker module-2, --disable-left-sidebardisable network, disk I/O, FS and sensors modules(py3sensors needed)--disable-process disable process module--disable-log disable log module--disable-bold disable bold mode in the terminal--enable-process-extendedenable extended stats on top process--enable-history enable the history mode (matplotlib needed)--path-history PATH_HISTORYset the export path for graph history--export-csv EXPORT_CSVexport stats to a CSV file--export-influxdb export stats to an InfluxDB server (influxdb needed)--export-opentsdb export stats to an OpenTSDB server (potsdb needed)--export-statsd export stats to a StatsD server (statsd needed)--export-rabbitmq export stats to rabbitmq broker (pika needed)-c CLIENT, --client CLIENTconnect to a Glances server by IPv4/IPv6 address orhostname-s, --server run Glances in server mode--browser start the client browser (list of servers)--disable-autodiscoverdisable autodiscover feature-p PORT, --port PORT define the client/server TCP port [default: 61209]-B BIND_ADDRESS, --bind BIND_ADDRESSbind server to the given IPv4/IPv6 address or hostname--password define a client/server password--snmp-community SNMP_COMMUNITYSNMP community--snmp-port SNMP_PORTSNMP port--snmp-version SNMP_VERSIONSNMP version (1, 2c or 3)--snmp-user SNMP_USERSNMP username (only for SNMPv3)--snmp-auth SNMP_AUTHSNMP authentication key (only for SNMPv3)--snmp-force force SNMP mode-t TIME, --time TIME set refresh time in seconds [default: 3 sec]-w, --webserver run Glances in web server mode (bottle needed)-q, --quiet do not display the curses interface-f PROCESS_FILTER, --process-filter PROCESS_FILTERset the process filter pattern (regular expression)--process-short-name force short name for processes name-0, --disable-irix Task's cpu usage will be divided by the total numberof CPUs--hide-kernel-threadshide kernel threads in process list--tree display processes as a tree-b, --byte display network rate in byte per second--fahrenheit display temperature in Fahrenheit (default is Celsius)-1, --percpu start Glances in per CPU mode--fs-free-space display FS free space instead of used--theme-white optimize display colors for white backgroundExamples of use:Monitor local machine (standalone mode):$ glancesMonitor local machine with the Web interface (Web UI):$ glances -wGlances web server started on http://0.0.0.0:61208/Monitor local machine and export stats to a CSV file (standalone mode):$ glances --export-csvMonitor local machine and export stats to a InfluxDB server with 5s refresh time (standalone mode):$ glances -t 5 --export-influxdbStart a Glances server (server mode):$ glances -sConnect Glances to a Glances 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-statsdStart the client browser (browser mode):$ glances --browser

👆点击查看更多内容👆
推荐阅读
elk8.0部署文档(rsyslog+kafka+logstash+elasticsearch+kibana))
ELK告警插件-elastalert2 实践,支持elk8.0版本,企微机器人告警实现
记得星标记一下,下次更容易找到我
文章转载自大侠之运维,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。




