<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def collect(self):
 """ Collect and publish disk temperatures """

        instances = {}

        # Support disks such as /dev/(sd.*)
        for device in os.listdir('/dev/'):
            instances.update(self.match_device(device, '/dev/'))

        # Support disk by id such as /dev/disk/by-id/wwn-(.*)
        for device_id in os.listdir('/dev/disk/by-id/'):
            instances.update(self.match_device(device, '/dev/disk/by-id/'))

        metrics = {}
        for device, p in instances.items():
            output = p.communicate()[0].strip()

            try:
                metrics[device + ".Temperature"] = float(output)
            except:
                self.log.warn('Disk temperature retrieval failed on ' + device)

        for metric in metrics.keys():
            self.publish(metric, metrics[metric])