PDA

View Full Version : [LINUX] CPU temperature incorrect in XBMC for Linux?


CrashX
2009-01-12, 07:06
I noticed that the cpu temperature is displayed as ?.

I checked the code and found that the cpu temperature is coming from CPUInfo.cpp:

m_fProcTemperature = fopen("/proc/acpi/thermal_zone/THRM/temperature", "r");
if (m_fProcTemperature == NULL)
m_fProcTemperature = fopen("/proc/acpi/thermal_zone/THR1/temperature", "r");
if (m_fProcTemperature == NULL)
m_fProcTemperature = fopen("/proc/acpi/thermal_zone/THM/temperature", "r");

Unfornately, in Ubuntu 8.10 64bit that file doesn't exist ...

BLKMGK
2009-01-12, 07:33
Actually it's always a ? on 32bit too :(

althekiller
2009-01-12, 08:07
You have a /proc/acpi/thermal_zone/THM0/temperature though?

BLKMGK
2009-01-12, 08:10
Honestly do not know if I have that or not, just knew that it was always a ? and never knew what to investigate to find out what was up. On my last install I even had LMsensors working in hopes of solving that heh. Reinstalling on 8.1 from scratch so I will try to look into this more. I and several others would LOVE to have the temp display working right for us!

Edit: checked on my new build - XBMC not yet running. proc/acpi/thermal_zone exists but nothing lower and nothing in this dir. Does that help? Ubuntu 8.1

althekiller
2009-01-12, 08:36
So long as your ACPI is setup correctly and your cpu is supported by acpi thermal zone, this should be fixed in r17031. Be patient, temp only updates every 60s or so and the for some odd reason isn't called straight away (ie. you get a ? for the first ~60s).

CrashX
2009-01-12, 16:57
No I don't ... I have sensors installed and working as expected with temperature readings . I only have /proc/acpi/thermal_zone directory and it is empty.

You have a /proc/acpi/thermal_zone/THM0/temperature though?

CrashX
2009-01-12, 17:05
According to the website below, /proc/acpi is being replaced by interfaces in /sys and new software should not look in /proc.

http://acpi.sourceforge.net/documentation/thermal.html

althekiller
2009-01-12, 18:30
Next time you post a link make sure the info is more than just an after thought and that it contains useful info. I know damn well /proc is deprecated (not removed). But I haven't found exactly WHAT PATH in /sys has deprecated /proc/acpi/thermal_zone. Feel free to dig it up and create a ticket on trac, but don't bother unless you find the appropriate info.

In the interim, your kernel is misconfigured, your hardware unsupported, you don't have acpid running or some combo.

Chrisleben
2009-01-21, 06:54
Same problem here. Anyone figured it out?

theuni
2009-01-21, 07:37
my temp is shown (degC*1000) in: /sys/class/hwmon/hwmon0/device/temp1_input

matches sensors info for the same device.

Don't know if that's worth anything, figured I'd pass it along.

TheUni

Chrisleben
2009-01-21, 12:46
Theuni
have you installed anything special? i got them aswell in sys what version are you using?

CrashX
2009-01-21, 18:12
Will check mines if it is their as well .. I will create a patch if so ..

althekiller
2009-01-21, 18:54
Check /sys/class/thermal/thermal_zone0/temp instead, there is no way to know what file is mapped to what sensor in the dir tehuni mentioned.

Chrisleben
2009-01-21, 21:12
Check /sys/class/thermal/thermal_zone0/temp instead, there is no way to know what file is mapped to what sensor in the dir tehuni mentioned.

i dont got that but i got the one tehuni had

CrashX
2009-01-22, 01:37
I don't have /sys/class/thermal/thermal_zone0/temp but I do have /sys/class/hwmon/hwmon0/device/temp1_input.

But my temp1_input is Chipset and temp2_input is CPU and temp3_input is Case Temperature reading ... I have integrated videocard ..

It looks like this information will only get populated if lib_sensors is installed ....

How about you guys ? Do you have three readings as well ? Do you have integrated videocard ? Maybe with alot of example, we can get an idea what file cpu temperature is stored in ...

Another way, is to parse the output of sensors program and look for the cpu temperature and compare the value to tempX_Input if it matches then it is file we use ....

althekiller
2009-01-22, 04:06
As I said before (info which I obtained from the sysfs kernel docs), there's no standard way to make sense of the temp data in /sys/class/hwmon. So that's not an option. I'd rather drop temperature entirely than pull in another dep for just for it. We're a media center not a hardware monitor...

Chrisleben
2009-01-22, 10:31
Thats true this is a media center :) i dont really care about the temp just annyoing it says ? thanx for all help.

rodalpho
2009-01-22, 17:39
I'd rather drop temperature entirely than pull in another dep for just for it. We're a media center not a hardware monitor...
I certainly agree with not requiring the dependency. Proper behavior would probably be something like displaying "unavailable" if the sensors package isn't installed, working if it is, and documenting it in the readme and/or the wiki as an optional dependency.

BLKMGK
2009-01-23, 00:14
Media center yes, however that often means PCs installed in closets, cabinets, and in cases with poor airflow. I for one would love to be able to configure XBMC to use LMsensors to read my GPU and CPU...

althekiller
2009-01-23, 03:32
Python.

CrashX
2009-01-23, 04:02
It looks we can determine what file ( temp?? ) is used for CPU temp by running the following command:

sensors -u

We can parse the output of it to determine the file that contains temperature information ... After that we keep reading the contents of the file ...

CrashX
2009-01-23, 05:03
Maybe this is better approach to this problem. Instead of trying to figure out what the file we need to parse it, we let the user specific the filename inside the advancesettings.xml

ie ..


<advancedsettings>
<cputemperature>
<file></file> --- > File that contains temperature formation
<regexp></regexp> ---> regular expression to retrieve temperature reading and temperature type ( C/F/??) from the specified file
</cputemperature>
<gputemperature>
<file></file>
<regexp></regexp>
</gputemperature>
<fan>
<file></file>
<regexp></regexp>
</fan>
</advancedsettings>

