Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
蜕变的菜鸟
glances
提交
4f7f6be6
G
glances
项目概览
蜕变的菜鸟
/
glances
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
glances
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
4f7f6be6
编写于
12月 29, 2017
作者:
N
nicolargo
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'issue1173' into develop
上级
54b0c4e2
91c4f173
变更
18
隐藏空白更改
内联
并排
Showing
18 changed file
with
257 addition
and
448 deletion
+257
-448
NEWS
NEWS
+17
-0
conf/glances.conf
conf/glances.conf
+12
-11
docs/cmds.rst
docs/cmds.rst
+12
-116
docs/config.rst
docs/config.rst
+1
-1
docs/glances.rst
docs/glances.rst
+7
-3
docs/man/glances.1
docs/man/glances.1
+24
-147
glances/config.py
glances/config.py
+6
-4
glances/exports/glances_csv.py
glances/exports/glances_csv.py
+2
-2
glances/exports/glances_json.py
glances/exports/glances_json.py
+1
-1
glances/exports/graph.py
glances/exports/graph.py
+2
-2
glances/main.py
glances/main.py
+80
-104
glances/outputs/glances_bottle.py
glances/outputs/glances_bottle.py
+1
-1
glances/outputs/glances_curses.py
glances/outputs/glances_curses.py
+28
-35
glances/plugins/glances_sensors.py
glances/plugins/glances_sensors.py
+1
-1
glances/plugins/glances_wifi.py
glances/plugins/glances_wifi.py
+1
-1
glances/server.py
glances/server.py
+1
-1
glances/standalone.py
glances/standalone.py
+14
-0
glances/stats.py
glances/stats.py
+47
-18
未找到文件。
NEWS
浏览文件 @
4f7f6be6
...
...
@@ -11,6 +11,7 @@ Enhancements and new features:
* A way to have only REST API available and disable WEB GUI access #1149
* Docker module doesn't export details about stopped containers #1152
* Add dynamic fields in all sections of the configuration file #1204
* Make plugins disable and export CLI option dynamical #1173
* Add a light mode for the console UI #1165
* Refactor InfluxDB (API is now stable) #1166
...
...
@@ -33,19 +34,35 @@ Backward-incompatible changes:
* Minimum supported Docker API version is now 1.21 (Docker plugins)
* Support for InfluxDB < 0.9 is deprecated (InfluxDB exporter)
* --disable-<plugin> no longer available (use --disable-plugin <plugin>)
* --export-<exporter> no longer available (use --export <exporter>)
News command line options:
--disable-webui Disable the WebUI (only Restful API will respond)
--enable-light Enable the light mode for the UI interface
--modules-list Display plugins and exporters list
--disable-plugin plugin1,plugin2
Disable a list of comma separated plugins
--export exporter1,exporter2
Export stats to a comma separated exporters
News configuration keys in the glances.conf file:
Docker plugin (related to #1152)
[docker]
# By default, Glances only display running containers
# Set the following key to True to display all containers
all=False
All configuration file values (related to #1204)
[influxdb]
# It is possible to use dynamic system command
prefix=`hostname`
tags=foo:bar,spam:eggs,system:`uname -a`
==============================================================================
Glances Version 2
==============================================================================
...
...
conf/glances.conf
浏览文件 @
4f7f6be6
...
...
@@ -305,7 +305,7 @@ all=False
##############################################################################
[
influxdb
]
# Configuration for the --export
-
influxdb option
# Configuration for the --export
influxdb option
# https://influxdb.com/
host
=
localhost
port
=
8086
...
...
@@ -325,7 +325,7 @@ prefix=localhost
#tags=system:`uname -s`
[
cassandra
]
# Configuration for the --export
-
cassandra option
# Configuration for the --export
cassandra option
# Also works for the ScyllaDB
# https://influxdb.com/ or http://www.scylladb.com/
host
=
localhost
...
...
@@ -337,7 +337,7 @@ replication_factor=2
table
=
localhost
[
opentsdb
]
# Configuration for the --export
-
opentsdb option
# Configuration for the --export
opentsdb option
# http://opentsdb.net/
host
=
localhost
port
=
4242
...
...
@@ -345,14 +345,14 @@ port=4242
#tags=foo:bar,spam:eggs
[
statsd
]
# Configuration for the --export
-
statsd option
# Configuration for the --export
statsd option
# https://github.com/etsy/statsd
host
=
localhost
port
=
8125
#prefix=glances
[
elasticsearch
]
# Configuration for the --export
-
elasticsearch option
# Configuration for the --export
elasticsearch option
# Data are available via the ES Restful API. ex: URL/<index>/cpu/system
# https://www.elastic.co
host
=
localhost
...
...
@@ -360,12 +360,13 @@ port=9200
index
=
glances
[
riemann
]
# Configuration for the --export
-
riemann option
# Configuration for the --export
riemann option
# http://riemann.io
host
=
localhost
port
=
5555
[
rabbitmq
]
# Configuration for the --export rabbitmq option
host
=
localhost
port
=
5672
user
=
guest
...
...
@@ -373,7 +374,7 @@ password=guest
queue
=
glances_queue
[
couchdb
]
# Configuration for the --export
-
couchdb option
# Configuration for the --export
couchdb option
# https://www.couchdb.org
host
=
localhost
port
=
5984
...
...
@@ -383,7 +384,7 @@ db=glances
#password=root
[
kafka
]
# Configuration for the --export
-
kafka option
# Configuration for the --export
kafka option
# http://kafka.apache.org/
host
=
localhost
port
=
9092
...
...
@@ -391,7 +392,7 @@ topic=glances
#compression=gzip
[
zeromq
]
# Configuration for the --export
-
zeromq option
# Configuration for the --export
zeromq option
# http://www.zeromq.org
# Use * to bind on all interfaces
host
=*
...
...
@@ -403,7 +404,7 @@ port=5678
prefix
=
G
[
prometheus
]
# Configuration for the --export
-
prometheus option
# Configuration for the --export
prometheus option
# https://prometheus.io
# Create a Prometheus exporter listening on localhost:9091 (default configuration)
# Metric are exporter using the following name:
...
...
@@ -419,7 +420,7 @@ port=9091
prefix
=
glances
[
restful
]
# Configuration for the --export
-
restful option
# Configuration for the --export
restful option
# Example, export to http://localhost:6789/
host
=
localhost
port
=
6789
...
...
docs/cmds.rst
浏览文件 @
4f7f6be6
...
...
@@ -22,90 +22,34 @@ Command-Line Options
path to the configuration file
.. option:: -
-disable-aler
t
.. option:: -
modules-lis
t
dis
able alert/log module
dis
play modules (plugins & exports) list and exit
.. option:: --disable-
amps
.. option:: --disable-
plugin PLUGIN
disable
application monitoring process module
disable
PLUGIN (comma separed list)
.. option:: --
disable-cpu
.. option:: --
export EXPORT
disable CPU module
enable EXPORT module (comma separed list)
.. option:: --
disable-diskio
.. option:: --
export-csv-file EXPORT_CSV_FILE
disable disk I/O module
file path for CSV exporter
.. option:: --
disable-docker
.. option:: --
export-json-file EXPORT_JSON_FILE
disable Docker module
.. option:: --disable-folders
disable folders module
.. option:: --disable-fs
disable file system module
.. option:: --disable-hddtemp
disable HD temperature module
.. option:: --disable-ip
disable IP module
.. option:: --disable-irq
disable IRQ module
.. option:: --disable-load
disable load module
.. option:: --disable-mem
disable memory module
.. option:: --disable-memswap
disable memory swap module
.. option:: --disable-network
disable network module
.. option:: --disable-now
disable current time module
.. option:: --disable-ports
disable Ports module
file path for JSON exporter
.. option:: --disable-process
disable process module
.. option:: --disable-raid
disable RAID module
.. option:: --disable-sensors
disable sensors module
disable process module (reduce Glances CPU consumption)
.. option:: --disable-webui
disable the Web UI (only the Restful API will respond)
.. option:: --disable-wifi
disable Wifi module
.. option:: --light, --enable-light
light mode for Curses UI (disable all but top menu)
...
...
@@ -154,54 +98,6 @@ Command-Line Options
enable extended stats on top process
.. option:: --export-graph
export stats to graph
.. option:: --path-graph PATH_GRAPH
set the export path for graph history
.. option:: --export-csv EXPORT_CSV
export stats to a CSV file
.. option:: --export-cassandra
export stats to a Cassandra/Scylla server (cassandra lib needed)
.. option:: --export-couchdb
export stats to a CouchDB server (couchdb lib needed)
.. option:: --export-elasticsearch
export stats to an Elasticsearch server (elasticsearch lib needed)
.. option:: --export-influxdb
export stats to an InfluxDB server (influxdb lib needed)
.. option:: --export-opentsdb
export stats to an OpenTSDB server (potsdb lib needed)
.. option:: --export-rabbitmq
export stats to RabbitMQ broker (pika lib needed)
.. option:: --export-statsd
export stats to a StatsD server (statsd lib needed)
.. option:: --export-riemann
export stats to Riemann server (bernhard lib needed)
.. option:: --export-zeromq
export stats to a ZeroMQ server (zmq lib needed)
.. option:: -c CLIENT, --client CLIENT
connect to a Glances server by IPv4/IPv6 address, hostname or hostname:port
...
...
@@ -409,7 +305,7 @@ The following commands (key pressed) are supported while in Glances:
``p``
Sort processes by name
``q|ESC``
``q|ESC
|CTRL-C
``
Quit the current Glances session
``Q``
...
...
docs/config.rst
浏览文件 @
4f7f6be6
...
...
@@ -66,7 +66,7 @@ an InfluxDB export module:
.. code-block:: ini
[influxdb]
# Configuration for the --export
-
influxdb option
# Configuration for the --export
influxdb option
# https://influxdb.com/
host=localhost
port=8086
...
...
docs/glances.rst
浏览文件 @
4f7f6be6
...
...
@@ -44,13 +44,17 @@ Monitor local machine with the web interface (Web UI):
Monitor local machine and export stats to a CSV file:
$ glances --export
-
csv
$ glances --export
csv --export-csv-file /tmp/glances.
csv
Monitor local machine and export stats to a InfluxDB server with 5s
refresh time (also possible to export to OpenTSDB, Cassandra, Statsd,
ElasticSearch, RabbitMQ and Riemann):
$ glances -t 5 --export-influxdb
$ glances -t 5 --export influxdb
It is also possible to export stats to multiple endpoints:
$ glances -t 5 --export influxdb,statsd,csv
Start a Glances server (server mode):
...
...
@@ -62,7 +66,7 @@ Connect Glances to a Glances server (client mode):
Connect to a Glances server and export stats to a StatsD server:
$ glances -c <ip_server> --export
-
statsd
$ glances -c <ip_server> --export
statsd
Start the client browser (browser mode):
...
...
docs/man/glances.1
浏览文件 @
4f7f6be6
.\" Man page generated from reStructuredText.
.
.TH "GLANCES" "1" "Dec 2
6
, 2017" "3.0_DEV" "Glances"
.TH "GLANCES" "1" "Dec 2
8
, 2017" "3.0_DEV" "Glances"
.SH NAME
glances \- An eye on your system
.
...
...
@@ -68,98 +68,33 @@ path to the configuration file
.UNINDENT
.INDENT 0.0
.TP
.B \-
\-disable\-aler
t
dis
able alert/log module
.B \-
modules\-lis
t
dis
play modules (plugins & exports) list and exit
.UNINDENT
.INDENT 0.0
.TP
.B \-\-disable\-
amps
disable
application monitoring process module
.B \-\-disable\-
plugin PLUGIN
disable
PLUGIN (comma separed list)
.UNINDENT
.INDENT 0.0
.TP
.B \-\-
disable\-cpu
disable CPU module
.B \-\-
export EXPORT
enable EXPORT module (comma separed list)
.UNINDENT
.INDENT 0.0
.TP
.B \-\-
disable\-diskio
disable disk I/O module
.B \-\-
export\-csv\-file EXPORT_CSV_FILE
file path for CSV exporter
.UNINDENT
.INDENT 0.0
.TP
.B \-\-disable\-docker
disable Docker module
.UNINDENT
.INDENT 0.0
.TP
.B \-\-disable\-folders
disable folders module
.UNINDENT
.INDENT 0.0
.TP
.B \-\-disable\-fs
disable file system module
.UNINDENT
.INDENT 0.0
.TP
.B \-\-disable\-hddtemp
disable HD temperature module
.UNINDENT
.INDENT 0.0
.TP
.B \-\-disable\-ip
disable IP module
.UNINDENT
.INDENT 0.0
.TP
.B \-\-disable\-irq
disable IRQ module
.UNINDENT
.INDENT 0.0
.TP
.B \-\-disable\-load
disable load module
.UNINDENT
.INDENT 0.0
.TP
.B \-\-disable\-mem
disable memory module
.UNINDENT
.INDENT 0.0
.TP
.B \-\-disable\-memswap
disable memory swap module
.UNINDENT
.INDENT 0.0
.TP
.B \-\-disable\-network
disable network module
.UNINDENT
.INDENT 0.0
.TP
.B \-\-disable\-now
disable current time module
.UNINDENT
.INDENT 0.0
.TP
.B \-\-disable\-ports
disable Ports module
.B \-\-export\-json\-file EXPORT_JSON_FILE
file path for JSON exporter
.UNINDENT
.INDENT 0.0
.TP
.B \-\-disable\-process
disable process module
.UNINDENT
.INDENT 0.0
.TP
.B \-\-disable\-raid
disable RAID module
.UNINDENT
.INDENT 0.0
.TP
.B \-\-disable\-sensors
disable sensors module
disable process module (reduce Glances CPU consumption)
.UNINDENT
.INDENT 0.0
.TP
...
...
@@ -168,11 +103,6 @@ disable the Web UI (only the Restful API will respond)
.UNINDENT
.INDENT 0.0
.TP
.B \-\-disable\-wifi
disable Wifi module
.UNINDENT
.INDENT 0.0
.TP
.B \-\-light, \-\-enable\-light
light mode for Curses UI (disable all but top menu)
.UNINDENT
...
...
@@ -233,66 +163,6 @@ enable extended stats on top process
.UNINDENT
.INDENT 0.0
.TP
.B \-\-export\-graph
export stats to graph
.UNINDENT
.INDENT 0.0
.TP
.B \-\-path\-graph PATH_GRAPH
set the export path for graph history
.UNINDENT
.INDENT 0.0
.TP
.B \-\-export\-csv EXPORT_CSV
export stats to a CSV file
.UNINDENT
.INDENT 0.0
.TP
.B \-\-export\-cassandra
export stats to a Cassandra/Scylla server (cassandra lib needed)
.UNINDENT
.INDENT 0.0
.TP
.B \-\-export\-couchdb
export stats to a CouchDB server (couchdb lib needed)
.UNINDENT
.INDENT 0.0
.TP
.B \-\-export\-elasticsearch
export stats to an Elasticsearch server (elasticsearch lib needed)
.UNINDENT
.INDENT 0.0
.TP
.B \-\-export\-influxdb
export stats to an InfluxDB server (influxdb lib needed)
.UNINDENT
.INDENT 0.0
.TP
.B \-\-export\-opentsdb
export stats to an OpenTSDB server (potsdb lib needed)
.UNINDENT
.INDENT 0.0
.TP
.B \-\-export\-rabbitmq
export stats to RabbitMQ broker (pika lib needed)
.UNINDENT
.INDENT 0.0
.TP
.B \-\-export\-statsd
export stats to a StatsD server (statsd lib needed)
.UNINDENT
.INDENT 0.0
.TP
.B \-\-export\-riemann
export stats to Riemann server (bernhard lib needed)
.UNINDENT
.INDENT 0.0
.TP
.B \-\-export\-zeromq
export stats to a ZeroMQ server (zmq lib needed)
.UNINDENT
.INDENT 0.0
.TP
.B \-c CLIENT, \-\-client CLIENT
connect to a Glances server by IPv4/IPv6 address, hostname or hostname:port
.UNINDENT
...
...
@@ -537,7 +407,7 @@ Show/hide current time
.B \fBp\fP
Sort processes by name
.TP
.B \fBq|ESC\fP
.B \fBq|ESC
|CTRL\-C
\fP
Quit the current Glances session
.TP
.B \fBQ\fP
...
...
@@ -723,7 +593,7 @@ an InfluxDB export module:
.nf
.ft C
[influxdb]
# Configuration for the \-\-export
\-
influxdb option
# Configuration for the \-\-export
influxdb option
# https://influxdb.com/
host=localhost
port=8086
...
...
@@ -926,7 +796,7 @@ $ glances \-w
Monitor local machine and export stats to a CSV file:
.INDENT 0.0
.INDENT 3.5
$ glances \-\-export
\-
csv
$ glances \-\-export
csv \-\-export\-csv\-file /tmp/glances.
csv
.UNINDENT
.UNINDENT
.sp
...
...
@@ -935,7 +805,14 @@ refresh time (also possible to export to OpenTSDB, Cassandra, Statsd,
ElasticSearch, RabbitMQ and Riemann):
.INDENT 0.0
.INDENT 3.5
$ glances \-t 5 \-\-export\-influxdb
$ glances \-t 5 \-\-export influxdb
.UNINDENT
.UNINDENT
.sp
It is also possible to export stats to multiple endpoints:
.INDENT 0.0
.INDENT 3.5
$ glances \-t 5 \-\-export influxdb,statsd,csv
.UNINDENT
.UNINDENT
.sp
...
...
@@ -956,7 +833,7 @@ $ glances \-c <ip_server>
Connect to a Glances server and export stats to a StatsD server:
.INDENT 0.0
.INDENT 3.5
$ glances \-c <ip_server> \-\-export
\-
statsd
$ glances \-c <ip_server> \-\-export
statsd
.UNINDENT
.UNINDENT
.sp
...
...
glances/config.py
浏览文件 @
4f7f6be6
...
...
@@ -285,10 +285,12 @@ class Config(object):
# Search a substring `foo` and replace it by the result of its exec
if
ret
is
not
None
:
match
=
self
.
re_pattern
.
findall
(
ret
)
for
m
in
match
:
ret
=
ret
.
replace
(
m
,
system_exec
(
m
[
1
:
-
1
]))
try
:
match
=
self
.
re_pattern
.
findall
(
ret
)
for
m
in
match
:
ret
=
ret
.
replace
(
m
,
system_exec
(
m
[
1
:
-
1
]))
except
TypeError
:
pass
return
ret
def
get_int_value
(
self
,
section
,
option
,
default
=
0
):
...
...
glances/exports/glances_csv.py
浏览文件 @
4f7f6be6
...
...
@@ -37,7 +37,7 @@ class Export(GlancesExport):
super
(
Export
,
self
).
__init__
(
config
=
config
,
args
=
args
)
# CSV file name
self
.
csv_filename
=
args
.
export_csv
self
.
csv_filename
=
args
.
export_csv
_file
# Set the CSV output file
try
:
...
...
@@ -65,7 +65,7 @@ class Export(GlancesExport):
"""Update stats in the CSV output file."""
# Get the stats
all_stats
=
stats
.
getAllExports
()
plugins
=
stats
.
get
AllPlugins
()
plugins
=
stats
.
get
PluginsList
()
# Init data with timestamp (issue#708)
if
self
.
first_line
:
...
...
glances/exports/glances_json.py
浏览文件 @
4f7f6be6
...
...
@@ -17,7 +17,7 @@ class Export(GlancesExport):
super
(
Export
,
self
).
__init__
(
config
=
config
,
args
=
args
)
# JSON file name
self
.
json_filename
=
args
.
export_json
self
.
json_filename
=
args
.
export_json
_file
# Set the JSON output file
try
:
...
...
glances/exports/graph.py
浏览文件 @
4f7f6be6
...
...
@@ -54,7 +54,7 @@ class GlancesGraph(object):
"""Reset all the history."""
if
not
self
.
graph_enabled
():
return
False
for
p
in
stats
.
get
AllPlugins
():
for
p
in
stats
.
get
PluginsList
():
h
=
stats
.
get_plugin
(
p
).
get_stats_history
()
if
h
is
not
None
:
stats
.
get_plugin
(
p
).
reset_stats_history
()
...
...
@@ -94,7 +94,7 @@ class GlancesGraph(object):
return
0
index_all
=
0
for
p
in
stats
.
get
AllPlugins
():
for
p
in
stats
.
get
PluginsList
():
# History
h
=
stats
.
get_plugin
(
p
).
get_export_history
()
# Current plugin item history list
...
...
glances/main.py
浏览文件 @
4f7f6be6
...
...
@@ -31,6 +31,16 @@ from glances.globals import LINUX, WINDOWS
from
glances.logger
import
logger
def
disable
(
class_name
,
var
):
"""Set disable_<var> to True in the class class_name."""
setattr
(
class_name
,
'disable_'
+
var
,
True
)
def
enable
(
class_name
,
var
):
"""Set disable_<var> to False in the class class_name."""
setattr
(
class_name
,
'disable_'
+
var
,
False
)
class
GlancesMain
(
object
):
"""Main class to manage Glances instance."""
...
...
@@ -54,6 +64,9 @@ 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/
...
...
@@ -63,10 +76,10 @@ Examples of use:
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
/tmp/glances.csv
$ 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
$ glances -t 5 --export
influxdb
Start a Glances XML/RCP server (server mode):
$ glances -s
...
...
@@ -75,10 +88,13 @@ Examples of use:
$ 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
$ glances -c <ip_server> --export
statsd
Start the client browser (browser mode):
$ glances --browser
Disable some plugins (any modes):
$ glances --disable-plugin network,ports
"""
def
__init__
(
self
):
...
...
@@ -100,51 +116,18 @@ Examples of use:
dest
=
'debug'
,
help
=
'enable debug mode'
)
parser
.
add_argument
(
'-C'
,
'--config'
,
dest
=
'conf_file'
,
help
=
'path to the configuration file'
)
# Enable or disable option on startup
parser
.
add_argument
(
'--disable-alert'
,
action
=
'store_true'
,
default
=
False
,
dest
=
'disable_alert'
,
help
=
'disable alert module'
)
parser
.
add_argument
(
'--disable-amps'
,
action
=
'store_true'
,
default
=
False
,
dest
=
'disable_amps'
,
help
=
'disable applications monitoring process (AMP) module'
)
parser
.
add_argument
(
'--disable-cloud'
,
action
=
'store_true'
,
default
=
False
,
dest
=
'disable_cloud'
,
help
=
'disable Cloud module'
)
parser
.
add_argument
(
'--disable-cpu'
,
action
=
'store_true'
,
default
=
False
,
dest
=
'disable_cpu'
,
help
=
'disable CPU module'
)
parser
.
add_argument
(
'--disable-diskio'
,
action
=
'store_true'
,
default
=
False
,
dest
=
'disable_diskio'
,
help
=
'disable disk I/O module'
)
parser
.
add_argument
(
'--disable-docker'
,
action
=
'store_true'
,
default
=
False
,
dest
=
'disable_docker'
,
help
=
'disable Docker module'
)
parser
.
add_argument
(
'--disable-folders'
,
action
=
'store_true'
,
default
=
False
,
dest
=
'disable_folders'
,
help
=
'disable folder module'
)
parser
.
add_argument
(
'--disable-fs'
,
action
=
'store_true'
,
default
=
False
,
dest
=
'disable_fs'
,
help
=
'disable filesystem module'
)
parser
.
add_argument
(
'--disable-gpu'
,
action
=
'store_true'
,
default
=
False
,
dest
=
'disable_gpu'
,
help
=
'disable GPU module'
)
parser
.
add_argument
(
'--disable-hddtemp'
,
action
=
'store_true'
,
default
=
False
,
dest
=
'disable_hddtemp'
,
help
=
'disable HD temperature module'
)
parser
.
add_argument
(
'--disable-ip'
,
action
=
'store_true'
,
default
=
False
,
dest
=
'disable_ip'
,
help
=
'disable IP module'
)
parser
.
add_argument
(
'--disable-load'
,
action
=
'store_true'
,
default
=
False
,
dest
=
'disable_load'
,
help
=
'disable load module'
)
parser
.
add_argument
(
'--disable-mem'
,
action
=
'store_true'
,
default
=
False
,
dest
=
'disable_mem'
,
help
=
'disable memory module'
)
parser
.
add_argument
(
'--disable-memswap'
,
action
=
'store_true'
,
default
=
False
,
dest
=
'disable_memswap'
,
help
=
'disable memory swap module'
)
parser
.
add_argument
(
'--disable-network'
,
action
=
'store_true'
,
default
=
False
,
dest
=
'disable_network'
,
help
=
'disable network module'
)
parser
.
add_argument
(
'--disable-now'
,
action
=
'store_true'
,
default
=
False
,
dest
=
'disable_now'
,
help
=
'disable current time module'
)
parser
.
add_argument
(
'--disable-ports'
,
action
=
'store_true'
,
default
=
False
,
dest
=
'disable_ports'
,
help
=
'disable ports scanner module'
)
# Disable plugin
parser
.
add_argument
(
'--modules-list'
,
'--module-list'
,
action
=
'store_true'
,
default
=
False
,
dest
=
'modules_list'
,
help
=
'display modules (plugins & exports) list and exit'
)
parser
.
add_argument
(
'--disable-plugin'
,
dest
=
'disable_plugin'
,
help
=
'disable plugin (comma separed list)'
)
parser
.
add_argument
(
'--disable-process'
,
action
=
'store_true'
,
default
=
False
,
dest
=
'disable_process'
,
help
=
'disable process module'
)
parser
.
add_argument
(
'--disable-raid'
,
action
=
'store_true'
,
default
=
False
,
dest
=
'disable_raid'
,
help
=
'disable RAID module'
)
parser
.
add_argument
(
'--disable-sensors'
,
action
=
'store_true'
,
default
=
False
,
dest
=
'disable_sensors'
,
help
=
'disable sensors module'
)
# Enable or disable option
parser
.
add_argument
(
'--disable-webui'
,
action
=
'store_true'
,
default
=
False
,
dest
=
'disable_webui'
,
help
=
'disable the Web Interface'
)
parser
.
add_argument
(
'--disable-wifi'
,
action
=
'store_true'
,
default
=
False
,
dest
=
'disable_wifi'
,
help
=
'disable wifi module'
)
parser
.
add_argument
(
'--light'
,
'--enable-light'
,
action
=
'store_true'
,
default
=
False
,
dest
=
'enable_light'
,
help
=
'light mode for Curses UI (disable all but top menu)'
)
...
...
@@ -175,38 +158,21 @@ Examples of use:
parser
.
add_argument
(
'--enable-process-extended'
,
action
=
'store_true'
,
default
=
False
,
dest
=
'enable_process_extended'
,
help
=
'enable extended stats on top process'
)
# Export modules feature
parser
.
add_argument
(
'--export-graph'
,
action
=
'store_true'
,
default
=
None
,
dest
=
'export_graph'
,
help
=
'export stats to graphs'
)
parser
.
add_argument
(
'--path-graph'
,
default
=
tempfile
.
gettempdir
(),
dest
=
'path_graph'
,
help
=
'set the export path for graphs (default is {})'
.
format
(
tempfile
.
gettempdir
()))
parser
.
add_argument
(
'--export-csv'
,
default
=
None
,
dest
=
'export_csv'
,
help
=
'export stats to a CSV file'
)
parser
.
add_argument
(
'--export-json'
,
default
=
None
,
dest
=
'export_json'
,
help
=
'export stats to a JSON file'
)
parser
.
add_argument
(
'--export-cassandra'
,
action
=
'store_true'
,
default
=
False
,
dest
=
'export_cassandra'
,
help
=
'export stats to a Cassandra or Scylla server (cassandra lib needed)'
)
parser
.
add_argument
(
'--export-couchdb'
,
action
=
'store_true'
,
default
=
False
,
dest
=
'export_couchdb'
,
help
=
'export stats to a CouchDB server (couch lib needed)'
)
parser
.
add_argument
(
'--export-elasticsearch'
,
action
=
'store_true'
,
default
=
False
,
dest
=
'export_elasticsearch'
,
help
=
'export stats to an ElasticSearch server (elasticsearch lib needed)'
)
parser
.
add_argument
(
'--export-influxdb'
,
action
=
'store_true'
,
default
=
False
,
dest
=
'export_influxdb'
,
help
=
'export stats to an InfluxDB server (influxdb lib needed)'
)
parser
.
add_argument
(
'--export-kafka'
,
action
=
'store_true'
,
default
=
False
,
dest
=
'export_kafka'
,
help
=
'export stats to a Kafka server (kafka-python lib needed)'
)
parser
.
add_argument
(
'--export-opentsdb'
,
action
=
'store_true'
,
default
=
False
,
dest
=
'export_opentsdb'
,
help
=
'export stats to an OpenTSDB server (potsdb lib needed)'
)
parser
.
add_argument
(
'--export-prometheus'
,
action
=
'store_true'
,
default
=
False
,
dest
=
'export_prometheus'
,
help
=
'export stats to a Prometheus exporter (prometheus_client lib needed)'
)
parser
.
add_argument
(
'--export-rabbitmq'
,
action
=
'store_true'
,
default
=
False
,
dest
=
'export_rabbitmq'
,
help
=
'export stats to rabbitmq broker (pika lib needed)'
)
parser
.
add_argument
(
'--export-restful'
,
action
=
'store_true'
,
default
=
False
,
dest
=
'export_restful'
,
help
=
'export stats to a Restful endpoint (requests lib needed)'
)
parser
.
add_argument
(
'--export-riemann'
,
action
=
'store_true'
,
default
=
False
,
dest
=
'export_riemann'
,
help
=
'export stats to riemann broker (bernhard lib needed)'
)
parser
.
add_argument
(
'--export-statsd'
,
action
=
'store_true'
,
default
=
False
,
dest
=
'export_statsd'
,
help
=
'export stats to a StatsD server (statsd lib needed)'
)
parser
.
add_argument
(
'--export-zeromq'
,
action
=
'store_true'
,
default
=
False
,
dest
=
'export_zeromq'
,
help
=
'export stats to a ZeroMQ server (pyzmq lib needed)'
)
parser
.
add_argument
(
'--export'
,
dest
=
'export'
,
help
=
'enable export module (comma separed list)'
)
# To be removed on https://github.com/nicolargo/glances/issues/1206
# parser.add_argument('--export-graph', action='store_true', default=None,
# dest='export_graph', help='export stats to graphs')
# parser.add_argument('--path-graph', default=tempfile.gettempdir(),
# dest='path_graph', help='set the export path for graphs (default is {})'.format(tempfile.gettempdir()))
parser
.
add_argument
(
'--export-csv-file'
,
default
=
'./glances.csv'
,
dest
=
'export_csv_file'
,
help
=
'file path for CSV exporter'
)
parser
.
add_argument
(
'--export-json-file'
,
default
=
'./glances.json'
,
dest
=
'export_json_file'
,
help
=
'file path for JSON exporter'
)
# Client/Server option
parser
.
add_argument
(
'-c'
,
'--client'
,
dest
=
'client'
,
help
=
'connect to a Glances server by IPv4/IPv6 address or hostname'
)
...
...
@@ -286,6 +252,16 @@ Examples of use:
from
logging
import
DEBUG
logger
.
setLevel
(
DEBUG
)
# Plugins disable/enable
if
args
.
disable_plugin
is
not
None
:
for
p
in
args
.
disable_plugin
.
split
(
','
):
disable
(
args
,
p
)
# Exporters activation
if
args
.
export
is
not
None
:
for
p
in
args
.
export
.
split
(
','
):
setattr
(
args
,
'export_'
+
p
,
True
)
# Client/server Port
if
args
.
port
is
None
:
if
args
.
webserver
:
...
...
@@ -362,34 +338,34 @@ Examples of use:
if
args
.
enable_light
:
logger
.
info
(
"Light mode is on"
)
args
.
disable_left_sidebar
=
True
args
.
disable_process
=
True
args
.
disable_alert
=
True
args
.
disable_amps
=
True
args
.
disable_docker
=
True
disable
(
args
,
'process'
)
disable
(
args
,
'alert'
)
disable
(
args
,
'amps'
)
disable
(
args
,
'docker'
)
# Manage full quicklook option
if
args
.
full_quicklook
:
logger
.
info
(
"
Disable QuickLook menu
"
)
args
.
disable_quicklook
=
False
args
.
disable_cpu
=
True
args
.
disable_mem
=
True
args
.
disable_memswap
=
True
args
.
disable_load
=
False
logger
.
info
(
"
Full quicklook mode
"
)
enable
(
args
,
'quicklook'
)
disable
(
args
,
'cpu'
)
disable
(
args
,
'mem'
)
disable
(
args
,
'memswap'
)
enable
(
args
,
'load'
)
# Manage disable_top option
if
args
.
disable_top
:
logger
.
info
(
"Disable top menu"
)
args
.
disable_quicklook
=
True
args
.
disable_cpu
=
True
args
.
disable_mem
=
True
args
.
disable_memswap
=
True
args
.
disable_load
=
True
disable
(
args
,
'quicklook'
)
disable
(
args
,
'cpu'
)
disable
(
args
,
'mem'
)
disable
(
args
,
'memswap'
)
disable
(
args
,
'load'
)
# Control parameter and exit if it is not OK
self
.
args
=
args
# Export is only available in standalone or client mode (issue #614)
export_tag
=
any
([
getattr
(
args
,
a
)
for
a
in
args
.
__dict__
if
a
.
startswith
(
'export_'
)]
)
export_tag
=
self
.
args
.
export
is
not
None
and
any
(
self
.
args
.
export
)
if
WINDOWS
and
export_tag
:
# On Windows, export is possible but only in quiet mode
# See issue #1038
...
...
@@ -407,21 +383,21 @@ Examples of use:
sys
.
exit
(
2
)
# Check graph output path
if
args
.
export_graph
and
args
.
path_graph
is
not
None
:
if
not
os
.
access
(
args
.
path_graph
,
os
.
W_OK
)
:
logger
.
critical
(
"Graphs output path {} doesn't exist or is not writable"
.
format
(
args
.
path_graph
))
sys
.
exit
(
2
)
logger
.
debug
(
"Graphs output path is set to {}"
.
format
(
args
.
path_graph
))
# To be removed on https://github.com/nicolargo/glances/issues/1206
# if args.export_graph and args.path_graph is not None
:
# if not os.access(args.path_graph, os.W_OK):
# logger.critical("Graphs output path {} doesn't exist or is not writable".format(args.path_graph)
)
# sys.exit(2)
# logger.debug(
# "Graphs output path is set to {}".format(args.path_graph))
# For export graph, history is mandatory
if
args
.
export_graph
and
args
.
disable_history
:
logger
.
critical
(
"Can not export graph if history is disabled"
)
sys
.
exit
(
2
)
#
if args.export_graph and args.disable_history:
#
logger.critical("Can not export graph if history is disabled")
#
sys.exit(2)
# Disable HDDTemp if sensors are disabled
if
args
.
disable_sensors
:
args
.
disable_hddtemp
=
True
if
getattr
(
args
,
'disable_sensors'
,
False
)
:
disable
(
args
,
'hddtemp'
)
logger
.
debug
(
"Sensors and HDDTemp are disabled"
)
return
args
...
...
glances/outputs/glances_bottle.py
浏览文件 @
4f7f6be6
...
...
@@ -168,7 +168,7 @@ class GlancesBottle(object):
self
.
stats
=
stats
# Init plugin list
self
.
plugins_list
=
self
.
stats
.
get
AllPlugins
()
self
.
plugins_list
=
self
.
stats
.
get
PluginsList
()
# Bind the Bottle TCP address/port
if
self
.
args
.
open_web_browser
:
...
...
glances/outputs/glances_curses.py
浏览文件 @
4f7f6be6
...
...
@@ -165,15 +165,6 @@ class _GlancesCurses(object):
"""Init the history option."""
self
.
reset_history_tag
=
False
self
.
graph_tag
=
False
if
self
.
args
.
export_graph
:
logger
.
info
(
'Export graphs function enabled with output path %s'
%
self
.
args
.
path_graph
)
from
glances.exports.graph
import
GlancesGraph
self
.
glances_graph
=
GlancesGraph
(
self
.
args
.
path_graph
)
if
not
self
.
glances_graph
.
graph_enabled
():
self
.
args
.
export_graph
=
False
logger
.
error
(
'Export graphs disabled'
)
def
_init_cursor
(
self
):
"""Init cursors."""
...
...
@@ -382,12 +373,13 @@ class _GlancesCurses(object):
# 'f' > Show/hide fs / folder stats
self
.
args
.
disable_fs
=
not
self
.
args
.
disable_fs
self
.
args
.
disable_folders
=
not
self
.
args
.
disable_folders
elif
self
.
pressedkey
==
ord
(
'g'
):
# 'g' > Generate graph from history
self
.
graph_tag
=
not
self
.
graph_tag
elif
self
.
pressedkey
==
ord
(
'r'
):
# 'r' > Reset graph history
self
.
reset_history_tag
=
not
self
.
reset_history_tag
# To be removed on https://github.com/nicolargo/glances/issues/1206
# elif self.pressedkey == ord('g'):
# # 'g' > Generate graph from history
# self.graph_tag = not self.graph_tag
# elif self.pressedkey == ord('r'):
# # 'r' > Reset graph history
# self.reset_history_tag = not self.reset_history_tag
elif
self
.
pressedkey
==
ord
(
'w'
):
# 'w' > Delete finished warning logs
glances_logs
.
clean
()
...
...
@@ -494,7 +486,7 @@ class _GlancesCurses(object):
"""
ret
=
{}
for
p
in
stats
.
get
AllPlugins
(
enable
=
False
):
for
p
in
stats
.
get
PluginsList
(
enable
=
False
):
if
p
==
'quicklook'
or
p
==
'processlist'
:
# processlist is done later
# because we need to know how many processes could be displayed
...
...
@@ -597,25 +589,26 @@ class _GlancesCurses(object):
# History option
# Generate history graph
if
self
.
graph_tag
and
self
.
args
.
export_graph
:
self
.
display_popup
(
'Generate graphs history in {}
\n
Please wait...'
.
format
(
self
.
glances_graph
.
get_output_folder
()))
self
.
display_popup
(
'Generate graphs history in {}
\n
Done: {} graphs generated'
.
format
(
self
.
glances_graph
.
get_output_folder
(),
self
.
glances_graph
.
generate_graph
(
stats
)))
elif
self
.
reset_history_tag
and
self
.
args
.
export_graph
:
self
.
display_popup
(
'Reset graph history'
)
self
.
glances_graph
.
reset
(
stats
)
elif
(
self
.
graph_tag
or
self
.
reset_history_tag
)
and
not
self
.
args
.
export_graph
:
try
:
self
.
glances_graph
.
graph_enabled
()
except
Exception
:
self
.
display_popup
(
'Graph disabled
\n
Enable it using --export-graph'
)
else
:
self
.
display_popup
(
'Graph disabled'
)
self
.
graph_tag
=
False
# To be removed on https://github.com/nicolargo/glances/issues/1206
# if self.graph_tag and self.args.export_graph:
# self.display_popup(
# 'Generate graphs history in {}\nPlease wait...'.format(
# self.glances_graph.get_output_folder()))
# self.display_popup(
# 'Generate graphs history in {}\nDone: {} graphs generated'.format(
# self.glances_graph.get_output_folder(),
# self.glances_graph.generate_graph(stats)))
# elif self.reset_history_tag and self.args.export_graph:
# self.display_popup('Reset graph history')
# self.glances_graph.reset(stats)
# elif (self.graph_tag or self.reset_history_tag) and not self.args.export_graph:
# try:
# self.glances_graph.graph_enabled()
# except Exception:
# self.display_popup('Graph disabled\nEnable it using --export-graph')
# else:
# self.display_popup('Graph disabled')
# self.graph_tag = False
self
.
reset_history_tag
=
False
# Display edit filter popup
...
...
glances/plugins/glances_sensors.py
浏览文件 @
4f7f6be6
...
...
@@ -167,7 +167,7 @@ class Plugin(GlancesPlugin):
ret
=
[]
# Only process if stats exist and display plugin enable...
if
not
self
.
stats
or
args
.
disable_sensors
:
if
not
self
.
stats
or
self
.
is_disable
()
:
return
ret
# Max size for the interface name
...
...
glances/plugins/glances_wifi.py
浏览文件 @
4f7f6be6
...
...
@@ -167,7 +167,7 @@ class Plugin(GlancesPlugin):
ret
=
[]
# Only process if stats exist and display plugin enable...
if
not
self
.
stats
or
args
.
disable_wifi
or
not
wifi_tag
:
if
not
self
.
stats
or
not
wifi_tag
or
self
.
is_disable
()
:
return
ret
# Max size for the interface name
...
...
glances/server.py
浏览文件 @
4f7f6be6
...
...
@@ -162,7 +162,7 @@ class GlancesInstance(object):
def
getAllPlugins
(
self
):
# Return the plugins list
return
json
.
dumps
(
self
.
stats
.
get
AllPlugins
())
return
json
.
dumps
(
self
.
stats
.
get
PluginsList
())
def
getAllLimits
(
self
):
# Return all the plugins limits
...
...
glances/standalone.py
浏览文件 @
4f7f6be6
...
...
@@ -19,6 +19,7 @@
"""Manage the Glances standalone session."""
import
sys
from
glances.globals
import
WINDOWS
from
glances.logger
import
logger
...
...
@@ -41,6 +42,12 @@ class GlancesStandalone(object):
# Init stats
self
.
stats
=
GlancesStats
(
config
=
config
,
args
=
args
)
# Modules (plugins and exporters) are loaded at this point
# Glances can display the list if asked...
if
args
.
modules_list
:
self
.
display_modules_list
()
sys
.
exit
(
0
)
# If process extended stats is disabled by user
if
not
args
.
enable_process_extended
:
logger
.
debug
(
"Extended stats for top process are disabled"
)
...
...
@@ -85,6 +92,13 @@ class GlancesStandalone(object):
def
quiet
(
self
):
return
self
.
_quiet
def
display_modules_list
(
self
):
"""Display modules list"""
print
(
"Plugins list: {}"
.
format
(
', '
.
join
(
sorted
(
self
.
stats
.
getPluginsList
(
enable
=
False
)))))
print
(
"Exporters list: {}"
.
format
(
', '
.
join
(
sorted
(
self
.
stats
.
getExportsList
(
enable
=
False
)))))
def
__serve_forever
(
self
):
"""Main loop for the CLI."""
# Start a counter used to compute the time needed for
...
...
glances/stats.py
浏览文件 @
4f7f6be6
...
...
@@ -87,14 +87,16 @@ class GlancesStats(object):
"""Wrapper to load: plugins and export modules."""
# Init the plugins dict
# Active plugins dictionnary
self
.
_plugins
=
collections
.
defaultdict
(
dict
)
# Load the plugins
self
.
load_plugins
(
args
=
args
)
# Init the export modules dict
# Active exporters dictionnary
self
.
_exports
=
collections
.
defaultdict
(
dict
)
# All available exporters dictionnary
self
.
_exports_all
=
collections
.
defaultdict
(
dict
)
# Load the export modules
self
.
load_exports
(
args
=
args
)
...
...
@@ -102,7 +104,7 @@ class GlancesStats(object):
sys
.
path
=
sys_path
def
_load_plugin
(
self
,
plugin_script
,
args
=
None
,
config
=
None
):
"""Load the plugin (script), init it and add to the _plugin dict"""
"""Load the plugin (script), init it and add to the _plugin dict
.
"""
# The key is the plugin name
# for example, the file glances_xxx.py
# generate self._plugins_list["xxx"] = ...
...
...
@@ -115,6 +117,10 @@ class GlancesStats(object):
self
.
_plugins
[
name
]
=
plugin
.
Plugin
(
args
=
args
,
config
=
config
)
else
:
self
.
_plugins
[
name
]
=
plugin
.
Plugin
(
args
=
args
)
# Set the disable_<name> to False by default
setattr
(
self
.
args
,
'disable_'
+
name
,
getattr
(
self
.
args
,
'disable_'
+
name
,
False
))
except
Exception
as
e
:
# If a plugin can not be log, display a critical message
# on the console but do not crash
...
...
@@ -132,46 +138,69 @@ class GlancesStats(object):
args
=
args
,
config
=
self
.
config
)
# Log plugins list
logger
.
debug
(
"A
vailable plugins list: {}"
.
format
(
self
.
getAllPlugins
()))
logger
.
debug
(
"A
ctive plugins list: {}"
.
format
(
self
.
getPluginsList
()))
def
load_exports
(
self
,
args
=
None
):
"""Load all export modules in the 'exports' folder."""
if
args
is
None
:
return
False
header
=
"glances_"
# Transform the arguments list into a dict
# The aim is to chec if the export module should be loaded
# Build the export module available list
args_var
=
vars
(
locals
()[
'args'
])
for
item
in
os
.
listdir
(
exports_path
):
export_name
=
os
.
path
.
basename
(
item
)[
len
(
header
):
-
3
].
lower
()
if
(
item
.
startswith
(
header
)
and
item
.
endswith
(
".py"
)
and
item
!=
(
header
+
"export.py"
)
and
item
!=
(
header
+
"history.py"
)
and
args_var
[
'export_'
+
export_name
]
is
not
None
and
args_var
[
'export_'
+
export_name
]
is
not
False
):
item
!=
(
header
+
"history.py"
)):
self
.
_exports_all
[
export_name
]
=
os
.
path
.
basename
(
item
)[:
-
3
]
# Set the disable_<name> to False by default
setattr
(
self
.
args
,
'export_'
+
export_name
,
getattr
(
self
.
args
,
'export_'
+
export_name
,
False
))
# Aim is to check if the export module should be loaded
for
export_name
in
self
.
_exports_all
:
if
getattr
(
self
.
args
,
'export_'
+
export_name
,
False
):
# Import the export module
export_module
=
__import__
(
os
.
path
.
basename
(
item
)[:
-
3
])
export_module
=
__import__
(
self
.
_exports_all
[
export_name
])
# Add the export to the dictionary
# The key is the module name
# for example, the file glances_xxx.py
# generate self._exports_list["xxx"] = ...
self
.
_exports
[
export_name
]
=
export_module
.
Export
(
args
=
args
,
config
=
self
.
config
)
self
.
_exports
[
export_name
]
=
export_module
.
Export
(
args
=
args
,
config
=
self
.
config
)
self
.
_exports_all
[
export_name
]
=
self
.
_exports
[
export_name
]
# Log plugins list
logger
.
debug
(
"A
vailable exports modules list: {}"
.
format
(
self
.
getExport
List
()))
logger
.
debug
(
"A
ctive exports modules list: {}"
.
format
(
self
.
getExports
List
()))
return
True
def
getAllPlugins
(
self
,
enable
=
True
):
"""Return the enable plugins list.
if enable is False, return the list of all the plugins"""
def
getPluginsList
(
self
,
enable
=
True
):
"""Return the plugins list.
if enable is True, only return the active plugins (default)
if enable is False, return all the plugins
Return: list of plugin name
"""
if
enable
:
return
[
p
for
p
in
self
.
_plugins
if
self
.
_plugins
[
p
].
is_enable
()]
else
:
return
[
p
for
p
in
self
.
_plugins
]
def
getExportList
(
self
):
"""Return the exports modules list."""
return
[
e
for
e
in
self
.
_exports
]
def
getExportsList
(
self
,
enable
=
True
):
"""Return the exports list.
if enable is True, only return the active exporters (default)
if enable is False, return all the exporters
Return: list of export module name
"""
if
enable
:
return
[
e
for
e
in
self
.
_exports
]
else
:
return
[
e
for
e
in
self
.
_exports_all
]
def
load_limits
(
self
,
config
=
None
):
"""Load the stats limits (except the one in the exclude list)."""
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录