LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-17-2009, 01:27 PM   #1
Aztral
LQ Newbie
 
Registered: Jul 2009
Posts: 18

Rep: Reputation: 0
Determining cpu temperature


I'm writing a program that will determine my current cpu temperature. As I understand it, in order to do this I need to know the chip and sensor on my motherboard. I believe I have determined this through sensor-detect; I have an 'Intel Core family thermal sensor' chip. So basically my question is now what? I'm not sure how I would go about using this information in c or c++ using Kubuntu linux.

Thanks a lot for any info.
 
Old 07-17-2009, 02:19 PM   #2
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Hello Aztral

Try lmsensors, either calling its library functions directly or via output from its sensors program.

The raw temperature data provided may need scaling. There's some information about this at http://www.lm-sensors.org/ and some motherboard-specific configuration files at http://khali.linux-fr.org/devel/lm-sensors/. The gkrellm man page is helpful, too.

You probably have access to both CPU casing and CPU core temperatures; the latter are more accurate.

Best

Charles
 
Old 07-17-2009, 02:27 PM   #3
Aztral
LQ Newbie
 
Registered: Jul 2009
Posts: 18

Original Poster
Rep: Reputation: 0
Thanks very much I'll definitely look into using those library functions. I do suppose I could just parse the output from 'sensors' but that seems like an inefficient method to get in the habit of.
 
Old 07-17-2009, 02:30 PM   #4
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Hi -

1. The thing that lets you monitor temperature, CPU voltage, etc is "ACPI":
http://acpi.sourceforge.net/document...processor.html

2. You can check basic settings from the command line:
Quote:
sensors
cat /proc/cpuinfo
3. Chances are, however, these two commands might not work: APCI is not necessarily fully enabled out of the box (OOTB). Here's how you can configure it:

http://blog.taragana.com/index.php/a...e-6-26-kernel/

'Hope that helps .. PSM
 
Old 07-17-2009, 02:41 PM   #5
Aztral
LQ Newbie
 
Registered: Jul 2009
Posts: 18

Original Poster
Rep: Reputation: 0
Thanks for the response paul.

I did spend several hours earlier trying to figure out acpi -t but to no avail. I just get the error message "No support for device type: thermal". I did, however, figure out how to get sensors working so I'll most likely end up using that in some capacity if I cannot figure out how to code this myself.
 
Old 07-22-2009, 05:34 PM   #6
Aztral
LQ Newbie
 
Registered: Jul 2009
Posts: 18

Original Poster
Rep: Reputation: 0
New question!:

I am interested in determining cpu temperature, fan speed and also voltage. As I understand it, acpi no longer supports Core 2 Duo processors, which is why the directories /proc/acpi/fan and /proc/acpi/thermal_zone are empty on my machine.

EDIT: Now I'm not sure what I think. At my laptop at home with a Core 2 Duo the /proc/acpi/thermal_zone directory is populated and virtual files do exist to read cpu temperature.... I'm very confused at the moment.

However, I'm under the impression that lm-sensors is capable of reporting all of this information. Thus far I've only been able to get 'sensors' to report my cpu temperature. When I run sensors-detect, the sole thing that it detects is the driver 'coretemp'. Is it likely that my other sensors are not supported at this time?

Thanks again.

Also, is there a file somewhere in linux that contains anything resembling voltage or fan speed? I know systems it supports /proc/acpi/fan/whatever tells you whether or not the fan is on, but is there anything more specific than that?

Last edited by Aztral; 07-22-2009 at 08:25 PM.
 
Old 07-23-2009, 02:00 AM   #7
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Hello Aztral
Quote:
Originally Posted by Aztral View Post
When I run sensors-detect, the sole thing that it detects is the driver 'coretemp'. Is it likely that my other sensors are not supported at this time?
lmsensors can only report what the motherboard provides. Usually the BIOS is written to display everything that the motherboard provides in the BIOS setup screens so you could check there to get an idea of what's possible. If sensors-detect doesn't find anything you may be out of luck or have a very new monitoring chip. Which motherboard do you have?

Best

Charles
 
Old 07-27-2009, 06:32 PM   #8
Aztral
LQ Newbie
 
Registered: Jul 2009
Posts: 18