althekiller
2009-01-23, 06:38
The values in hwmon aren't guaranteed to be milliDeg C like the ones in thermal_zone. They can also be mV and have sensor specific math required.

How about instead we allow you to supply a command that prints only "temp scale" where temp is integer degrees and scale is one of c,f or k?

So my instance would be something like
<cputempcommand>sed -e 's/\([0-9]*\)[0-9]\{3\}/\1 C/' /sys/class/thermal/thermal_zone0/temp</cputempcommand>

I can't think of any problems with this solution off hand, but I haven't implemented it yet, so no guarantees.

CrashX
2009-01-23, 20:13
Maybe I am missing something but isn't this the same:


<cputemperature>
<file>/sys/class/thermal/thermal_zone0/temp</file>
<regexp>'s/\([0-9]*\)[0-9]\{3\}/\1 C/'</regexp>
</cputemperature>


Do you think it will probably be bit too much of a process for an application to call another application for data every 60 seconds ..

althekiller
2009-01-23, 22:01
Maybe I am missing something but isn't this the same:


<cputemperature>
<file>/sys/class/thermal/thermal_zone0/temp</file>
<regexp>'s/\([0-9]*\)[0-9]\{3\}/\1 C/'</regexp>
</cputemperature>

No, that's not a regex, it's a sed find+replace command.

Your solution is overly complicated and inflexible. It is far more simple to call popen on a user defined command line. This will allow any math that needs done on the sensor data to happen and also make direct calls to lmsensors or any other sensor reading prog. Plus I already have it implemented ;)

So take it or leave it, the patch is a bit of clean up and a commit away.

rodalpho
2009-01-23, 22:24
While you're at it, just in case you think it's appropriate to include in XBMC, I believe something like
nvidia-settings -q GPUCoreTemp | grep HOSTNAME | awk -F ":\ " '{print $2}'
will print the GPU temperature for nVidia cards. Can't test as I'm not at home.

CrashX
2009-01-23, 22:28
Yup I agree your idea is better but I am bit worried about having it access the shell so often ... 60 seconds is also bit too much time to wait for updated temperature information ..

Anyways if you have it done already then commit away ... THANKS ALOT ...

Will you be adding fan speed and gpu temperature support as well ... I see that XBMC has some support for it but the data isn't gotten though ...

I take it now with this support all OS will now support temperature readings ...

althekiller
2009-01-23, 22:57
GPU maybe, fan speed probably not. Fan speed was only available on XBOX as the PWM duty-cycle percentage, which is kinda useless anyway as the fan may not even be spinning. Not to mention neither of the default skins display the value anymore.

I wouldn't worry about going out to the shell, the function is only called when the value is actually being displayed.

As far as support on other platforms goes, AFAIK they both support popen but the call to get the cpu temp is currently ifdefed for linux only. I'll let one of the devs on said platforms test and enable if they see fit.

@rodalpho: This is a little more clean IMO ;)
echo "$(nvidia-settings -tq gpucoretemp) C"

rodalpho
2009-01-25, 19:52
Now that it's been checked in, I can't seem to get it to work. I have the following as ~/.xbmc/userdata/advancedsettings.xml (using LMsensors as I don't have the sys thermal stuff for some reason):


<advancedsettings>
<gputempcommand>echo "$(nvidia-settings -tq gpuCoreTemp) C"</gputempcommand>
<cputempcommand>sensors|grep "CPU Temp"|awk '{print $3}'</cputempcommand>
</advancedsettings>


And XBMC still shows question marks for CPU and GPU temperature. I tried putting it in /usr/local/share/xbmc/userdata/advancedsettings.xml also, no luck. Thoughts?

CrashX
2009-01-26, 03:40
By the look of the code ... it is looking for integer and character ... %d %c format ...

Your cputempcommand won't give you that that .. Try this ...

echo "$(sensors -u | grep "temp2_input"| awk '{print $2 }') C"

althekiller
2009-01-26, 04:12
By the look of the code ... it is looking for integer and character ... %d %c format ...

Right, just like the wiki says :) I take it everything works fine for you CrashX?

rodalpho
2009-01-26, 06:29
Tried
<advancedsettings>
<gputempcommand>echo "$(nvidia-settings -tq gpuCoreTemp) C"</gputempcommand>
<cputempcommand>echo "$(sensors -u | grep "temp2_input"| awk '{print $2 }') C"</cputempcommand>
</advancedsettings>
Which also didn't work for either CPU or GPU, just shows a "?" in XBMC. The commands do return what looks to be proper output.
rodalpho@fiddler:~$ echo "$(sensors -u | grep "temp2_input"| awk '{print $2 }') C"
29.50 C
rodalpho@fiddler:~$ echo "$(nvidia-settings -tq gpuCoreTemp) C"
37 C


Edit: Also tried

rodalpho@fiddler:~$ echo "$(sensors -u | grep "temp2_input"| awk '{print $2 }' |awk '{printf("%d\n",$1 + 0.5);}') C"
44 C

which returns an integer with no decimal, and it didn't work either. Just get question marks for both CPU and GPU temps.

Edit2: OK, after updating to 17366, the following advancedsettings.xml actually works, however in XBMC the numbers are converted to fahrenheit! They show up as 104F and 88F for GPU and CPU, respectively, when I prefer celsius. When advancedsettings.xml is removed, I'm back to question marks. Very very weird.

<advancedsettings>
<gputempcommand>echo "$(nvidia-settings -tq gpuCoreTemp) C"</gputempcommand>
<cputempcommand>echo "$(sensors -u | grep "temp2_input"| awk '{print $2 }' |awk '{printf("%d\n",$1 + 0.5);}') C"</cputempcommand>
</advancedsettings>

