The officially official Devuan Forum!

You are not logged in.

#1 2020-11-23 10:09:22

dice
Member
Registered: 2020-11-22
Posts: 559  
Website

Conky + sensors temp settings ?

Hi, anyone able to help with an issue i have with conky hwmon sensor readings?

I dont leave my computer on constantly so it gets turned off after im finished with it and upon booting it up i get a hwmon sensor temp reading sometimes and other times i dont.

What is happening is /sys/class/hwmon1 and 2 keep switching in sensors.

eg; These two values keep switching over reboots, so i would have to change conkyrc hwmon 1 temp 2 to hwmon 2 temp 2 and vice versa.

 cat /sys/class/hwmon/hwmon1/
device/      name         power/       subsystem/   temp1_input  uevent
cat /sys/class/hwmon/hwmon2/
device/           subsystem/        temp1_input       temp2_crit        temp2_label       temp3_crit_alarm  temp3_max         temp4_input       temp5_crit        temp5_label
name              temp1_crit        temp1_label       temp2_crit_alarm  temp2_max         temp3_input       temp4_crit        temp4_label       temp5_crit_alarm  temp5_max
power/            temp1_crit_alarm  temp1_max         temp2_input       temp3_crit        temp3_label       temp4_crit_alarm  temp4_max         temp5_input       uevent

This is what cpu temp looks like in conkyrc via dzen2

https://pastebin.com/raw/UvuT1Xmv

Last edited by dice (2020-11-23 10:18:25)

Offline

#2 2020-11-23 12:13:57

steve_v
Member
Registered: 2018-01-11
Posts: 381  

Re: Conky + sensors temp settings ?

dice wrote:

What is happening is /sys/class/hwmon1 and 2 keep switching in sensors.

I don't have equivalent hardware so I can't check (exact names will differ), but my approach would be either:
a) If hwmon1 and hwmon2 are handled by different drivers, go see how and when they are loaded. They'll be getting an index based on which module loads first, so if you can fix the load order they should always get the same name.
b) See if there's another usable source, such as conky's {acpitemp} object or a node in e.g. /sys/class/thermal.
c) Get the values externally. IIRC conky can call external binaries, so you should be able to use lm-sensors with something like:

${execi 10 sensors | grep "Package id 0" | cut -d'+' -f2 | cut -c1-7}

"Package id 0" is from the intel coretemp driver so your sensor name will probably differ, but it should still be easily grepable.

It shouldn't be difficult to search through the /sys/class/hwmon[x]/name files for the sensor you want in a bash script either, push comes to shove.

Last edited by steve_v (2020-11-23 12:20:12)


Once is happenstance. Twice is coincidence. Three times is enemy action. Four times is Official GNOME Policy.

Offline

#3 2020-11-23 13:05:24

dice
Member
Registered: 2020-11-22
Posts: 559  
Website

Re: Conky + sensors temp settings ?

Hi steve_v

thanks for your input. I think you may be right about what modules are getting loaded first, currently im not at that computer but will have a dig around and see if i can debug it asap.

The machine has an intel cpu with integrated graphics, it has sensors detect for acpi, cpu, graphics and the wifi card, so it is definitely possible it is a modules load issue.

Offline

#4 2020-11-24 08:37:58

dice
Member
Registered: 2020-11-22
Posts: 559  
Website

Re: Conky + sensors temp settings ?

I dont understand why but hwmon seems to be a moving target, also not sure if im listing modules correctly in /etc/modules as per below too see if this would fix it doesnt, the only other like you say steve is i think making a script up. Ive found that cat /sys/devices/platform/coretemp.0/hwmon/hwmon2/temp2_input | cut -c-2 seems to be consistent enough for execi in conky.

NB: ive added all the modules below except for coretemp which sensors-detect do, i dont think order here really matters though?

# /etc/modules: kernel modules to load at boot time.
#
# This file contains the names of kernel modules that should be loaded
# at boot time, one per line. Lines beginning with "#" are ignored.

# Generated by sensors-detect on Tue Nov 24 17:47:49 2020
# Chip drivers
iwlwifi
cfg80211
mac80211
coretemp
acpitz

Last edited by dice (2020-11-24 08:39:28)

Offline

#5 2020-11-24 19:07:01

Head_on_a_Stick
Member
From: London
Registered: 2019-03-24
Posts: 3,125  
Website

Re: Conky + sensors temp settings ?


Brianna Ghey — Rest In Power

Offline

#6 2020-11-25 07:21:13

dice
Member
Registered: 2020-11-22
Posts: 559  
Website

Re: Conky + sensors temp settings ?

If the solution in that thread was ${platform coretemp.0 temp 1} my conky dzen2 says no such file,

conky: can't open '/sys/bus/platform/devices/coretemp.0/temp1_input': No such file or directory please check your device or remove this var from conky 

