After a recent thermal scare I started looking into thermal monitoring.  In the process I re-wrote myth_sensors.pl (since it didn&#39;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&#39;d like it to line up the colons) but I&#39;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-&gt;General-&gt;Miscellaneous Settings-&gt;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&#39; 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 &quot;sensors&quot; to<br>
# see a list of everything that&#39;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 &quot;sensors&quot;<br>SensorNames = {&#39;CPU0 Temp      :&#39;:&quot;Core 0:&quot;,<br>
               &#39;CPU1 Temp      :&#39;:&quot;Core 1:&quot;,<br>               &#39;Fan Speed (CPU):&#39;:&quot;CPU:&quot;,<br>               &#39;Fan Speed (Sys):&#39;:&quot;System:&quot;}<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 = {&#39;/dev/sda&#39;:&quot;OS Drive &quot;,<br>              &#39;/dev/sdb&#39;:&quot;Media    &quot;,<br>              &#39;/dev/sdc&#39;:&quot;Backup #1&quot;,<br>
              &#39;/dev/sdd&#39;:&quot;Backup #2&quot;,<br>              &#39;/dev/sd?&#39;:&quot;Your name&quot;}<br><br># You shouldn&#39;t need to modify anything below here.<br><br>print &quot;Current Temperatures and fan speeds:&quot;<br>
(sensors_status,sensors_output) = commands.getstatusoutput(&#39;sensors&#39;)<br>sortedSensorNames = SensorNames.keys()<br>sortedSensorNames.sort()<br>if sensors_status == 0:<br>  for patterns in sortedSensorNames:<br>    sensorPat = re.compile(&#39;^&#39;+SensorNames[patterns]+&#39;\s+\+*(\d{1,4})(\.\d*..C|\<br>
\sRPM)&#39;, re.M)<br>    sensorData = sensorPat.search(sensors_output)<br>    if sensorData:<br>      if re.search(r&#39;RPM&#39;,patterns):<br>        suffix=&quot; RPM&quot;<br>      else:<br>        suffix=&quot;&amp;deg;C&quot;<br>
      print patterns+&quot; &quot;+sensorData.group(1)+suffix<br><br>(hddtemp_status,hddtemp_output) = commands.getstatusoutput(&#39;sudo hddtemp /dev/s\<br>d?&#39;)<br>if hddtemp_status == 0:<br>  driveList = glob.glob(&#39;/dev/sd?&#39;)<br>
  for drive in sorted(driveList):<br>    drivePat  = re.compile(drive+&#39;:.*:\s+(\d{1,3})..C$&#39;, re.M)<br>    driveTemp = drivePat.search(hddtemp_output)<br>    if driveTemp:<br>      if drive in DriveNames:<br>        CurrentDriveName=DriveNames[drive]<br>
      else:<br>        CurrentDriveName=&quot;Unknown  &quot;<br>      print CurrentDriveName+&quot; Temp : &quot;+driveTemp.group(1)+&quot;&amp;deg;C&quot;<br><br></blockquote>