mirror of
https://github.com/nicolargo/glances.git
synced 2024-12-28 11:41:46 +03:00
Update for python3. Need package python3-pika
This commit is contained in:
parent
26bea1ac91
commit
36c2f7d8c9
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user