diff --git a/glances/glances.py b/glances/glances.py index a78278bf..47ddb196 100755 --- a/glances/glances.py +++ b/glances/glances.py @@ -726,7 +726,7 @@ class glancesGrabHDDTemp: if self.initok: data = "" - # Taking care of a possible subtle death of hddtemp + # Taking care of sudden deaths/stops of hddtemp daemon try: sck = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sck.connect((self.address, self.port)) @@ -746,11 +746,18 @@ class glancesGrabHDDTemp: else: data = self.cache self.cache = data - for line in data.split("\n"): + fields = data.split("|") + devices = (len(fields) - 1) / 5 + for i in range(0, devices): + offset = i * 5 hddtemp_current = {} - fields = line.split('|') - hddtemp_current['label'] = fields[1].split("/")[-1] - hddtemp_current['value'] = int(fields[3]) + temperature = fields[offset + 3] + if temperature == "ERR": + hddtemp_current['label'] = "hddtemp error" + hddtemp_current['value'] = 0 + else: + hddtemp_current['label'] = fields[offset + 1].split("/")[-1] + hddtemp_current['value'] = int(temperature) self.hddtemp_list.append(hddtemp_current) def get(self):