althekiller
2009-01-26, 07:17
What is displayed in the GUI is determined by the region you have set.

rodalpho
2009-01-26, 07:23
Fair enough. Just weird that it shows F after having specified C in the config file.

althekiller
2009-01-26, 08:16
You aren't specifying the display scale, you're specifying the scale of the input. All temperatures in XBMC are displayed on the same scale based on the region setting. This is how it has been for years.

CrashX
2009-01-26, 15:12
I tested it as well and all worked fine.

queeup
2009-02-14, 23:58
Nvidia temp not working for me :(

xbmc@xbmc:~$ nvidia-settings -tq gpuCoreTemp

ERROR: The control display is undefined; please run `nvidia-settings --help`
for usage information.

xbmc@xbmc:~$

Installed with olympia (wiki) guide except SVN build.
XBMC from SVN-PPA (17700),
Nvidia driver:180.29

ronie
2009-02-15, 01:58
Nvidia temp not working for me :(

xbmc@xbmc:~$ nvidia-settings -tq gpuCoreTemp

ERROR: The control display is undefined; please run `nvidia-settings --help`
for usage information.

xbmc@xbmc:~$

Installed with olympia (wiki) guide except SVN build.
XBMC from SVN-PPA (17700),
Nvidia driver:180.29

try this:
nvidia-settings -c :0 -tq GPUCoreTemp

queeup
2009-02-15, 07:42
hmmm.
xbmc@xbmc:~$ nvidia-settings -c :0 -tq GPUCoreTemp -V

WARNING: Error querying attribute 'GPUCoreTemp' specified in query
'GPUCoreTemp'; 'GPUCoreTemp' is not available on xbmc:0.0.

xbmc@xbmc:~$

soder
2009-02-15, 10:03
Hi! Will try to ask this question here, and hope you guys can help me.

I got a GIGABYTE MA78GM-S2H, and I my temp are also not correct displayed.

What do I have to install on my Ubuntu 8.10 to make it work?

A little guide, and I would be very happy.

Thanks

EDIT: I followed the guide http://www.lm-sensors.org/wiki/iwizard/1
but when I then try "sensors" only this is displayed, and that cant be right..

root@htpc-desktop:/home/htpc# sensors
k8temp-pci-00c3
Adapter: PCI adapter
Core0 Temp: +23.0°C
Core0 Temp: +20.0°C
Core1 Temp: +21.0°C
Core1 Temp: +27.0°C

/Söder

olympia
2009-02-15, 11:06
A little guide, and I would be very happy.



http://xbmc.org/wiki/?title=HOW-TO:_Install_XBMC_for_Linux_on_Ubuntu_8.10_%28Intre pid%29_step-by-step#Enable_thermal_monitoring

soder
2009-02-15, 12:33
http://xbmc.org/wiki/?title=HOW-TO:_Install_XBMC_for_Linux_on_Ubuntu_8.10_%28Intre pid%29_step-by-step#Enable_thermal_monitoring

Ok, thanks, but is this right?

htpc@htpc-desktop:~$ sensors -u
k8temp-pci-00c3
Adapter: PCI adapter
Core0 Temp:
temp1_input: 29.00
Core0 Temp:
temp2_input: 28.00
Core1 Temp:
temp3_input: 30.00
Core1 Temp:
temp4_input: 37.00

it8718-isa-0228
Adapter: ISA adapter
in0:
in0_input: 1.22
in0_min: 0.00
in0_max: 4.08
in0_alarm: 0.00
in1:
in1_input: 1.95
in1_min: 0.00
in1_max: 4.08
in1_alarm: 0.00
in2:
in2_input: 3.28
in2_min: 0.00
in2_max: 4.08
in2_alarm: 0.00
in3:
in3_input: 2.94
in3_min: 0.00
in3_max: 4.08
in3_alarm: 0.00
in4:
in4_input: 3.07
in4_min: 0.00
in4_max: 4.08
in4_alarm: 0.00
in5:
in5_input: 3.17
in5_min: 0.00
in5_max: 4.08
in5_alarm: 0.00
in6:
in6_input: 4.08
in6_min: 0.00
in6_max: 4.08
in6_alarm: 1.00
in7:
in7_input: 3.28
in7_min: 0.00
in7_max: 4.08
in7_alarm: 0.00
in8:
in8_input: 3.12
fan1:
fan1_input: 0.00
fan1_min: 0.00
fan1_alarm: 0.00
fan2:
fan2_input: 0.00
fan2_min: 0.00
fan2_alarm: 0.00
fan3:
fan3_input: 0.00
fan3_min: 0.00
fan3_alarm: 0.00
temp1:
temp1_input: 46.00
temp1_max: 127.00
temp1_min: 127.00
temp1_alarm: 0.00
temp1_type: 2.00
temp2:
temp2_input: 49.00
temp2_max: 80.00
temp2_min: 127.00
temp2_alarm: 0.00
temp2_type: 3.00
temp3:
temp3_input: 92.00
temp3_max: 127.00
temp3_min: 127.00
temp3_alarm: 0.00
temp3_type: 2.00
cpu0_vid:
cpu0_vid: 1.55

I have a AMD 4850 cpu..

EDIT: Still only ? in XBMC...

/Söder

BLKMGK
2009-02-15, 19:04
Thanks for the guide, much appreciated! Will be following it shortly :)

dafart
2009-02-19, 21:12
I can hereby confirm that <advancedsettings>
<gputempcommand>echo "$(nvidia-settings -tq gpuCoreTemp) C"</gputempcommand>
<cputempcommand>echo "$(sensors -u | grep "temp2_input"| awk '{print $2 }' |awk '{printf("%d\n",$1 + 0.5);}') C"</cputempcommand>
</advancedsettings> shows correct gpu temp of my nvidia card. (thanks rodalpho)

CPU temp info does not display correctly though.
lm_sensors is installed correctly and the code added to advencedsettings.xml gives this output when entered in a terminal:echo "$(sensors -u | grep "temp2_input"| awk '{print $2 }') C"
4.00
38.00 C


Could it be due to the fact that my cpu has 2 cores that it doesn know what to put?

Hopefully someone can shed a light on this.

Cheers, dafart

althekiller
2009-02-19, 23:01
The code expects an integer. Hack off the ".00" and it should be fine.

olympia
2009-02-19, 23:59
The code expects an integer. Hack off the ".00" and it should be fine.

I think his problem is, that he see 4 C as CPU temp.
I have the same experience on my mobo: the cpu temp is not detected correctly by lmsensors.

The output of sensors -u is:


Sys Temp:
temp1_input: 41.00
temp1_max: 82.00
temp1_max_hyst: 11.00
temp1_alarm: 0.00
temp1_type: 4.00
CPU Temp:
temp2_input: 8.00
temp2_max: 80.00
temp2_max_hyst: 75.00
temp2_alarm: 0.00
temp2_type: 1.00
AUX Temp:
temp3_input: 41.50
temp3_max: 80.00
temp3_max_hyst: 75.00
temp3_alarm: 0.00
temp3_type: 4.00
cpu0_vid:
cpu0_vid: 2.10

coretemp-isa-0000
Adapter: ISA adapter
Core 0:
temp1_input: 42.00
temp1_crit: 100.00
temp1_crit_alarm: 0.00

coretemp-isa-0001
Adapter: ISA adapter
Core 1:
temp1_input: 44.00
temp1_crit: 100.00
temp1_crit_alarm: 0.00


so temp2_input: 8.00 obviously wrong while the core temps displays correctly. So I think becasue of the wrong CPU temp detection, we shoud look for one of the core temp to display, but we cannot grep for temp1_input as we already have this value for sys temp (first match).

I was unable to solve this with my knowlege.

althekiller
2009-02-20, 00:16
Sure you can...
echo "$(sensors -u | tail -n3 | grep input | sed -e 's/.*\([0-9]*\)\..*/\1/') C"
...should be close. I don't have lmsensors installed to test it.

EDIT: Looking at sensors... WTH are you using -u for?

olympia
2009-02-20, 08:42
Sure you can...
echo "$(sensors -u | tail -n3 | grep input | sed -e 's/.*\([0-9]*\)\..*/\1/') C"
...should be close. I don't have lmsensors installed to test it.

Thank you for the tip! I should have find this out myself... :blush:

Your sed command was not ok (maybe I will play with that later), so I replaced it with the command from rodalpho as the following:

echo "$(sensors -u | tail -n4 | grep temp1_input | awk '{print $2 }' |awk '{printf("%d\n",$1 + 0.5);}') C"

it works.


EDIT: Looking at sensors... WTH are you using -u for?

you mean why not use and analyze the output of sensors instead of sensors -u?

althekiller
2009-02-20, 17:54
you mean why not use and analyze the output of sensors instead of sensors -u?

Huh? I don't think that's what I mean. -u treats the sensors as "unknown" and is "for testing only" (direct quotes from the --help). You want -U or no options at all (I can't tell the difference).

olympia
2009-02-20, 18:06
Huh? I don't think that's what I mean. -u treats the sensors as "unknown" and is "for testing only" (direct quotes from the --help). You want -U or no options at all (I can't tell the difference).

Without options, the output looks like this:

w83627dhg-isa-0290
Adapter: ISA adapter
VCore: +1.14 V (min = +0.00 V, max = +1.74 V)
in1: +12.25 V (min = +12.83 V, max = +3.80 V) ALARM
AVCC: +3.20 V (min = +0.83 V, max = +0.61 V) ALARM
3VCC: +3.20 V (min = +1.12 V, max = +3.65 V)
in4: +1.59 V (min = +1.12 V, max = +1.38 V) ALARM
in5: +1.54 V (min = +0.15 V, max = +0.77 V) ALARM
in6: +4.97 V (min = +4.25 V, max = +1.87 V) ALARM
VSB: +3.22 V (min = +0.14 V, max = +2.75 V) ALARM
VBAT: +3.20 V (min = +1.55 V, max = +0.05 V) ALARM
Case Fan: 1599 RPM (min = 16071 RPM, div = 4) ALARM
CPU Fan: 0 RPM (min = 9375 RPM, div = 8) ALARM
Aux Fan: 0 RPM (min = 168750 RPM, div = 8) ALARM
fan4: 1687 RPM (min = 10546 RPM, div = 4) ALARM
fan5: 0 RPM (min = 67500 RPM, div = 4) ALARM
Sys Temp: +35.0°C (high = +82.0°C, hyst = +8.0°C) sensor = thermistor
CPU Temp: +3.0°C (high = +80.0°C, hyst = +75.0°C) sensor = diode
AUX Temp: +36.0°C (high = +80.0°C, hyst = +75.0°C) sensor = thermistor
cpu0_vid: +2.100 V

coretemp-isa-0000
Adapter: ISA adapter
Core 0: +38.0°C (crit = +100.0°C)

coretemp-isa-0001
Adapter: ISA adapter
Core 1: +40.0°C (crit = +100.0°C)


I think scraping the output with option -u is easier :)

althekiller
2009-02-20, 18:15
Just so you know, every command in a shell script launches its own subshell. So the shorter your pipe, the better.

CrashX
2009-02-20, 18:20
I think what althekiller means why not use sensors -U (note that caps ) instead of sensors -u.

althekiller:

We can always patch the code to accept decimal (%f) and integer (%d) to make it easier on the shell.

althekiller
2009-02-20, 20:54
I don't see a point in switching to float just for sensors -u. It isn't even intended for normal use. All of the normal places to get the temp are integer values (procfs, sysfs, sensors (w/o -u), nvidia-settings, etc). Even sensors -u is integer data from what I can tell, at least none of the temps on my server have a non-zero fractional part. Besides, it's easy enough to sed off the integer part of a float.

olympia
2009-02-20, 21:33
???

I showed you my output of sensors w/o -u. The values are float there as well.

CrashX
2009-02-20, 21:59
Correct me if I am wrong, if we use (%f), it should satisfy both integer and decimal ?

Anyways for me, I needed an extra command to trim the decimal values which could of been avoided.

olympia
2009-02-21, 00:37
Just so you know, every command in a shell script launches its own subshell. So the shorter your pipe, the better.

With Sensors -u

echo "$(sensors -u | tail -n4 | grep input | sed -e 's/.*\([0-9]..*\)\..*/\1/') C"

With sensors without any options:

echo "$(sensors | grep "Core 1" | sed -e 's/[a-z]*..............\([0-9].\)\..*/\1/') C"

Both works well, but this latter seems really crap and dirty :rolleyes:
sed is not my favorite.... :blush:

djurny
2009-03-23, 01:46
if you want to use the least amount of pipes as possible, the following is a candidate:

<cputempcommand>sensors|sed -ne "s/Core 1: \+[-+]\([0-9]\+\).*/\1 C/p"</cputempcommand>


or you could just do the following, which will give average core temps on your system instead of 'external' cpu temps.. (meaning sensors on cpu casing or just below the cores themselves)


<cputempcommand>num=0; sum=0; for temp in $(cat /sys/devices/platform/coretemp.?/temp?_input); do num=$(($num + 1)); sum=$(($sum + $temp)); done; echo "$(($sum / $num / 1000)) C"</cputempcommand>


havent tested the latter one, do not know how popen() handles bash like syntax..

here's a shell script for all temperature readings i have on my machine, should not be hard to modify it to your own needs :)


#!/bin/bash

# authors:
# djurny <no(at)spam.com>
# license:
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# description:
# get various temperature readings
# usage:
# $0 core
# gets average core temperature, needs coretemp installed!
# $0 gpu
# get nvidia gpu core temperature, needs nvidia-settings installed!
# $0 hdd
# gets active harddisk temperatures, needs hdparm and hddtemp installed!
# notes:
# for automated use, add NOPASSWD for hdparm, hddtemp for user to sudoers

err() {
echo "$*" 1>&2
}

get_core_temp() {
local num=0
local sum=0
for temp in $(cat /sys/devices/platform/coretemp.?/temp?_input); do
num=$(($num + 1))
sum=$(($sum + $temp))
done
if [[ $sum -eq 0 || $num -eq 0 ]]; then
err "could not get correct temperature(s) (sum='$sum' num='$num')"
return 1
fi
echo "$(($sum / $num / 1000)) C"
return 0
}

get_gpu_temp () {
local app="nvidia-settings"
if ! which $app >/dev/null 2>/dev/null; then
err "file not found '$app'"
return 1
fi
# this may need some tiddling with DISPLAY settings!
echo "$($app --terse --query GPUCoreTemp) C"
return 0
}

get_hdd_temp() {
local ret=0
local hdds="/dev/sd?"
local tmp=0
local tmpfile="/tmp/$(basename $0)"
# local app
# for app in hdparm hddtemp; do
# if ! which $app >/dev/null 2>/dev/null; then
# err "file not found '$app'"
# return 1
# fi
# done
for hdd in $hdds; do
sudo hdparm -C $hdd >$tmpfile 2>/dev/null
if [ $? -gt 0 ]; then
err "could not get powerstate for '$hdd'"
ret=1
continue
fi
if ! grep -e "active\|idle" $tmpfile >/dev/null 2>/dev/null; then
# do not allow hddtemp to spin up sleeping hdds
continue
fi
tmp=$(sudo hddtemp --numeric $hdd 2>/dev/null)
if [[ $? -gt 0 || -z "$tmp" || $tmp -eq 0 ]]; then
err "could not get hdd temp for '$hdd'"
continue
fi
echo "$tmp C"
done
return $ret
}

case "$1" in
core)
if ! get_core_temp; then
err "could not get cpu temperature"
exit 1
fi
;;
gpu)
if ! get_gpu_temp; then
err "could not get gpu temperature"
exit 1
fi
;;
hdd)
if ! get_hdd_temp; then
err "could not get hdd temperature"
exit 1
fi
;;
*)
err "do not knnow what to do for '$1'"
exit 1
;;
esac

