[mythtv-users] Tracking temperatures and fan speeds in mythweb status

Harry Devine lifter89 at comcast.net
Wed Sep 23 01:15:35 UTC 2009


Matt Beadon wrote:
> 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.
>
> 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.  ;)
>
> 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
>
> So here it is:
> enjoy,
> Matt
>
>     #!/usr/bin/python
>     #
>     # myth_sensors.py
>     # Retrieves sensors output and formats it for inclusion in the
>     MythTV backend
>     # status page.
>
>     # Prerequisites:
>     #   install: hddtemp +(allow sudo hddtemp), lm-sensors, python n'
>     stuff
>     #   run: sensors-detect
>     #   run: sensors and use that info to update the list of sensors
>     names below.
>
>     import re
>     import glob
>     import commands
>
>     # Set this list of sensors to match what you want to track. Run
>     "sensors" to
>     # see a list of everything that's available on your system.  The
>     left side
>     # of this list is text that will be on the status page and the
>     right is what
>     # needs to match the output of "sensors"
>     SensorNames = {'CPU0 Temp      :':"Core 0:",
>                    'CPU1 Temp      :':"Core 1:",
>                    'Fan Speed (CPU):':"CPU:",
>                    'Fan Speed (Sys):':"System:"}
>
>     # Set the following dictionary to name whatever drives (/dev/sd?)
>     you have in
>     # your system (or else live with the names I use)
>     DriveNames = {'/dev/sda':"OS Drive ",
>                   '/dev/sdb':"Media    ",
>                   '/dev/sdc':"Backup #1",
>                   '/dev/sdd':"Backup #2",
>                   '/dev/sd?':"Your name"}
>
>     # You shouldn't need to modify anything below here.
>
>     print "Current Temperatures and fan speeds:"
>     (sensors_status,sensors_output) = commands.getstatusoutput('sensors')
>     sortedSensorNames = SensorNames.keys()
>     sortedSensorNames.sort()
>     if sensors_status == 0:
>       for patterns in sortedSensorNames:
>         sensorPat =
>     re.compile('^'+SensorNames[patterns]+'\s+\+*(\d{1,4})(\.\d*..C|\
>     \sRPM)', re.M)
>         sensorData = sensorPat.search(sensors_output)
>         if sensorData:
>           if re.search(r'RPM',patterns):
>             suffix=" RPM"
>           else:
>             suffix="°C"
>           print patterns+" "+sensorData.group(1)+suffix
>
>     (hddtemp_status,hddtemp_output) = commands.getstatusoutput('sudo
>     hddtemp /dev/s\
>     d?')
>     if hddtemp_status == 0:
>       driveList = glob.glob('/dev/sd?')
>       for drive in sorted(driveList):
>         drivePat  = re.compile(drive+':.*:\s+(\d{1,3})..C$', re.M)
>         driveTemp = drivePat.search(hddtemp_output)
>         if driveTemp:
>           if drive in DriveNames:
>             CurrentDriveName=DriveNames[drive]
>           else:
>             CurrentDriveName="Unknown  "
>           print CurrentDriveName+" Temp : "+driveTemp.group(1)+"°C"
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> mythtv-users mailing list
> mythtv-users at mythtv.org
> http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-users
>   
I just tried using it but it crashes my mythbackend.  I tailored it for 
my hard drives and CPUs, and it runs from the command line, but when I 
put it into the mythtv-setup section that you mentioned, and go to the 
backend status page on Mythweb, the backend crashes and I eventually get 
some PHP errors.  I didn't go to the System Status page on the frontend 
since I use Mythweb for as much as I can.

Not a big deal I thought I'd mention it.  Its definitely a nice little 
utility.

Harry



More information about the mythtv-users mailing list