Merge branch 'develop' into issue1446

This commit is contained in:
nicolargo 2019-03-31 16:59:31 +02:00
commit 20ca58d5a4
4 changed files with 46 additions and 51 deletions

2
NEWS
View File

@ -15,6 +15,8 @@ Bugs corrected:
* Fix Cassandra table name export #1402
* 500 Internal Server Error /api/3/network/interface_name #1401
* Connection to MQTT server failed : getaddrinfo() argument 2 must be integer or string #1450
* `l` keypress (hide alert log) not working after some time #1449
Others:

View File

@ -413,6 +413,7 @@ port=8883
user=guest
password=guest
topic=glances
tls=true
[couchdb]
# Configuration for the --export couchdb option

View File

@ -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)

View File

@ -114,22 +114,12 @@ class Plugin(GlancesPlugin):
ret = []
# Only process if display plugin enable...
if not self.stats and self.is_disable():
if not self.stats or self.is_disable():
return ret
# Build the string message
# Header
ret.append(self.curse_add_line(global_message(), "TITLE"))
if self.stats:
# Header
# msg = 'Warning or critical alerts'
# ret.append(self.curse_add_line(msg, "TITLE"))
# logs_len = glances_events.len()
# if logs_len > 1:
# msg = ' (last {} entries)'.format(logs_len)
# else:
# msg = ' (one entry)'
# ret.append(self.curse_add_line(msg, "TITLE"))
# Loop over alerts
for alert in self.stats:
# New line
@ -166,7 +156,6 @@ class Plugin(GlancesPlugin):
if top_process != '':
msg = ': {}'.format(top_process)
ret.append(self.curse_add_line(msg))
# logger.info(alert)
return ret