exit 0

# EOF

soder
2009-04-11, 14:40
Ok, thanks, but is this right?

htpc@htpc-desktop:~$ sensors -u
k8temp-pci-00c3
Adapter: PCI adapter
Core0 Temp:
temp1_input: 29.00
Core0 Temp:
temp2_input: 28.00
Core1 Temp:
temp3_input: 30.00
Core1 Temp:
temp4_input: 37.00

it8718-isa-0228
Adapter: ISA adapter
in0:
in0_input: 1.22
in0_min: 0.00
in0_max: 4.08
in0_alarm: 0.00
in1:
in1_input: 1.95
in1_min: 0.00
in1_max: 4.08
in1_alarm: 0.00
in2:
in2_input: 3.28
in2_min: 0.00
in2_max: 4.08
in2_alarm: 0.00
in3:
in3_input: 2.94
in3_min: 0.00
in3_max: 4.08
in3_alarm: 0.00
in4:
in4_input: 3.07
in4_min: 0.00
in4_max: 4.08
in4_alarm: 0.00
in5:
in5_input: 3.17
in5_min: 0.00
in5_max: 4.08
in5_alarm: 0.00
in6:
in6_input: 4.08
in6_min: 0.00
in6_max: 4.08
in6_alarm: 1.00
in7:
in7_input: 3.28
in7_min: 0.00
in7_max: 4.08
in7_alarm: 0.00
in8:
in8_input: 3.12
fan1:
fan1_input: 0.00
fan1_min: 0.00
fan1_alarm: 0.00
fan2:
fan2_input: 0.00
fan2_min: 0.00
fan2_alarm: 0.00
fan3:
fan3_input: 0.00
fan3_min: 0.00
fan3_alarm: 0.00
temp1:
temp1_input: 46.00
temp1_max: 127.00
temp1_min: 127.00
temp1_alarm: 0.00
temp1_type: 2.00
temp2:
temp2_input: 49.00
temp2_max: 80.00
temp2_min: 127.00
temp2_alarm: 0.00
temp2_type: 3.00
temp3:
temp3_input: 92.00
temp3_max: 127.00
temp3_min: 127.00
temp3_alarm: 0.00
temp3_type: 2.00
cpu0_vid:
cpu0_vid: 1.55

