Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import diamond.collector
- import urllib2
- import json
- class EasyBidderCollector(diamond.collector.Collector):
- # class EasyBidderCollector(object):
- url="http://localhost:8082/status"
- data = ""
- def get_info(self):
- r = urllib2.urlopen(self.url)
- self.data = json.load(r)
- return self.data
- def collect(self):
- self.get_info()
- metric_prefix = "easybidder."
- metrics = self.data['counters']
- for key,value in metrics.iteritems():
- metric_name = "%s%s" % (metric_prefix,key)
- self.publish(metric_name,value)
- if __name__ == "__main__":
- e = EasyBidderCollector()
- print e.get_info()
- e.collect()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement