Make sure the drive temperatures are added
Need to ensure that we add temperatures for each physical drive we add into the system.
This commit is contained in:
@@ -328,11 +328,6 @@ 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:
|
||||
@@ -340,11 +335,18 @@ class MonitorWindow(QMainWindow):
|
||||
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 )
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user