Exemplo n.º 1
0
def update_statsd_gauge(tp_process, tp_type, state_name, count):
    statsd_key = key_pattern % {
        'process': slugify(tp_process),
        'state': slugify(state_name),
        'type': slugify(tp_type),
    }
    print('Calculated %s as %d.' % (statsd_key, count))
    statsd.gauge(
        statsd_key,
        count,
    )
Exemplo n.º 2
0
 def reportStats(self, stats):
     for row in stats:
         base = 'haproxy.%s.%s.' % (row['pxname'], row['svname'])
         for key in GAUGES:
             value = row[key]
             if value != '':
                 statsd.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
                 statsd.incr(metric, value)
             self.prevdata[metric] = newvalue