Q: Is it possible to read the hardware sensors from the Terminal, without any 3rd party help? A: Yes it is. Q: Mmkay, but how? A: I'm glad yo asked. With ioreg and a few extra utilities, like awk:
ioreg -n IOHWSensor | awk -F "=" '/\"current-value\" = (\d*)|\"location\" = (\d*)/ { print ($2); }'
That will output:
3031040
"HDD BOTTOMSIDE"
3309568
"CPU TOPSIDE"
3440640
"GPU ON DIE"
80033
"CPU CORE"
307429376
"REAR MAIN ENCLOSURE"
1900544
"BATTERY"
As you can see the numbers don't make any sense. And this where the amazing “Mac OS X System Internals” comes in. In chapter 10.7 “A Programming Tour of the I/O Kit's Functionality” (page 1307) we find that the values should be bit shifted right by 16. So here's another example, in Python, with the bit shift applied:
import commands
ioreg = commands.getoutput ('/usr/sbin/ioreg -n IOHWSensor')
k = re.findall ("\"location\" = \"(.*?)\"", ioreg)
v = re.findall ("\"current-value\" = (\d*)", ioreg)
aDict = dict (zip ([lower (el) for el in k], [int (el) >> 16 for el in v]))
Giving us the temps in centigrade:
{'gpu on die': 52, 'battery': 29, 'cpu topside': 49, 'rear main enclosure': 4732, 'cpu core': 1, 'hdd bottomside': 46}
This code also wraps the results in a simple Python dictionary. ‘rear main enclosure’ is obviously the RPM of the only fan this machine has.
Here's the output from running the shell command on a G5:
476
"CPU T-Diode"
107
"CPU Current"
823
"CPU Voltage"
124
"Slots Power"
2097152
"DRIVE BAY"
Many thanks to all the people who helped me piece this one together!