提交 2b0d3388 编写于 作者: N nicolargo

ZeroMQ plugin is now compatible with Python3

上级 74593f13
......@@ -10,10 +10,11 @@ to providing stats to multiple services (see list below).
:maxdepth: 2
csv
influxdb
cassandra
elastic
influxdb
opentsdb
statsd
rabbitmq
elastic
riemann
statsd
zeromq
......@@ -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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册