Friday, December 19, 2014

Am I Getting Hot or Cold?

Yes. A post on monitoring your PowerBook's temperatures when running Debian or similar variations of Linux. As mentioned in a previous post, I am a big fan of Conky, which I utilize to show me several pieces of information regarding my PB and other PowerPC systems at any given time. Conky shows me such things as CPU, battery, and memory usage, as well as the capacities of each plus disk space usage across all partitions, up and down network statistics on all interfaces, and top process CPU consumers. I should note that right now, when completely idle with no GUI applications running, Conky states CPU is at 1%, which I see as very ideal. Usually it's Conky taking up a majority of that 1% of CPU.

The only thing I was missing was a way to monitor temperatures that are reported by the machine's included sensors. PowerPC portables have a history of running quite warm. Obtaining this same information in OS X is incredibly easy using a dashboard widget such as iStat Pro. Still being incredibly new to many things Linux and even PowerPC, I had to start doing a little bit of research to see if or where this information could be stored for retrieval. After perusing the different Conky options, I came to the conclusion that the desired information could not be natively retrieved using any existing Conky options as most deal with the (ugh) Intel architecture.  If I'm wrong, please let me know either through the comments belows or via email if you don't feel like publicly shaming me.

One way to start was to run the lsmod command, which would provide me with a list of loaded kernel modules.  One of those sure had to be doing something temperature/fan related?  Well, a few stuck out at me including, ic2-powermac, although it was not being used by anything, but I ran into this module when doing some research online.  The other one in particular was therm_adt746x, but again was not being used by any drivers. I'll be doing some more reading of these modules in the near future.

Luckily, I also discovered a couple of the sensors and output I could retrieve from various files under the /sys/devices/temperatures folder. I simply did a search of the file system using locate temperature. There were only two sensors listed along with a few other configuration files that I have yet to investigate any further.

For each sensor, there were 3 relevant text files (actually 4 for sensor1): sensor[#]_limit, sensor[#]_location, and sensor[#]_temperature. Sensor 1 also included a sensor[#]_fan_speed file. I ran cat on each of the 3 files (again 4 for sensor1), just to obtain some sort of idea of what information it would provide. Here is a quick overview:

  •     fan_speed – provides the current speed of the fans in RPMs
  •     limit – specifies the upper limit of the temperature that the sensor can reach before I assume either you start to have issues or the fans kick in
  •     location - specifies the location that the sensor is monitoring the temperature for
  •     temperature – this file provides a single number, which happens to the latest temperature reading in degrees Celsius (converting this to Fahrenheit should be trivial)
According to the locations, one sensor was for the CPU_BOTTOMSIDE and the other PWR_SUPPLY_BOTTOMSIDE. My understanding (again please correct me if I am wrong) is there should be other additional sensors on the PowerBook that we could pull values from. If there are, I'd love to figure out how to do just that. For example, on the OS X side, when looking at temperatures in iStat Pro, it also provides temperature values for CPU top, battery, trackpad, and HD. Perhaps there is some additional documentation somewhere covering this sort of information?

Great, so how can I customize Conky to pull in these values and output them to the grid of information I have running on my desktop? Well, one of the first ideas that came to mind was using a shell script that essentially grabs the temperatures and fan RPM values from the corresponding files and assigns each to a variable that can then be output by Conky. Perhaps there is an easier way to do this?

Yes there is. Here is where exec object comes in handy. This particular object will let you specify a shell command you'd like to run and output.  If you want to have the command ran at your own set intervals, use the execi command instead, but be aware that the interval value you set must be lower than your configured update_interval (mine is set to 1.0 second) for Conky.  So for each sensor I added the following line:

Bottom CPU Temperature: ${exec cat /sys/devices/temperatures/sensor1_temperature}

Battery Temperature: ${exec cat /sys/devices/temperatures/sensor2_temperature} 

According to the man pages for Conky, running shell commands within Conky tends to be more resource intensive.  Personally, I have seen a small average of about a 1% increase in CPU consumption, but that could be to other configuration changes I've made recently to the PB.  These two additional lines in my Conky configuration file worked and do as they are intended, so in some ways a success.  Here's a screenshot:


One last thing I would like to share about Conky.  If you want to disable any sort of flickering Conky may be experiencing, add double_buffer yes to your list of options. Makes everything look like it is running much smoother. I was going to post a link to my conky.conf file somewhere, but decided if somebody was interested in taking a look at it, I send it to them via email.

I know I've barely scratched the surface on how all of these sensors work, but it's a start. One thing I haven't quite figured out is how often the temperatures are being updated in those specific files, so the quest for answers and understanding continue!

Hopefully you enjoyed this post and can use it as a starting pointing for doing your own temperature/fan speed monitoring on your PowerPC machine(s) or even as a gateway to other great ideas for information that can be displayed by Conky. 

I still have yet to finish the post on my PowerBook 1400CS (waiting on a few more parts) as well as the introduction to Clang on PowerPC. The latter is a post I am taking extra care to refine before I put it out there in the wild.

No comments:

Post a Comment