However it shows up as

cat /sys/bus/platform/devices/coretemp.0/hwmon/hwmon1/temp1_input

Maybe conky is looking in the wrong directory for that variable?

Last edited by dice (2020-11-25 07:25:29)

Offline

#7 2020-12-02 10:56:19

dice
Member
Registered: 2020-11-22
Posts: 559  
Website

Re: Conky + sensors temp settings ?

I found a really nice script for use with lm_sensors, way beyond my scripting abilities, all credit to the author whoever it is.

If you want this in °F you need to add an -f to sensors in the script and change out the celcius parts, i did it the other way around as this script was for °F originally.

needs bc package if you havent already installed it.

#!/bin/bash

# 1. get temperature

## a. split response
## Core 0:        +48.0°C  (high = +105.0°C, crit = +105.0°C)
IFS=')' read -ra core_temp_arr <<< $(sensors | grep '^Core\s[[:digit:]]\+:') #echo "${core_temp_arr[0]}"

## b. find cpu usage
total_cpu_temp=0
index=0
for i in "${core_temp_arr[@]}"; do :
    temp=$(echo $i | sed -n 's/°C.*//; s/.*[+-]//; p; q')
    let index++
    total_cpu_temp=$(echo "$total_cpu_temp + $temp" | bc)
done
avg_cpu_temp=$(echo "scale=2; $total_cpu_temp / $index" | bc)

## c. build entry
temp_status="CPU: $avg_cpu_temp °C"
echo $temp_status

exit 0

source: https://stackoverflow.com/questions/506 … -from-bash

Last edited by dice (2020-12-02 10:58:08)

Offline

#8 2020-12-02 11:05:52

fsmithred
Administrator
Registered: 2016-11-25
Posts: 2,486  

Re: Conky + sensors temp settings ?

I like seeing the individual core temps. Here's the line I'm using:

${execi 8 sensors | awk '/Core/ { printf substr($3,2,2)" " }'}

and the output looks like this:

CPU: 42 36 40 41

Offline

#9 2020-12-02 12:49:29

dice
Member
Registered: 2020-11-22
Posts: 559  
Website

Re: Conky + sensors temp settings ?

fsmithred wrote:

I like seeing the individual core temps. Here's the line I'm using:

${execi 8 sensors | awk '/Core/ { printf substr($3,2,2)" " }'}

and the output looks like this:

CPU: 42 36 40 41

That is a good one, i like to see the individual cores as well and this solves my issue with hwmon moving around. Thanks

Offline

#10 2021-05-07 12:07:51

dice
Member
Registered: 2020-11-22
Posts: 559  
Website

Re: Conky + sensors temp settings ?

revisiting this thread to add to it.

Figured out i think an easier script to calculate the average of sensors temp output from the awk command posted by fsmithred above.

Im fairly certain the maths is correct below but wondering if it could be done a better way and also how i could tack on the celcius symbol °C - to the end of the output?

#!/bin/sh

get_temp=$(sensors | awk '/Core/ { printf substr($3,2,2)"" }')

printf "Temp:" && expr "$get_temp" / 1000000

this command in the script..

sensors | awk '/Core/ { printf substr($3,2,2)"" }' 

now prints 8 digits like so..

44444744

edit: so output look like so from the script.

Temp:44

Last edited by dice (2021-05-07 13:10:50)

Offline

#11 2021-05-07 13:17:29

Head_on_a_Stick
Member
From: London
Registered: 2019-03-24
Posts: 3,125  
Website

Re: Conky + sensors temp settings ?

Try

#!/bin/sh

temp="$(sensors | awk '/Core/{sum+=$3}END{print sum/4}')"

printf "Temp: %s°C" "$temp"

