def collect(self):
        try:
            response = urllib2.urlopen("http://%s:%s/dashboard/stats" % (
                self.config['host'], int(self.config['port'])))
        except Exception, e:
            self.log.error('Couldnt connect to sidekiq-web: %s', e)
            return {}

        try:
            j = json.loads(response.read())
        except Exception, e:
            self.log.error('Couldnt parse json: %s', e)
            return {}

        for k in j:
            for item, value in j[k].items():

                if isinstance(value, (str, unicode)) and 'M' in value:
                    value = float(value.replace('M', ''))
                    for unit in self.config['byte_unit']:
                        unit_value = diamond.convertor.binary.convert(
                            value=value,
                            oldUnit='megabyte',
                            newUnit=unit)

                        self.publish("%s.%s_%s" % (k, item, unit), unit_value)
                else:
                    self.publish("%s.%s" % (k, item), value)
dataset/ETHPy150Open BrightcoveOS/Diamond/src/collectors/sidekiqweb/sidekiqweb.py/SidekiqWebCollector.collect/original