After a recent thermal scare I started looking into thermal monitoring. In the process I re-wrote myth_sensors.pl (since it didn't work on my system) as myth_sensors.py. As much as anything it was an exercise in learning python but I figured with a few comments it could be useful to other people.<br>
<br>It could use some html formatting in the output (in particular I'd like it to line up the colons) but I'll leave that as a homework exercise. ;)<br><br>To use this script check the prerequisites below, drop it someplace on your system, and add the path in mythtv-setup->General->Miscellaneous Settings->Miscellaneous Status Application<br>
<br>So here it is: <br>enjoy,<br>Matt<br><br><blockquote style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;" class="gmail_quote">#!/usr/bin/python<br>#<br># myth_sensors.py<br>
# Retrieves sensors output and formats it for inclusion in the MythTV backend<br># status page.<br><br># Prerequisites:<br># install: hddtemp +(allow sudo hddtemp), lm-sensors, python n' stuff<br># run: sensors-detect<br>
# run: sensors and use that info to update the list of sensors names below.<br><br>import re<br>import glob<br>import commands<br><br># Set this list of sensors to match what you want to track. Run "sensors" to<br>
# see a list of everything that's available on your system. The left side<br># of this list is text that will be on the status page and the right is what<br># needs to match the output of "sensors"<br>SensorNames = {'CPU0 Temp :':"Core 0:",<br>
'CPU1 Temp :':"Core 1:",<br> 'Fan Speed (CPU):':"CPU:",<br> 'Fan Speed (Sys):':"System:"}<br><br># Set the following dictionary to name whatever drives (/dev/sd?) you have in<br>
# your system (or else live with the names I use)<br>DriveNames = {'/dev/sda':"OS Drive ",<br> '/dev/sdb':"Media ",<br> '/dev/sdc':"Backup #1",<br>
'/dev/sdd':"Backup #2",<br> '/dev/sd?':"Your name"}<br><br># You shouldn't need to modify anything below here.<br><br>print "Current Temperatures and fan speeds:"<br>
(sensors_status,sensors_output) = commands.getstatusoutput('sensors')<br>sortedSensorNames = SensorNames.keys()<br>sortedSensorNames.sort()<br>if sensors_status == 0:<br> for patterns in sortedSensorNames:<br> sensorPat = re.compile('^'+SensorNames[patterns]+'\s+\+*(\d{1,4})(\.\d*..C|\<br>
\sRPM)', re.M)<br> sensorData = sensorPat.search(sensors_output)<br> if sensorData:<br> if re.search(r'RPM',patterns):<br> suffix=" RPM"<br> else:<br> suffix="&deg;C"<br>
print patterns+" "+sensorData.group(1)+suffix<br><br>(hddtemp_status,hddtemp_output) = commands.getstatusoutput('sudo hddtemp /dev/s\<br>d?')<br>if hddtemp_status == 0:<br> driveList = glob.glob('/dev/sd?')<br>
for drive in sorted(driveList):<br> drivePat = re.compile(drive+':.*:\s+(\d{1,3})..C$', re.M)<br> driveTemp = drivePat.search(hddtemp_output)<br> if driveTemp:<br> if drive in DriveNames:<br> CurrentDriveName=DriveNames[drive]<br>
else:<br> CurrentDriveName="Unknown "<br> print CurrentDriveName+" Temp : "+driveTemp.group(1)+"&deg;C"<br><br></blockquote>