I have a sony vaio f11 laptop. It’s pretty quick for a laptop, but it also runs pretty hot. (Sony has a bios update that supposedly cools it down a bit – by some reports at the expense of performance – but it only installs under windows, which I’ve no longer got.) Two or three times, during the dog days of summer, it has shut itself down due to heat.
Under /sys/devices/virtual/thermal/thermal_zone*, you can get some information about this. In particular, /sys/devices/virtual/thermal/thermal_zone1/trip_point_1_temp appears to be where the bios decides to work harder to cool down, while trip_point_0_temp is where it shuts down. The former is 94 (degrees Celsius, presumably) while the latter is 98. Unfortunately these are read-only and can’t be changed.
So I decided I should keep closer watch over the actual temperatures (to what end? dunno). My two main window managers are wmii and Unity – I use the two about equally. One great thing about wmii is that the status bar is filled in with a script, so adding the temperatures was trivial. My ‘Action status’ line simply became
while true do if [ $((count % 2)) -eq 0 ]; then t0=$(cat /sys/devices/virtual/thermal/thermal_zone0/temp) t1=$(cat /sys/devices/virtual/thermal/thermal_zone1/temp) t0=$((t0/1000)) t1=$((t1/1000)) fi status $t0 $t1 | wmiir write /rbar/status count=$((count+1)) sleep 1 done
where the function ‘status’ adds some other info like uptime and battery state.
For Unity, I of course wanted a nicely integrated application indicator. So I spent a few minutes on the following python program, which I’m now using. You can find it packaged at ppa:serge-hallyn/indicators.
#!/usr/bin/python # # This program creates an indicator showing the current temp for each # cpu on a sony vaio F11. # # Copyright 2009-2011 Canonical Ltd. # # Authors: Neil Jagdish Patel # Jono Bacon # Serge Hallyn # Used # http://bradmont.net/wp-content/uploads/2011/08/maildir-indicator.py_.txt # as an example. # # This program is free software: you can redistribute it and/or modify it # under the terms of either or both of the following licenses: # # 1) the GNU Lesser General Public License version 3, as published by the # Free Software Foundation; and/or # 2) the GNU Lesser General Public License version 2.1, as published by # the Free Software Foundation. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranties of # MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR # PURPOSE. See the applicable version of the GNU Lesser General Public # License for more details. # # You should have received a copy of both the GNU Lesser General Public # License version 3 and version 2.1 along with this program. If not, see # # import gobject import gtk import appindicator import os import commands CHECK_FREQUENCY = 2 # seconds BAT_DIR="/sys/devices/virtual/thermal/" BAT_FILE="temp" def quit(widget, data=None): gtk.main_quit() def read_file(i, dir): filename = BAT_DIR + dir + '/' + BAT_FILE f=open(filename, 'r') val=f.read() f.close() v = int(val) return "CPU%d: %dC" % (i, v/1000) def update_temps(ind): tempstr = '' i = 0 for d in os.listdir(BAT_DIR): if d[0:12] == "thermal_zone": if i > 0: tempstr += '|' tempstr += read_file(i, d) i += 1 ind.set_label(tempstr) return True if __name__ == "__main__": ind = appindicator.Indicator ("CPUTemp", "ubuntu-logo", appindicator.CATEGORY_SYSTEM_SERVICES) ind.set_status (appindicator.STATUS_ACTIVE) update_temps(ind) ind.set_icon("ubuntu-logo") menu = gtk.Menu() image = gtk.ImageMenuItem(gtk.STOCK_QUIT) image.connect("activate", quit) image.show() menu.append(image) ind.set_menu(menu) gtk.timeout_add(CHECK_FREQUENCY * 1000, update_temps, ind) gtk.main()
Now, when I’m watching a movie on Amazon Prime, I can watch the temperature go to about 80. If compiling while running a VM, I can watch it jump up to perhaps 95 and (before a bead of sweat can start down my forehead) back down into the 80s.