Prevent exporting empty data to InfluxDB

pull/1558/head
nicolargo 2019-11-09 10:20:23 +01:00
parent 4be7c630a1
commit 2c34d463c9
1 changed files with 8 additions and 6 deletions

View File

@ -126,10 +126,12 @@ class Export(GlancesExport):
if self.prefix is not None:
name = self.prefix + '.' + name
# Write input to the InfluxDB database
try:
self.client.write_points(self._normalize(name, columns, points))
except Exception as e:
logger.error("Cannot export {} stats to InfluxDB ({})".format(name,
e))
if len(points) == 0:
logger.debug("Cannot export empty {} stats to InfluxDB".format(name))
else:
logger.debug("Export {} stats to InfluxDB".format(name))
try:
self.client.write_points(self._normalize(name, columns, points))
except Exception as e:
logger.error("Cannot export {} stats to InfluxDB ({})".format(name, e))
else:
logger.debug("Export {} stats to InfluxDB".format(name))