def get_temp_sensor(sensor_names, reduce_fn=mean, log=None): """ Get temperature sensor reading from X4xx. """ temps = [] try: for sensor_name in sensor_names: temp_raw = read_thermal_sensor_value(sensor_name, 'in_temp_raw', 'iio', 'name') temp_offset = read_thermal_sensor_value(sensor_name, 'in_temp_offset', 'iio', 'name') temp_scale = read_thermal_sensor_value(sensor_name, 'in_temp_scale', 'iio', 'name') # sysfs-bus-iio linux kernel API reports temp in milli deg C # https://www.kernel.org/doc/Documentation/ABI/testing/sysfs-bus-iio temp_in_deg_c = (temp_raw + temp_offset) * temp_scale / 1000 temps.append(temp_in_deg_c) except ValueError: if log: log.warning("Error when converting temperature value.") temps = [-1] except KeyError: if log: log.warning("Can't read %s temp sensor fron iio sub-system.", str(sensor_name)) temps = [-1] return { 'name': 'temperature', 'type': 'REALNUM', 'unit': 'C', 'value': str(reduce_fn(temps)) }
def get_fan_sensor(self): """ Return a sensor dictionary containing the RPM of the cooling device/fan0 """ self.log.trace("Reading cooling device.") return_val = '-1' try: raw_val = read_thermal_sensor_value('Fan', 'cur_state') return_val = str(raw_val) except ValueError: self.log.warning("Error when converting fan speed value") except KeyError: self.log.warning("Can't read cur_state on Fan") return { 'name': 'cooling fan', 'unit': 'rpm', 'type': 'INTEGER', 'value': return_val }
def get_fan_sensor(self): """ Get cooling device reading of N3xx. In this case the speed of fan 0. """ self.log.trace("Reading fpga cooling device.") return_val = '-1' try: raw_val = read_thermal_sensor_value('ec-fan0', 'cur_state') return_val = str(raw_val) except ValueError: self.log.warning("Error when converting fan speed value") except KeyError: self.log.warning("Can't read cur_state on ec-fan0") return { 'name': 'cooling fan', 'type': 'INTEGER', 'unit': 'rpm', 'value': return_val }
def get_temp_sensor(self): """ Get temperature sensor reading of the N3xx. """ self.log.trace("Reading fpga temperature.") return_val = '-1' try: raw_val = read_thermal_sensor_value('fpga-thermal-zone', 'temp') return_val = str(raw_val / 1000) except ValueError: self.log.warning("Error when converting temperature value") except KeyError: self.log.warning("Can't read temp on fpga-thermal-zone") return { 'name': 'temperature', 'type': 'REALNUM', 'unit': 'C', 'value': return_val }
def get_fan_sensor(self): """ Get cooling device reading of N3xx. In this case the speed of fan 0. """ self.log.trace("Reading FPGA cooling device.") return_val = '-1' try: raw_val = read_thermal_sensor_value('ec-fan0', 'cur_state') return_val = str(raw_val) except ValueError: self.log.warning("Error when converting fan speed value") except KeyError: self.log.warning("Can't read cur_state on ec-fan0") return { 'name': 'cooling fan', 'type': 'INTEGER', 'unit': 'rpm', 'value': return_val }
def get_temp_sensor(self): """ Get temperature sensor reading of the N3xx. """ self.log.trace("Reading FPGA temperature.") return_val = '-1' try: raw_val = read_thermal_sensor_value('fpga-thermal-zone', 'temp') return_val = str(raw_val/1000) except ValueError: self.log.warning("Error when converting temperature value") except KeyError: self.log.warning("Can't read temp on fpga-thermal-zone") return { 'name': 'temperature', 'type': 'REALNUM', 'unit': 'C', 'value': return_val }