Improve error message when MQTT error occures

This commit is contained in:
nicolargo
2022-07-15 11:42:20 +02:00
parent b2052414b6
commit cea2e777ef
2 changed files with 3 additions and 4 deletions

View File

@@ -547,7 +547,7 @@ queue=glances_queue
# Configuration for the --export mqtt option
host=localhost
port=1883
tls=true
tls=false
user=guest
password=guest
topic=glances

View File

@@ -45,7 +45,6 @@ class Export(GlancesExport):
# Get the current hostname
self.hostname = socket.gethostname()
self.port = int(self.port) or 8883
self.topic = self.topic or 'glances'
self.user = self.user or 'glances'
@@ -59,7 +58,7 @@ class Export(GlancesExport):
# Init the MQTT client
self.client = self.init()
if not self.client:
exit('MQTT client initialization failed')
exit("MQTT client initialization failed")
def init(self):
"""Init the connection to the MQTT server."""
@@ -74,7 +73,7 @@ class Export(GlancesExport):
client.loop_start()
return client
except Exception as e:
logger.critical("Connection to MQTT server failed : %s " % e)
logger.critical("Connection to MQTT server %s:%s failed with error: %s " % (self.host, self.port, e))
return None
def export(self, name, columns, points):