Some FS and LAN metrics fail to export correctly to StatsD (issue #1068)

This commit is contained in:
nicolargo 2017-04-01 21:37:54 +02:00
parent 201d6ddb00
commit 20f814a03c
2 changed files with 15 additions and 1 deletions

3
NEWS
View File

@ -5,7 +5,10 @@ Glances Version 2
Version 2.9.2
=============
Bugs corrected:
* StatsD export prefix option is ignored (issue #1074)
* Some FS and LAN metrics fail to export correctly to StatsD (issue #1068)
Version 2.9.1
=============

View File

@ -76,7 +76,18 @@ class Export(GlancesExport):
stat_name = '{}.{}'.format(name, columns[i])
stat_value = points[i]
try:
self.client.gauge(stat_name, stat_value)
self.client.gauge(self._normalize(stat_name),
stat_value)
except Exception as e:
logger.error("Can not export stats to Statsd (%s)" % e)
logger.debug("Export {} stats to Statsd".format(name))
def _normalize(self, name):
"""Normalize name for the Statsd convention"""
# Name should not contain some specials chars (issue #1068)
ret = name.replace(':', '')
ret = ret.replace('%', '')
ret = ret.replace(' ', '_')
return ret