def collect(self):
        metrics = {}
        raw = {}

        data = self.getData()

        data = data.split('\n\x00')
        for d in data:
            matches = re.search("([A-Z]+)\s+:\s+(.*)$", d)
            if matches:
                value = matches.group(2).strip()
                raw[matches.group(1)] = matches.group(2).strip()
                vmatch = re.search("([0-9.]+)", value)
                if not vmatch:
                    continue
                try:
                    value = float(vmatch.group(1))
                except __HOLE__:
                    continue
                metrics[matches.group(1)] = value

        for metric in self.config['metrics']:
            if metric not in metrics:
                continue

            metric_name = "%s.%s" % (raw['UPSNAME'], metric)

            value = metrics[metric]

            if metric in ['TONBATT', 'CUMONBATT', 'NUMXFERS']:
                value = self.derivative(metric_name, metrics[metric])

            self.publish(metric_name, value)

        return True
dataset/ETHPy150Open BrightcoveOS/Diamond/src/collectors/apcupsd/apcupsd.py/ApcupsdCollector.collect