I have a AMD 4850 cpu..

EDIT: Still only ? in XBMC...

/Söder

Is there any way for me to corrent my cpu temp showed by sensors?
In BIOS I know the temp is higher then what sensors are showing me..?

And XBMC are STILL only giving me an ? for CPU TEMP...

/Söder

althekiller
2009-04-11, 19:17
Is there any way for me to corrent my cpu temp showed by sensors?
In BIOS I know the temp is higher then what sensors are showing me..?

And XBMC are STILL only giving me an ? for CPU TEMP...

/Söder

You need to be more clear on what exactly you want to do. You clearly haven't read/comprehended any of the documentation for this advanced setting, or this short thread if you're trying to pass that command directly to XBMC.

The temp is probably higher in bios because the frequency isn't throttled at that point and it is in OS. Otherwise you can work out an equation for for the error on your own and do the math in bash (google "arithematic +bash").

soder
2009-04-11, 20:34
You need to be more clear on what exactly you want to do. You clearly haven't read/comprehended any of the documentation for this advanced setting, or this short thread if you're trying to pass that command directly to XBMC.

The temp is probably higher in bios because the frequency isn't throttled at that point and it is in OS. Otherwise you can work out an equation for for the error on your own and do the math in bash (google "arithematic +bash").

Hmm I dont really understand what you mean. I've installed sensor like I should. If I then start with the commanc "sensors" or "sensors -u" I get a lot or info. The first info are some about the cores. I guess this is the one XBMC want to grab and use?

