mirror of
https://github.com/nicolargo/glances.git
synced 2024-11-30 12:02:49 +03:00
Add MQTT hostname configuration
added the possibility of configuring the hostname of the MQTT topic
This commit is contained in:
parent
c591461fde
commit
ff5b181d6c
1
docker-compose/glances.conf
Normal file → Executable file
1
docker-compose/glances.conf
Normal file → Executable file
@ -595,6 +595,7 @@ queue=glances_queue
|
||||
# Configuration for the --export mqtt option
|
||||
host=localhost
|
||||
port=8883
|
||||
hostname=NONE
|
||||
tls=false
|
||||
user=guest
|
||||
password=guest
|
||||
|
8
glances/exports/mqtt/__init__.py
Normal file → Executable file
8
glances/exports/mqtt/__init__.py
Normal file → Executable file
@ -38,13 +38,17 @@ class Export(GlancesExport):
|
||||
|
||||
# Load the MQTT configuration file
|
||||
self.export_enable = self.load_conf(
|
||||
'mqtt', mandatories=['host', 'password'], options=['port', 'user', 'topic', 'tls', 'topic_structure']
|
||||
'mqtt', mandatories=['host', 'password'], options=['port', 'user', 'hostname', 'topic', 'tls', 'topic_structure']
|
||||
)
|
||||
if not self.export_enable:
|
||||
exit('Missing MQTT config')
|
||||
|
||||
# Get the current hostname
|
||||
self.hostname = socket.gethostname()
|
||||
self.hostname = (self.hostname or socket.gethostname())
|
||||
if self.hostname in ['NONE']:
|
||||
self.hostname = socket.gethostname()
|
||||
else:
|
||||
self.hostname = self.hostname
|
||||
self.port = int(self.port) or 8883
|
||||
self.topic = self.topic or 'glances'
|
||||
self.user = self.user or 'glances'
|
||||
|
Loading…
Reference in New Issue
Block a user