Original Poster
Rep: Reputation: 0
Well, I'm trying to create a tool that will operate over multiple custom Linux OS's and several different hardware setups. For that reason using lm_sensors would probably be ideal, but I'm having trouble setting that up on a couple of the OS's. For example trying to make all or make install lm_sensors results in a "no rule to make '/usr/include/gnu/stubs-32.h', needed by 'prog/dump/superio.rd'. . ." compiler error, meaning I'm missing glibc-dev or something like that?

One small plus (I think) is that in running sensors-detect on all the different configurations results in the same chip being detected. They all need/use the w83627hf driver, which means theoretically I could perhaps write a very dumbed down, specific version of lm_sensors that could do the trick?

However, at the end of sensors-detect I receive the message "Warning: the required module w83627hf is not currently installed on your system. If it is built into the kernel then it's OK. Otherwise, check http://www.lm-sensors.org/wiki/Devices for driver availability." So I'm kind of at a loss of what step to take next.

Thanks again for the assistance, it is much appreciated.
 
Old 07-28-2009, 04:10 AM   #9
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Hello Aztral
Quote:
Originally Posted by Aztral View Post
Well, I'm trying to create a tool that will operate over multiple custom Linux OS's and several different hardware setups. For that reason using lm_sensors would probably be ideal, but I'm having trouble setting that up on a couple of the OS's. For example trying to make all or make install lm_sensors results in a "no rule to make '/usr/include/gnu/stubs-32.h', needed by 'prog/dump/superio.rd'. . ." compiler error, meaning I'm missing glibc-dev or something like that?
Sorry -- I have only installed the pre-built package so cannot advise. If netsearching doesn't find an answer you could ask in the [CODE]lmsensors mailing list.

Quote:
Originally Posted by Aztral View Post
One small plus (I think) is that in running sensors-detect on all the different configurations results in the same chip being detected. They all need/use the w83627hf driver, which means theoretically I could perhaps write a very dumbed down, specific version of lm_sensors that could do the trick?
You could but would any benefits justify the extra work?

Quote:
Originally Posted by Aztral View Post
However, at the end of sensors-detect I receive the message "Warning: the required module w83627hf is not currently installed on your system. If it is built into the kernel then it's OK. Otherwise, check http://www.lm-sensors.org/wiki/Devices for driver availability." So I'm kind of at a loss of what step to take next.
Strange -- that page says it's been supported since kernel 2.6.5 so you shouldn't have a problem. Why didn't installation detect the chip and install the module? Maybe time to start another thread on this specific question, quoting which OS you are using.

Best

Charles
 
Old 07-28-2009, 12:08 PM   #10
Aztral
LQ Newbie
 
Registered: Jul 2009
Posts: 18

Original Poster
Rep: Reputation: 0
I'm thinking the lack of that module is going to be the biggest problem.

I've also looked at /sys/class/hwmon, which it turns out actually does record the temperature of some systems (not the ones I need it on, of course) where /proc/acpi does not, but as I understand it it also relies on the i2c driver. Since that driver doesn't exist on the systems I need it on (I've looked in /sys/bus/i2c/devices, /sys/bus/platform/devices and about every other /sys directory I can think of, plus sensors-detect probably knows what it's talking about) the /sys/class/hwmon directory is empty.

Also, looking at the lm_sensors source, I think that lm_sensors actually uses the information in the /sys/class/hwmon directory, which means I'm completely out of luck unless I can find a way to populate it.

Crap.

Is it possible to install that module at this point?

Last edited by Aztral; 07-28-2009 at 12:19 PM.
 
Old 07-28-2009, 12:26 PM   #11
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Quote:
Originally Posted by Aztral View Post
Is it possible to install that module at this point?
I expect so but, like I wrote "Maybe time to start another thread on this specific question, quoting which OS you are using."
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
CPU temperature Sc0pE Linux - Software 2 05-22-2005 05:10 PM
CPU Temperature thresholds. liguorir Solaris / OpenSolaris 1 10-15-2004 10:59 AM
cpu temperature alaios Linux - Hardware 4 09-21-2004 04:30 PM
how to get cpu temperature taoweijia Linux - Software 3 02-13-2004 06:04 PM
CPU Temperature Cubiq Programming 3 04-06-2002 11:04 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:05 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration