Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
蜕变的菜鸟
glances
提交
4ffad89e
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 搜索 >>
提交
4ffad89e
编写于
7月 30, 2017
作者:
N
nicolargo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
New export plugin: standard and configurable Restfull exporter #1129
上级
23676e1d
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
56 addition
and
6 deletion
+56
-6
NEWS
NEWS
+1
-0
README.rst
README.rst
+2
-2
docs/gw/index.rst
docs/gw/index.rst
+1
-0
docs/gw/restful.rst
docs/gw/restful.rst
+42
-0
docs/man/glances.1
docs/man/glances.1
+1
-1
glances/exports/glances_export.py
glances/exports/glances_export.py
+4
-0
glances/exports/glances_restful.py
glances/exports/glances_restful.py
+5
-3
未找到文件。
NEWS
浏览文件 @
4ffad89e
...
...
@@ -8,6 +8,7 @@ Version NEXT RELEASE
Enhancements and new features:
* [WIP] Refactoring of the WebUI
* New export plugin: standard and configurable Restfull exporter (issue #1129)
Bugs corrected:
...
...
README.rst
浏览文件 @
4ffad89e
...
...
@@ -73,7 +73,7 @@ Optional dependencies:
- ``pysnmp`` (for SNMP support)
- ``pystache`` (for the action script feature)
- ``pyzmq`` (for the ZeroMQ export module)
- ``requests`` (for the Ports
and Cloud plugins
)
- ``requests`` (for the Ports
, Cloud plugins and Restful export module
)
- ``scandir`` (for the Folders plugin) [Only for Python < 3.5]
- ``statsd`` (for the StatsD export module)
- ``wifi`` (for the wifi plugin) [Linux-only]
...
...
@@ -353,7 +353,7 @@ Gateway to other services
Glances can export stats to: ``CSV`` file, ``InfluxDB``, ``Cassandra``, ``CouchDB``,
``OpenTSDB``, ``Prometheus``, ``StatsD``, ``ElasticSearch``, ``RabbitMQ/ActiveMQ``,
``ZeroMQ``, ``Kafka``
and ``Riemann
`` server.
``ZeroMQ``, ``Kafka``
, ``Riemann`` and ``Restful
`` server.
How to contribute ?
===================
...
...
docs/gw/index.rst
浏览文件 @
4ffad89e
...
...
@@ -18,6 +18,7 @@ to providing stats to multiple services (see list below).
opentsdb
prometheus
rabbitmq
restful
riemann
statsd
zeromq
docs/gw/restful.rst
0 → 100644
浏览文件 @
4ffad89e
.. _restful:
Restful
=======
You can export statistics to a ``Restful`` JSON server. All the available stats
will be exported in one big (~15 KB) POST request to the Restful endpoint.
The Restful endpoint should be defined in the Glances configuration file as
following:
.. code-block:: ini
[restful]
# Configuration for the --export-restful option
# Example, export to http://localhost:6789/
host=localhost
port=6789
protocol=http
path=/
URL Syntax:
.. code-block:: ini
http://localhost:6789/
| | | |
| | | path
| | port
| hostname
host
and run Glances with:
.. code-block:: console
$ glances --export-restful
Glances will generate stats as a big JSON dictionary (see example `here`_).
.. _here: https://pastebin.com/7U3vXqvF
docs/man/glances.1
浏览文件 @
4ffad89e
.\" Man page generated from reStructuredText.
.
.TH "GLANCES" "1" "Ju
n 27
, 2017" "2.10.1_DEVELOP" "Glances"
.TH "GLANCES" "1" "Ju
l 30
, 2017" "2.10.1_DEVELOP" "Glances"
.SH NAME
glances \- An eye on your system
.
...
...
glances/exports/glances_export.py
浏览文件 @
4ffad89e
...
...
@@ -23,6 +23,8 @@ I am your father...
...for all Glances exports IF.
"""
import
json
from
glances.compat
import
NoOptionError
,
NoSectionError
,
iteritems
,
iterkeys
from
glances.logger
import
logger
...
...
@@ -182,6 +184,8 @@ class GlancesExport(object):
pre_key
=
''
# Walk through the dict
for
key
,
value
in
iteritems
(
stats
):
if
isinstance
(
value
,
bool
):
value
=
json
.
dumps
(
value
)
if
isinstance
(
value
,
list
):
try
:
value
=
value
[
0
]
...
...
glances/exports/glances_restful.py
浏览文件 @
4ffad89e
...
...
@@ -21,6 +21,7 @@
import
sys
from
glances.compat
import
listkeys
from
glances.logger
import
logger
from
glances.exports.glances_export
import
GlancesExport
...
...
@@ -63,18 +64,19 @@ class Export(GlancesExport):
self
.
port
,
self
.
path
)
logger
.
info
(
"Stats will be exported to the restful
URL:
{}"
.
format
(
url
))
"Stats will be exported to the restful
endpoint
{}"
.
format
(
url
))
return
url
def
export
(
self
,
name
,
columns
,
points
):
"""Export the stats to the Statsd server."""
if
name
in
self
.
buffer
:
if
name
==
self
.
plugins_to_export
()[
0
]
and
self
.
buffer
!=
{}
:
# One complete loop have been done
logger
.
debug
(
"Export stats ({}) to Restful endpoint ({})"
.
format
(
listkeys
(
self
.
buffer
),
self
.
client
))
# Export stats
post
(
self
.
client
,
json
=
self
.
buffer
,
allow_redirects
=
True
)
# Reset buffer
self
.
buffer
=
{}
logger
.
debug
(
"Export stats to Restful endpoint ({})"
.
format
(
self
.
client
))
# Add current stat to the buffer
self
.
buffer
[
name
]
=
dict
(
zip
(
columns
,
points
))
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录