提交 36c2f7d8 编写于 作者: K Katyucha

Update for python3. Need package python3-pika

上级 26bea1ac
......@@ -159,6 +159,8 @@ Command-Line Options
export stats to an InfluxDB server
--export-statsd
export stats to a Statsd server
--export-rabbitmq
export stats to a RabbitMQ server
-c CLIENT, --client CLIENT
connect to a Glances server by IPv4/IPv6 address or
hostname
......@@ -824,6 +826,25 @@ Glances will generate stats as:
'glances.load.min1': 0.19,
...
*RabbitMQ*
You can export statistics to an RabbitMQ server (AMQP Broker). The connection should be defined in the Glances configuration file as following:
.. code-block::
[rabbitmq]
host=localhost
port=5672
user=glances
password=glances
queue=glances_queue
and run Glances with:
.. code-block:: console
$ glances --export-rabbitmq
APIs Documentations
===================
......
......@@ -25,7 +25,10 @@ from numbers import Number
# Import Glances lib
from glances.core.glances_logging import logger
from configparser import NoSectionError, NoOptionError
try:
from configparser import NoOptionError, NoSectionError
except ImportError: # Python 2
from ConfigParser import NoOptionError, NoSectionError
from glances.exports.glances_export import GlancesExport
# Import pika for RabbitMQ
......@@ -78,13 +81,14 @@ class Export(GlancesExport):
"""Init the connection to the rabbitmq server"""
if not self.export_enable:
return None
sparameters = "amqp://"+self.rabbitmq_user+":"+self.rabbitmq_password+"@"+self.rabbitmq_host+":"+self.rabbitmq_port+"/"
try:
parameters = pika.URLParameters("amqp://"+self.rabbitmq_user+":"+self.rabbitmq_password+"@"+self.rabbitmq_host+":"+self.rabbitmq_port+"/")
parameters = pika.URLParameters(sparameters)
connection = pika.BlockingConnection(parameters)
channel = connection.channel()
return channel
except Exception as e:
logger.critical("Connection to rabbitMQ failed : %s" % e)
logger.critical("Connection to rabbitMQ failed : %s " % e)
return None
def export(self, name, columns, points):
......
......@@ -80,6 +80,9 @@ export stats to an InfluxDB server
.B \-\-export-statsd
export stats to a Statsd server
.TP
.B \-\-export-rabbitmq
export stats to a RabbitMQ server
.TP
.B \-s, \-\-server
run Glances in server mode
.TP
......@@ -234,6 +237,9 @@ Monitor local machine and export stats to a CSV file (standalone mode):
Monitor local machine and export stats to a InfluxDB server with 5s refresh time (standalone mode):
.B $ glances -t 5 --export-influxdb
.PP
Monitor local machine and export stats to a RabbitMQ server with 5s refresh time (standalone mode):
.B $ glances -t 5 --export-rabbitmq
.PP
Start a Glances server (server mode):
.B $ glances -s
.PP
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册