diff --git a/monitor/oneUpMon.py b/monitor/oneUpMon.py index 9d3cdf4..2c7df31 100755 --- a/monitor/oneUpMon.py +++ b/monitor/oneUpMon.py @@ -328,23 +328,25 @@ class MonitorWindow(QMainWindow): exception, so everything needs to be wrapped in a handler. ''' - # Obtain the CPU temperature - try: - cpu_c = float(sysdata.CPUTemperature) - except Exception: - cpu_c = None - + # Obtain the current fan speed try: fan_speed = sysdata.fanSpeed except Exception: fan_speed = None + temperatures = [] + try: + temperatures.append( float(sysdata.CPUTemperature) ) + except Exception: + temperatures.append( 0.0 ) + # Obtain the NVMe device temperature try: - nvme_c = sysdata.driveTemp + for _drive in multiDrive.drives: + temperatures.append( multiDrive.driveTemp( _drive ) ) except Exception: - nvme_c = None + temperatures = [ 0.0 for _ in multiDrive.drives ] # Obtain the NVMe Device read and write rates try: @@ -364,7 +366,7 @@ class MonitorWindow(QMainWindow): values = [ None for name in cpuload.cpuNames ] # Append to charts - self.cpu_chart.append([cpu_c,nvme_c]) + self.cpu_chart.append( temperatures ) self.fan_chart.append([fan_speed]) self.io_chart.append( rwData ) self.use_chart.append( values ) diff --git a/monitor/systemsupport.py b/monitor/systemsupport.py index 390d5ca..b42c377 100755 --- a/monitor/systemsupport.py +++ b/monitor/systemsupport.py @@ -191,6 +191,32 @@ class multiDriveStat(): except: return 0 + def driveTemp(self,_drive) -> float: + smartOutRaw = "" + cmd = f'sudo smartctl -A /dev/{_drive}' + try: + command = os.popen( cmd ) + smartOutRaw = command.read() + except Exception as error: + print( f"Could not launch {cmd} error is {error}" ) + return 0.0 + finally: + command.close() + + smartOut = [ l for l in smartOutRaw.split('\n') if l] + for smartAttr in ["Temperature:","194","190"]: + try: + line = [l for l in smartOut if l.startswith(smartAttr)][0] + parts = [p for p in line.replace('\t',' ').split(' ') if p] + if smartAttr == "Temperature:": + return float(parts[1]) + else: + return float(parts[0]) + except IndexError: + pass + + return float(0.0) + def readWriteSectors( self )-> dict[str,tuple[int,int]]: ''' Obtain the number of sectors read and written since the last