When you have lm-sensors installed on Linux, you can invoke sensors to list all detected sensors and their states. While it is generally of mild interest except when you suspect that something’s wrong with your box—or, more precisely, when you want to make sure something doesn’t go wrong.
Amongst the sensors, there are temperature sensors that gives you information about the chipset and CPU. You can also find out about fan speeds. So I wondered if could use the sensors to see if there’s a significant difference between when the computer is idle and when I am using it. I thought I could, maybe, also see temperature differences between day and night.
First, Let’s write a (Bash) script to get the raw data—science loves raw data.
#!/usr/bin/env bash # monitors temperature, fan speed, and # CPU speed # while [ 1 ] do echo $(sensors \ | grep : \ | grep -i 'side\|core \|fan2' \ | cut -d: -f 2 \ | sed s/^\ *// \ | cut -d\ -f 1 \ | sed s/[^0-9\.]//g \ ) \ $(grep MHz /proc/cpuinfo | cut -d: -f 2 | sed s/\\.[0-9]*// ) \ $(date) sleep 1 done
The script invokes sensors and inspects /proc/cpuinfo to get the info. The first part of the echo gets the info for the core temperature and the fan speed (the machine I was interested in had 4 cores and one detected fan (oddly “fan2″)), cuts at ‘:’ and then does some sed to clean up leading white-spaces. The second part gets the speed of each cores/threads. I had in mind, later, to check how speed changes overtime even when the computer is idle.
The data is noisy (I can’t seem to be able to get anything but integer temperatures from the sensors on that machine):
The (horizontal) scale is seconds, and as there are 86400 seconds in a day, ticks are placed at midnight, every day. We can smooth it a bit (with a moving average, mostly for display purposes):
We see that that on the first day, in late evening, the temperature rose quite a bit. Indeed, I was preparing an assignments for my students, and I ran editor, compiler, and test suite, but a a leisury pace. No long, CPU-intensive, tasks. Editing, compiling, some testing. The rise is unmistakable, but it’s only a few °C.
If we look at all the data I collected (12 days):
Indeed, we see, except for a few days were I used the computer most of day (or when not at all), we see the same pattern reappear on most evenings. On days 1, 4, 5, and 10, I did work evenings, and days 6 and 7 most of the day. So it seems that you can tell whether or not the computer is in use (even just editing) just by the local temperature difference in the time series. The main problem is that it is not referenced relative to the room temperature.
For example, on day 8 and 9, I did not really use the computer, but you see that the temperature rose somewhat during day to fall back during night. That is, I think, the daily variation in temperature, but I can’t factor it out as such because I would need a fifth sensor, room temperature. While there are other sensors (SYSTIN, etc.), none correlates strongly with the actual room temperature, as measured by an IR thermometer. With an accurate measure of room temperature, we could factor out for sure the effect of daily temperature variations.
So this is only partial results—or hardly any results at all—and a work in progress. For one thing, we can see that the sensors aren’t that reliable: the yellow line is core2, which, on my machine, is constantly much cooler than the other cores, even when under load, for no obvious reasons. Other machines I have do not exhibit this bias. Other sensors (SYSTIN, AUXTIN) are just… constant. When I set to do this experiment, I expected to see sine-like variations on all idle days; but some are quite constant (day 2, for one thing) some do exhibit some variations; but more importantly, not all cores show the same temperature variations—as I said, the sensors aren’t reliable.