diff options
Diffstat (limited to 'glances/exports')
-rw-r--r-- | glances/exports/glances_export.py | 8 | ||||
-rw-r--r-- | glances/exports/glances_statsd.py | 18 |
2 files changed, 20 insertions, 6 deletions
diff --git a/glances/exports/glances_export.py b/glances/exports/glances_export.py index e47f773b..b402ea2e 100644 --- a/glances/exports/glances_export.py +++ b/glances/exports/glances_export.py @@ -122,9 +122,9 @@ class GlancesExport(object): def parse_tags(self, tags): """Parse tags into a dict. - tags: a comma separated list of 'key:value' pairs. + input tags: a comma separated list of 'key:value' pairs. Example: foo:bar,spam:eggs - dtags: a dict of tags. + output dtags: a dict of tags. Example: {'foo': 'bar', 'spam': 'eggs'} """ dtags = {} @@ -158,7 +158,9 @@ class GlancesExport(object): if isinstance(all_stats[plugin], dict): all_stats[plugin].update(all_limits[plugin]) elif isinstance(all_stats[plugin], list): - all_stats[plugin] += all_limits[plugin] + # TypeError: string indices must be integers (Network plugin) #1054 + for i in all_stats[plugin]: + i.update(all_limits[plugin]) else: continue export_names, export_values = self.__build_export(all_stats[plugin]) diff --git a/glances/exports/glances_statsd.py b/glances/exports/glances_statsd.py index db7628a0..4ab88e9c 100644 --- a/glances/exports/glances_statsd.py +++ b/glances/exports/glances_statsd.py @@ -57,7 +57,7 @@ class Export(GlancesExport): # Init the Statsd client self.client = self.init() - def init(self, prefix='glances'): + def init(self): """Init the connection to the Statsd server.""" if not self.export_enable: return None @@ -66,7 +66,7 @@ class Export(GlancesExport): self.port)) return StatsClient(self.host, int(self.port), - prefix=prefix) + prefix=self.prefix) def export(self, name, columns, points): """Export the stats to the Statsd server.""" @@ -76,7 +76,19 @@ class Export(GlancesExport): stat_name = '{}.{}'.format(name, columns[i]) stat_value = points[i] try: - self.client.gauge(stat_name, stat_value) + self.client.gauge(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(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 |