mirror of https://github.com/nicolargo/glances
Connection to MQTT server failed : getaddrinfo() argument 2 must be integer or string #1450
parent
6f5ea9592d
commit
2030adf58a
|
@ -413,6 +413,7 @@ port=8883
|
|||
user=guest
|
||||
password=guest
|
||||
topic=glances
|
||||
tls=true
|
||||
|
||||
[couchdb]
|
||||
# Configuration for the --export couchdb option
|
||||
|
|
|
@ -42,20 +42,22 @@ class Export(GlancesExport):
|
|||
self.user = None
|
||||
self.password = None
|
||||
self.topic = None
|
||||
self.tls = 'true'
|
||||
|
||||
# Load the MQTT configuration file
|
||||
self.export_enable = self.load_conf('mqtt',
|
||||
mandatories=['host', 'password'],
|
||||
options=['port', 'user', 'topic'])
|
||||
options=['port', 'user', 'topic', 'tls'])
|
||||
if not self.export_enable:
|
||||
exit('Missing MQTT config')
|
||||
|
||||
# Get the current hostname
|
||||
self.hostname = socket.gethostname()
|
||||
|
||||
self.port = self.port or 8883
|
||||
self.port = int(self.port) or 8883
|
||||
self.topic = self.topic or 'glances'
|
||||
self.user = self.user or 'glances'
|
||||
self.tls = (self.tls.lower() == 'true')
|
||||
|
||||
# Init the MQTT client
|
||||
self.client = self.init()
|
||||
|
@ -69,6 +71,7 @@ class Export(GlancesExport):
|
|||
clean_session=False)
|
||||
client.username_pw_set(username=self.user,
|
||||
password=self.password)
|
||||
if self.tls:
|
||||
client.tls_set(certs.where())
|
||||
client.connect(host=self.host,
|
||||
port=self.port)
|
||||
|
|
Loading…
Reference in New Issue