def reportStats(self, stats): pipe = statsd.pipeline() for row in stats: base = 'haproxy.%s.%s.' % (row['pxname'], row['svname']) for key in GAUGES: value = row[key] if value != '': pipe.gauge(base + key, _to_int(value)) for key in COUNTERS: metric = base + key newvalue = row[key] if newvalue == '': continue newvalue = _to_int(newvalue) oldvalue = self.prevdata.get(metric) if oldvalue is not None: value = newvalue - oldvalue pipe.incr(metric, value) self.prevdata[metric] = newvalue pipe.send()
def reportStats(self, stats): pipe = statsd.pipeline() for row in stats: base = 'haproxy.%s.%s.' % (row['pxname'], row['svname']) for key in GAUGES: value = row[key] if value != '': pipe.gauge(base + key, int(value)) for key in COUNTERS: metric = base + key newvalue = row[key] if newvalue == '': continue newvalue = int(newvalue) oldvalue = self.prevdata.get(metric) if oldvalue is not None: value = newvalue - oldvalue pipe.incr(metric, value) self.prevdata[metric] = newvalue pipe.send()
def reportStats(self, stats): pipe = statsd.pipeline() base = 'zk.%s.' % (self.hostname, ) for key in GAUGES: try: value = int(stats.get(key, 0)) pipe.gauge(base + key, value) except Exception: self.log.exception("Unable to process %s", key) for key in COUNTERS: try: newvalue = int(stats.get(key, 0)) oldvalue = self.prevdata.get(key) if oldvalue is not None: value = newvalue - oldvalue pipe.incr(base + key, value) self.prevdata[key] = newvalue except Exception: self.log.exception("Unable to process %s", key) pipe.send()
def report_stats(): with statsd.pipeline() as pipe: for stat, value in get_qshape_stats(): pipe.incr(stat, value)
def report_stats(): with statsd.pipeline() as pipe: for stat, value in get_fpm_stats(FPM_STATUS_URL): pipe.gauge(stat, value)