mirror of
https://github.com/nicolargo/glances.git
synced 2026-03-13 03:17:12 -04:00
Improve error message when MQTT error occures
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user