(Untested because my sensors doesn't show a "Core" column. This example presumes four cores with the temperature given in the third field, correct as needed.)


Brianna Ghey — Rest In Power

Offline

#12 2021-05-07 13:58:48

dice
Member
Registered: 2020-11-22
Posts: 559  
Website

Re: Conky + sensors temp settings ?

Head_on_a_Stick wrote:

Try

#!/bin/sh

temp="$(sensors | awk '/Core/{sum+=$3}END{print sum/4}')"

printf "Temp: %s°C" "$temp"

(Untested because my sensors doesn't show a "Core" column. This example presumes four cores with the temperature given in the third field, correct as needed.)

nice, thanks head on a stick. works for me, it seems out by 1 degree compared to my other scripts but yours may very well be more accurate.

Offline

#13 2021-05-07 14:00:14

Head_on_a_Stick
Member
From: London
Registered: 2019-03-24
Posts: 3,125  
Website

Re: Conky + sensors temp settings ?

Your other scripts weren't printing an average of all four cores whereas mine is :-)


Brianna Ghey — Rest In Power

Offline

#14 2021-05-07 14:32:09

dice
Member
Registered: 2020-11-22
Posts: 559  
Website

Re: Conky + sensors temp settings ?

Head_on_a_Stick wrote:

Your other scripts weren't printing an average of all four cores whereas mine is :-)

can you explain a little what is going on in that command?

from what i can gather it is getting the 3rd column of temperature digits from the /Core/ output and dividing the sum by a factor of 4, would this be correct? I would rather it didnt print a decimal place as it moves around too much in the panel, aka 51.75 to 52 etc.

Offline

#15 2021-05-07 15:13:13

Altoid
Member
Registered: 2017-05-07
Posts: 1,581  

Re: Conky + sensors temp settings ?

Hello:

fsmithred wrote:

... individual core temps.

Same here.

Here's the line I'm using, not my work.
I recall getting the format right here at Dev1:

TEMPERATURES
${hr 2}
Core 0: +${hwmon 0 temp 2} C  $alignc Core 1: +${hwmon 0 temp 3} C
Core 2: +${hwmon 0 temp 4} C  $alignc Core 3: +${hwmon 0 temp 5} C
${hr 0.3}

Looks (sort of) like this:

TEMPERATURES
_____________________________
Core 0: +44 C   Core 1: +41 C
Core 2: +40 C   Core 3: +41 C
_____________________________

Best,

A.

Offline

#16 2021-05-07 15:23:21

Head_on_a_Stick
Member
From: London
Registered: 2019-03-24
Posts: 3,125  
Website

Re: Conky + sensors temp settings ?

dice wrote:

from what i can gather it is getting the 3rd column of temperature digits from the /Core/ output and dividing the sum by a factor of 4, would this be correct?

Yes, that's right.

dice wrote:

I would rather it didnt print a decimal place

#!/bin/sh

temp="$(sensors|awk '/Core/{lines++}{sum+=$3}END{print int(sum/lines)}')"

printf "Temp: %s°C" "$temp"

EDIT: added lines variable to make the script work for any number of active cores.

Last edited by Head_on_a_Stick (2021-05-07 19:36:33)


Brianna Ghey — Rest In Power

Offline

#17 2021-05-08 11:46:46

dice
Member
Registered: 2020-11-22
Posts: 559  
Website

Re: Conky + sensors temp settings ?

Head_on_a_Stick wrote:
dice wrote:

I would rather it didnt print a decimal place

#!/bin/sh

temp="$(sensors|awk '/Core/{lines++}{sum+=$3}END{print int(sum/lines)}')"

printf "Temp: %s°C" "$temp"

EDIT: added lines variable to make the script work for any number of active cores.

Thanks.

Although with your edit i am getting this output ?

Temp: 318°C

Previous command without line var

Temp: 43°C

sensors output in full is..

~$ sensors
BAT1-acpi-0
Adapter: ACPI interface
in0:          11.74 V
curr1:         2.05 A

coretemp-isa-0000
Adapter: ISA adapter
Core 0:       +42.0°C  (high = +84.0°C, crit = +100.0°C)
Core 1:       +42.0°C  (high = +84.0°C, crit = +100.0°C)
Core 2:       +45.0°C  (high = +84.0°C, crit = +100.0°C)
Core 3:       +43.0°C  (high = +84.0°C, crit = +100.0°C)

nouveau-pci-0100
Adapter: PCI adapter
GPU core:    850.00 mV (min =  +0.80 V, max =  +0.95 V)
temp1:        +37.0°C  (high = +95.0°C, hyst =  +3.0°C)
                       (crit = +105.0°C, hyst =  +5.0°C)
                       (emerg = +135.0°C, hyst =  +5.0°C)

Offline

#18 2021-05-08 14:00:49

Head_on_a_Stick
Member
From: London
Registered: 2019-03-24
Posts: 3,125  
Website

Re: Conky + sensors temp settings ?

Bah, sorry, I thought I tested that...

Does this work?

#!/bin/sh

temp="$(sensors|awk '/^Core/{sum+=$3;lines+=1}END{print int (sum/lines)}')"

printf "Temp: %s°C" "$temp"

Brianna Ghey — Rest In Power

Offline

#19 2021-05-09 10:47:10

dice
Member
Registered: 2020-11-22
Posts: 559  
Website

Re: Conky + sensors temp settings ?

Head_on_a_Stick wrote:

Bah, sorry, I thought I tested that...

Does this work?

#!/bin/sh

temp="$(sensors|awk '/^Core/{sum+=$3;lines+=1}END{print int (sum/lines)}')"

printf "Temp: %s°C" "$temp"

yes that works, sorry for late reply been away from technology for a time.

cheers

Offline

Board footer