@@ 87-98 (lines=12) @@ | ||
84 | self.port, |
|
85 | prefix=prefix) |
|
86 | ||
87 | def export(self, name, columns, points): |
|
88 | """Export the stats to the Statsd server.""" |
|
89 | for i in range(len(columns)): |
|
90 | if not isinstance(points[i], Number): |
|
91 | continue |
|
92 | stat_name = '{}.{}'.format(name, columns[i]) |
|
93 | stat_value = points[i] |
|
94 | try: |
|
95 | self.client.gauge(stat_name, stat_value) |
|
96 | except Exception as e: |
|
97 | logger.error("Can not export stats to Statsd (%s)" % e) |
|
98 | logger.debug("Export {} stats to Statsd".format(name)) |
|
99 |
@@ 81-92 (lines=12) @@ | ||
78 | logger.critical("Connection to Riemann failed : %s " % e) |
|
79 | return None |
|
80 | ||
81 | def export(self, name, columns, points): |
|
82 | """Write the points in Riemann.""" |
|
83 | for i in range(len(columns)): |
|
84 | if not isinstance(points[i], Number): |
|
85 | continue |
|
86 | else: |
|
87 | data = {'host': self.hostname, 'service': name + " " + columns[i], 'metric': points[i]} |
|
88 | logger.debug(data) |
|
89 | try: |
|
90 | self.client.send(data) |
|
91 | except Exception as e: |
|
92 | logger.error("Cannot export stats to Riemann (%s)" % e) |
|
93 |
@@ 101-113 (lines=13) @@ | ||
98 | ||
99 | return db |
|
100 | ||
101 | def export(self, name, columns, points): |
|
102 | """Export the stats to the Statsd server.""" |
|
103 | for i in range(len(columns)): |
|
104 | if not isinstance(points[i], Number): |
|
105 | continue |
|
106 | stat_name = '{}.{}.{}'.format(self.prefix, name, columns[i]) |
|
107 | stat_value = points[i] |
|
108 | tags = self.parse_tags(self.tags) |
|
109 | try: |
|
110 | self.client.send(stat_name, stat_value, **tags) |
|
111 | except Exception as e: |
|
112 | logger.error("Can not export stats %s to OpenTSDB (%s)" % (name, e)) |
|
113 | logger.debug("Export {} stats to OpenTSDB".format(name)) |
|
114 | ||
115 | def exit(self): |
|
116 | """Close the OpenTSDB export module.""" |