I dont know how this is "calculated"? I didnt even know it was. Isnt there just some sensor that can measure the temp?

I have read this tread, and the sensors page. I dont understand and thats why I ask here...?

/Söder

althekiller
2009-04-11, 20:39
You need to create a shell command that outputs the form "X Y" where X is the temperature as an integer and Y is the scale as a character ('C' or 'F'). Figuring out the shell command is left up to you, there are plenty of examples in this thread and the wiki to get it all straight.

speed32219
2009-04-17, 02:46
Soder, it can be confusing since if you read the whole thread there is reference to advancsettings.xml and then comments on creating shell scripts. I think the original question was somehting about ? showing up within xbmc when you check the info screen. (I've never seen a ? pop up on the command line, yet) And I am at the same spot as you currently. I guess we need to create a shell script and launch it using launcher which I am also trying to get to work, almost there, just need to create a shell script for firefox. (I Hope) Then I will work on one for cpu/gpu temps, but it would be nice to just select info on the remote and have it displayed with cpu useage instead of the ?.

Now can someone point me to advancesettings.xml or do I need to go to my xbox to find it, I am using a pc based linux ubuntu intrepid release. I can not find that file.

Thank you

althekiller
2009-04-17, 03:29
There's plenty of info about as.xml in the wiki. Including that it is a USER CREATED file.

domi55
2009-07-15, 20:37
Guys,

I have successfully configured GPU temp monitoring on as.xml:

<advancedsettings>
<gputempcommand>echo "$(nvidia-settings -c :0 -tq GPUCoreTemp) C"</gputempcommand>
</advancedsettings>


But with my NVIDIA ION Board (Zotac ION ITX A) I have problems to detect the CPU temp:

(T: XBMCLive)xbmc@XBMCLive:~$ ls /proc/acpi/thermal_zone/
(T: XBMCLive)xbmc@XBMCLive:~$
(T: XBMCLive)xbmc@XBMCLive:~$ find /sys -name *temp*
(T: XBMCLive)xbmc@XBMCLive:~$


And it seems that lm-sensors does not work for ION boards at the moment:

(T: XBMCLive)xbmc@XBMCLive:~$ sudo sensors-detect
Sorry, no sensors were detected.
Either your sensors are not supported, or they are connected to an
I2C or SMBus adapter that is not supported.

http://ubuntuforums.org/showthread.php?t=1199797

My XBMC Version: 9.04.1 r20654

Does anybody have an idea how I can get the CPU temps for my ION board?

althekiller
2009-07-15, 20:46
You need an updated and/or patched kernel to get temps out of that chipset. Probably some info on the ubuntu forums regarding what needs done.

domi55
2009-07-15, 21:06
You need an updated and/or patched kernel to get temps out of that chipset.

Alright I see. So I guess you have experience with temp monitoring on that chipset/board?

Because if I do a search on the ubuntu forums the only thread I can find is the following:

http://ubuntuforums.org/showthread.php?t=1199797

Can you probably point me in the right direction?

althekiller
2009-07-15, 21:18
No, I have no experience with it. I just read it somewhere awhile ago and remembered. Between our forums, the ubuntu forums and google you should beable to find something.

pat1975
2009-07-15, 23:17
Does anybody have an idea how I can get the CPU temps for my ION board?

yeah, me!

Link you posted directs to my thread :-)

Nothing new for me on this. But I think, as both CPU and GPU are under the same heatsink, temps should be nearly equal.

Patrick

vikjon0
2009-07-15, 23:29
I am also interested in getting this working in the ION Atom.

If I understand what I read correclty there should be a fix for the atom from Dec 2008 and there is also a completly new verson available.

