6/5/08

Suse Linux View CPU speed and Hard disk/CPU temperature

I have a laptop which sometime goes really hot and I wanted a simple way to be able to view CPU and Hard disk temperature. I' m on SUSE 10.3 and I tried installing LM-sensors but no sensors were detected. After a very little search I found that you can view the CPU speed by using the cpufrequtils so I installed the package using Yast and executed cpufreq-info.
Here is the output:

cpufrequtils 002: cpufreq-info (C) Dominik Brodowski 2004-2006
Report errors and bugs to http://bugs.opensuse.org, please.
analyzing CPU 0:
driver: acpi-cpufreq
CPUs which need to switch frequency at the same time: 0
hardware limits: 798 MHz - 2.00 GHz
available frequency steps: 2.00 GHz, 1.60 GHz, 1.33 GHz, 1.06 GHz, 798 MHz
available cpufreq governors: conservative, userspace, powersave, ondemand, performance
current policy: frequency should be within 798 MHz and 2.00 GHz.
The governor "ondemand" may decide which speed to use
within this range.
current CPU frequency is 798 MHz (asserted by call to hardware).

I was a little excited but I wanted to view the CPU and the hard disk temperature too.
I found that I could see CPU temperature with the command:

cat /proc/acpi/thermal_zone/THRM/temperature

and the hard disk temperature (and some other stuff if you don't use grep) with

smartctl -d ata -A /dev/sda3 | grep -i temperature

where sda3 is my hard disk partition where linux are installed but actually it doesn't matter. ( I think :-P)

Now we know the commands and we have the tools we need.
But hold on a second, Can't we make it better?
Of course we can, we are talking about computers here!
So I wrote this simple shell script

cpufreq-info |
grep -i "current CPU frequency";
cat /proc/acpi/thermal_zone/THRM/temperature |
awk '{ printf(" CPU Temperature\t= " $2"\n") }';
smartctl -d ata -A /dev/sda3 |
grep -i temperature |
awk '{ printf(" Hard disk Temperature = " $10"\n") }'

and saved it in a file named temperature.
I gave it execution permission using
chmod +x temperature
and I was able to see the CPU speed and temperature and the Hard disk temperature too
by using
./temperature
and that's it.
This is my output.

blablabla/Temperature # ./temperature
current CPU frequency is 798 MHz (asserted by call to hardware).
CPU Temperature = 51
Hard disk Temperature = 54

blablabla/Temperature #

Yeap, a little hot, but it can be hotter so it's ok... :-P
After that I wrote a little C code to have the script executed
from a program but I will explain it in another post very soon!

I hope this work for you too.
Thank you all for visiting,reading and posting your comments.

2 comments:

Spencer said...

OK, So I'm a bit confused.

When I cat /proc/acpi/thermal_zone/THM0/temperature I consistantly get 8C.

But that seems WAY too cold for the CPU. I mean even the intake air is more than 8C.

Am I doing something wrong?

Anonymous said...

cat /proc/acpi/thermal_zone/THRM/temperature |
awk '{ printf(" CPU Temperature\t= " $2"\n") }';

this two command are used to show the CPU temperature. You are absolutely right, 8C is very low.
I believe there is something wrong with ACPI on your pc.