• 1
  • 2
  • 3
  • 4(current)
  • 5
  • 6
  • 8
[LINUX] CPU temperature incorrect in XBMC for Linux?
#46
althekiller Wrote: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:

Code:
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.
Reply
#47
Sure you can...
Code:
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?
Reply
#48
althekiller Wrote:Sure you can...
Code:
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:
Code:
echo "$(sensors -u | tail -n4 | grep temp1_input | awk '{print $2 }' |awk '{printf("%d\n",$1 + 0.5);}') C"

it works.

althekiller Wrote: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?
Reply
#49
olympia Wrote: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).
Reply
#50
althekiller Wrote: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:

Code:
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 Smile
Reply
#51
Just so you know, every command in a shell script launches its own subshell. So the shorter your pipe, the better.
Reply
#52
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.
Reply
#53
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.
Reply
#54
Huh

I showed you my output of sensors w/o -u. The values are float there as well.
Reply
#55
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.
Reply
#56
althekiller Wrote:Just so you know, every command in a shell script launches its own subshell. So the shorter your pipe, the better.

With Sensors -u

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

With sensors without any options:

Code:
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
Reply
#57
if you want to use the least amount of pipes as possible, the following is a candidate:
Code:
<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)

Code:
<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 Smile

Code:
#!/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
Intel Core2 Q8200 - GigaByte GA-E7AUM-DSH2 - 8GiB DDR2 - Recom 8b - Hauppauge PVR150 - 2* Acer AL2216w - Philips 26" CRT - Sanyo PLV-Z5
Reply
#58
soder Wrote:Ok, thanks, but is this right?

Code:
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
Reply
#59
soder Wrote: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").
Reply
#60
althekiller Wrote: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
Reply
  • 1
  • 2
  • 3
  • 4(current)
  • 5
  • 6
  • 8

Logout Mark Read Team Forum Stats Members Help
[LINUX] CPU temperature incorrect in XBMC for Linux?2