lm-sensors 3.1.1

This is the latest release of the stable branch, for Linux 2.6.5+. It supports all the devices your kernel supports, as it no longer contains chip-specific code.

I do not know how to check the version I have in 9.04 but the sensors-detect is built in may 2008 which I guess means that we need a newer version than Ubuntu supplies.

Intalling this manaully is very deep water for me though. Will see if I have the time to read up on it,

domi55
2009-07-16, 10:18
Intalling this manaully is very deep water for me though.

Same for me ;) I tried it yesterday with absolutely no success. I would love to have a working lm-sensors version.

temps should be nearly equal.
Thanks pat1975. I know that! But as I already mentioned I would like to monitor my temps with lm-sensors.

Probably somebody can help us to install lm-sensors 3.1.1 manually.

althekiller
2009-07-16, 10:40
lmsensors can't work until the kernel exposes the sensors.

domi55
2009-07-16, 10:56
lmsensors can't work until the kernel exposes the sensors.

Sorry althekiller but I dont't understand what you mean.

Release Notes:
http://lm-sensors.org/browser/lm-sensors/tags/V3-1-1/CHANGES

On the release notes we can see that with version 3.1.0 they've added the NVIDIA MCP79 chipset.

Add nNidia nForce MCP67, MCP73, MCP79 SMBus support

As far as I can remember if we intall lm-sensors with "sudo apt-get install lm-sensors" it will insta version 3.0.2. But I'm not sure.

vikjon0
2009-07-16, 11:08
I think he mean that the Kernel have to support it.
If they have changed the way it collects the values it makes sense that the kernel have to be updated as well.

domi55
2009-07-16, 11:14
Alright I see. Then I need somebody who points me in the right direction for updating the kernel.

domi55
2009-07-17, 10:57
Ok it seems that somebody in the ubuntu forums found a solution:

http://ubuntuforums.org/showthread.php?t=1199797

kurai
2009-07-17, 13:44
Yay, at last someone has figured out the peculiarities of the Ion monitoring setup \o/

I can now throw away all my half-baked hacked around not-working attempts and use lmsensors like a normal person :grin:

domi55
2009-07-17, 13:58
I can now throw away all my half-baked hacked around not-working attempts and use lmsensors like a normal person

Haha! Right. Same for me ;)

vikjon0
2009-07-17, 14:10
Yes, but at least on Asrock ION 330 it does not seem to work.

domi55
2009-07-17, 14:21
Did you rerun

# sudo sensors-detect

After doing

# modprobe i2c-dev
# modprobe i2c-nforce2
# echo "10de 0aa2" > /sys/bus/pci/drivers/nForce2_smbus/new_id

# i2cdetect -l should now show you two new nvidia SMBus adapters:

i2c-0 i2c NVIDIA i2c adapter I2C adapter
i2c-1 i2c NVIDIA i2c adapter I2C adapter
i2c-2 i2c NVIDIA i2c adapter I2C adapter
i2c-3 smbus SMBus nForce2 adapter at 4d00 SMBus adapter
i2c-4 smbus SMBus nForce2 adapter at 4e00 SMBus adapter

# modprobe lm85

?

vikjon0
2009-07-17, 14:52
Yes, and he detected nothing.

Will try again from the top later, maybe I made a misstake somewhere.

domi55
2009-07-17, 14:55
Yes, and he detected nothing.

Will try again from the top later, maybe I made a misstake somewhere.

Hm... Thats acutally strange. I will try the procedure tonight with my Zotac ION 330 board.
Can you please update kzanol from the ubuntu forums that you were unsuccessful?

domi55
2009-07-17, 20:22
Hm... The procedure does not work on my Zotac ION ITX A board:

http://ubuntuforums.org/showpost.php?p=7631114&postcount=9

davilla
2009-07-17, 20:40
cpu temp support for the all atom processors is not in lmsensors/kernel yet. You're just going to have to wait for upstream to add it.

domi55
2009-07-21, 20:29
Hi all!

Monitoring CPU temps on a Zotac IONITX A board is now possible:

Needed module: [URL removed]


(T: XBMCLive)root@XBMCLive:/tmp# mv coretemp.ko /lib/modules/`uname -r`/kernel/drivers/hwmon/
(T: XBMCLive)xbmc@XBMCLive:/tmp$ sudo vi /etc/modules <-- Add coretemp to the end of the file
(T: XBMCLive)xbmc@XBMCLive:/tmp$ sudo init 6
(T: XBMCLive)xbmc@XBMCLive:/tmp$ sudo sensors
coretemp-isa-0000
Adapter: ISA adapter
Core 0: +30.0°C (crit = +95.0°C)

coretemp-isa-0001
Adapter: ISA adapter
Core 1: +28.0°C (crit = +95.0°C)

coretemp-isa-0002
Adapter: ISA adapter
Core 2: +30.0°C (crit = +95.0°C)

coretemp-isa-0003
Adapter: ISA adapter
Core 3: +28.0°C (crit = +95.0°C)

And now I use the following advancedsettings.xml commands:
<gputempcommand>echo "$(nvidia-settings -c :0 -tq GPUCoreTemp) C"</gputempcommand>
<cputempcommand>echo "$(sensors -u | head -6 |grep "temp1_input"| awk '{print $2 }' |awk '{printf("%d\n",$1 + 0.5);}') C"</cputempcommand>

Thanks very much to kzanol and tg1 from the ubuntu forums:

http://ubuntuforums.org/showthread.php?p=7653212

XBMC CPU temp monitoring: http://upload.olol.ch/thumbnails/images/1248197271_cpu_temp_zotac_.jpg
XBMC GPU temp monitoring: http://upload.olol.ch/thumbnails/images/1248197271_gpu_temp_zotac_.jpg

vikjon0
2009-07-21, 20:34
Great work!

