From 2b0d33889a62edd9a1d9099c54975956a5aa2b45 Mon Sep 17 00:00:00 2001 From: nicolargo Date: Sat, 15 Oct 2016 15:57:44 +0200 Subject: [PATCH] ZeroMQ plugin is now compatible with Python3 --- docs/gw/index.rst | 9 +++++---- glances/exports/glances_zeromq.py | 15 +++++++-------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/docs/gw/index.rst b/docs/gw/index.rst index b868863e..fb372ccc 100644 --- a/docs/gw/index.rst +++ b/docs/gw/index.rst @@ -10,10 +10,11 @@ to providing stats to multiple services (see list below). :maxdepth: 2 csv - influxdb cassandra - opentsdb - statsd - rabbitmq elastic + influxdb + opentsdb + rabbitmq riemann + statsd + zeromq diff --git a/glances/exports/glances_zeromq.py b/glances/exports/glances_zeromq.py index 64037626..b8ee760b 100644 --- a/glances/exports/glances_zeromq.py +++ b/glances/exports/glances_zeromq.py @@ -23,14 +23,13 @@ import sys from datetime import datetime import time import json +import zmq +from zmq.utils.strtypes import asbytes -from glances.compat import NoOptionError, NoSectionError +from glances.compat import NoOptionError, NoSectionError, u, b, nativestr from glances.logger import logger from glances.exports.glances_export import GlancesExport -import zmq - - class Export(GlancesExport): """This class manages the ZeroMQ export module.""" @@ -56,7 +55,7 @@ class Export(GlancesExport): try: self.host = self.config.get_value(section, 'host') self.port = self.config.get_value(section, 'port') - self.prefix = self.config.get_value(section, 'prefix') + self.prefix = str(self.config.get_value(section, 'prefix')) except NoSectionError: logger.critical("No ZeroMQ configuration found") return False @@ -106,9 +105,9 @@ class Export(GlancesExport): # - First frame containing the following prefix (STRING) # - Second frame with the Glances plugin name (STRING) # - Third frame with the Glances plugin stats (JSON) - message = [str(self.prefix), - name, - json.dumps(data)] + message = [b(self.prefix), + b(name), + asbytes(json.dumps(data))] # Write data to the ZeroMQ bus # Result can be view: tcp://host:port