althekiller
2009-07-21, 21:15
I can't emphasize enough how STUPID it is to download a random kernel module and just load it up. It's a terrible idea from a security standpoint. Not to mention kernel module binaries are very restricted as far as kernel and compiler versions go, so you'd be lucky if it even loads. I'm removing the link. Team XBMC can't be responsible for such an unsafe practice. Find a link to the sources and write up a howto for building it.

domi55
2009-07-21, 21:23
Alright althekiller. I do understand you. But this is in my case just for playing around a little bit. Sorry for that.

I'm removing the link. Team XBMC can't be responsible for such an unsafe practice. Find a link to the sources and write up a howto for building it.

No problem. Thanks for editing.

fidoboy
2009-07-26, 18:38
I'm sorry for the newby question but, where is advancedsettings.xml?? I'm trying to get the temp sensors working on XBMC but i can't find advancedsettings.xml

regards,

bidossessi
2009-07-26, 18:57
I'm sorry for the newby question but, where is advancedsettings.xml?? I'm trying to get the temp sensors working on XBMC but i can't find advancedsettings.xml

regards,

you have to create it manually, like it is said in the wiki

fidoboy
2009-07-27, 18:20
you have to create it manually, like it is said in the wiki

Many thanks, i've solved it and it's working fine now (GPU and CPU temps)

kind regards,

erhnam
2009-07-29, 12:01
Hi all!

Monitoring CPU temps on a Zotac IONITX A board is now possible:

Needed module: [URL removed]



And now I use the following advancedsettings.xml commands:
<gputempcommand>echo "$(nvidia-settings -c :0 -tq GPUCoreTemp) C"</gputempcommand>
<cputempcommand>echo "$(sensors -u | head -6 |grep "temp1_input"| awk '{print $2 }' |awk '{printf("%d\n",$1 + 0.5);}') C"</cputempcommand>

Thanks very much to kzanol and tg1 from the ubuntu forums:

http://ubuntuforums.org/showthread.php?p=7653212

XBMC CPU temp monitoring: http://upload.olol.ch/thumbnails/images/1248197271_cpu_temp_zotac_.jpg
XBMC GPU temp monitoring: http://upload.olol.ch/thumbnails/images/1248197271_gpu_temp_zotac_.jpg

My output is a little bit different:

(T: XBMCLive)xbmc@XBMCLive:~$ sudo sensors
coretemp-isa-0000
Adapter: ISA adapter
Core 0: +49.0°C (crit = +95.0°C)

coretemp-isa-0001
Adapter: ISA adapter
Core 1: +49.0°C (crit = +95.0°C)


Maybe it's related to my single core Atom. Which commands should I use for adding line to the dvancedsettings.xml file?

domi55
2009-07-29, 13:33
please use:

# sensors -u

...and the <cputempcommand> code should also work for you.

graysky
2009-09-05, 14:45
I can't seem to get this patched module to work at all. Help is appreciated :)

I'm not using ubuntu, it's Arch. The same patch shouldn't care wich distro it is though...

1) Got the source
2) Applied the patch
3) Compiled a new kernel and in doing so, the patched coretemp.ko

From here can I not simply copy the patched coretemp.ko to /lib/modules/2.6.30-ARCH/kernel/drivers/hwmon/ and just modprobe it?

# cp /home/builds/kernelbuild/src/drivers/hwmon/coretemp.ko /lib/modules/2.6.30-ARCH/kernel/drivers/hwmon/
# depmod -a
# modprobe coretemp
FATAL: Error inserting coretemp (/lib/modules/2.6.30-ARCH/kernel/drivers/hwmon/coretemp.ko): Invalid module format

No luck :(

Ideas?

althekiller
2009-09-05, 19:10
I'm going to assume you're on about ION since you thread jacked a thread jacked, stale thread assuming everyone wants to read the whole back story to figure out WTH you're on about. The CPU and GPU share a heatsink, their temps aren't going to very by much more than 5C. Just use the GPU temp easily attained with nvidia-settings for both.

graysky
2009-09-05, 20:25
Sorry to offend. I will gladly start a new thread.

althekiller
2009-09-05, 20:28
...no need, that wasn't the offense anyway. Just PROVIDE DETAILS in the future, don't assume we know exactly what your problem is, we don't. Besides, I already answered your problem.

djon
2009-10-21, 18:11
Anyone figured out a kernel that works with Asrock ION? I'm contemplating using a Zalman fan mate on the little noisy CPU fan, but would like to know if I'm frying the poor thing...

iGudi
2009-11-12, 10:12
This is how i got it running on my ION 330:

Install for CPU temp.
----------------------------
sudo apt-get install lm-sensors

sudo sensors-detect


ION FIX
----------------------------

wget http://mabene.icomedias.com/coretemp.ko
sudo insmod coretemp.ko
sensors eller sensors -u

reboot

install permanent:
sudo cp coretemp.ko /lib/modules/2.6.28-16-generic/kernel/drivers/hwmon/
sudo nano /etc/modules
add "coretemp"


Nvidia temp.
-----------------------------
nvidia-settings -c :0 -tq GPUCoreTemp

iGudi
2009-11-12, 15:42
Here's the output - eventhough I'm having a hard time believing the temps. It's gotta be more then 8 degress...?!

xbmc@xbmc:/tmp$ sensors
coretemp-isa-0000
Adapter: ISA adapter
Core 0: +8.0°C (crit = +95.0°C)

coretemp-isa-0001
Adapter: ISA adapter
Core 1: +7.0°C (crit = +95.0°C)

coretemp-isa-0002
Adapter: ISA adapter
Core 2: +8.0°C (crit = +95.0°C)

coretemp-isa-0003
Adapter: ISA adapter
Core 3: +6.0°C (crit = +95.0°C)

X3lectric
2009-11-18, 13:50
check out the sensors-detect stuff here http://blog.xbmc.org/forum/showthread.php?p=438274#post438274