You are not logged in.

#1 2025-01-14 15:17:56

Succulent of your garden
Member
Registered: 2024-02-29
Posts: 129

Need to get cpu voltage to show in my bar

Hi

I really  want to monitor my cpu voltage in my var for my WM. I need to get the voltage with cli without using sudo, or getting it from a file.

Can I do that ? I need to fetch the info without privilege elevation.

Any Ideas ?

Last edited by Succulent of your garden (2025-01-14 15:18:25)

Offline

#2 2025-01-14 15:20:51

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 23,844

Re: Need to get cpu voltage to show in my bar

https://wiki.archlinux.org/title/Lm_sensors ?

After doing the initial configuration with sensors-detect subsequent calls of sensors don't need root. and whether you can query this strongly depends on your board and available sensor modules for it.

Last edited by V1del (2025-01-14 15:21:34)

Offline

#3 2025-01-14 23:31:02

Succulent of your garden
Member
Registered: 2024-02-29
Posts: 129

Re: Need to get cpu voltage to show in my bar

After running the sensors-detect script, now It starting to show the voltage, but in this current format:

in0:                      424.00 mV (min =  +0.00 V, max =  +1.74 V)
in1:                        1.01 V  (min =  +0.00 V, max =  +0.00 V)  ALARM
in2:                        3.41 V  (min =  +0.00 V, max =  +0.00 V)  ALARM
in3:                        3.31 V  (min =  +0.00 V, max =  +0.00 V)  ALARM
in4:                        1.01 V  (min =  +0.00 V, max =  +0.00 V)  ALARM
in5:                        0.00 V  (min =  +0.00 V, max =  +0.00 V)
in6:                        0.00 V  (min =  +0.00 V, max =  +0.00 V)
in7:                        3.41 V  (min =  +0.00 V, max =  +0.00 V)  ALARM
in8:                        3.20 V  (min =  +0.00 V, max =  +0.00 V)  ALARM

Which I image I could  make the sum of all of the  items of the second column to get my actual voltage right ?  But there is another way more easily to  get the voltage without using a sudo command ? Using "sudo dmidecode --type processor | grep -i voltage" I can get the voltage, but it needs sudo, and I'm not sure if it's a good idea to let run dmidecode without asking sudo but running like root.

Last edited by Succulent of your garden (2025-01-14 23:35:19)

Offline

#4 2025-01-15 00:03:37

dimich
Member
From: Kharkiv, Ukraine
Registered: 2009-11-03
Posts: 309

Re: Need to get cpu voltage to show in my bar

Succulent of your garden wrote:

I could  make the sum of all of the  items of the second column to get my actual voltage right ?

What do you mean by "actual voltage"? Modern computer has many power buses with different voltages.

Succulent of your garden wrote:

But there is another way more easily to  get the voltage without using a sudo command ?

lm_sensors and dmidecode read voltages either from sysfs or directly from sensors, usually via /dev/i2c-*. Likely you can read /sys/class/hwmon/ nodes without root priviledges. Just figure out which node corresponds to which sensor in your system.
You can run sensors with strace to check which files it read in your system, or explore sources.

Offline

#5 2025-01-15 12:07:34

Succulent of your garden
Member
Registered: 2024-02-29
Posts: 129

Re: Need to get cpu voltage to show in my bar

dimich wrote:

What do you mean by "actual voltage"? Modern computer has many power buses with different voltages.

I'm guessing that each one of the in<number> in the first column are my cpu cores, at least for me that's what I'm thinking now.

dimich wrote:

lm_sensors and dmidecode read voltages either from sysfs or directly from sensors, usually via /dev/i2c-*. Likely you can read /sys/class/hwmon/ nodes without root priviledges. Just figure out which node corresponds to which sensor in your system.
You can run sensors with strace to check which files it read in your system, or explore sources.

Thank you so much, I'll try that approach now.

Offline

#6 2025-01-16 00:37:43

dimich
Member
From: Kharkiv, Ukraine
Registered: 2009-11-03
Posts: 309

Re: Need to get cpu voltage to show in my bar

Succulent of your garden wrote:

I'm guessing that each one of the in<number> in the first column are my cpu cores, at least for me that's what I'm thinking now.

They are from in*_input files in one of your /sys/class/hwmon/hwmon*/ directories. Perhaps, one of them is core voltage. Which file corresponds to which sensor depends on your motherboard and hwmon driver. Usually driver is not aware of mapping because motherboard manufacturers don't share this information officially. Driver just exposes what is reported by ACPI "as is". You can try to figure out who is who there specifically for your MB by comparing values with values displayed in BIOS.

Offline

#7 2025-01-16 15:37:42

Succulent of your garden
Member
Registered: 2024-02-29
Posts: 129

Re: Need to get cpu voltage to show in my bar

I found the cpu folder, but it's very hard to know where the file is. How are you using strace to get the route ?

I'm using this:

sudo strace -ff -e open,read dmidecode --type processor

but It gaves me wierd outputs in the read command like read(9/002/728/and so on). It seems like it's reading an ELF file. Do you think that dmidecode read the information using some ELF files ?

Last edited by Succulent of your garden (2025-01-16 15:38:11)

Offline

#8 2025-01-16 15:56:49

dimich
Member
From: Kharkiv, Ukraine
Registered: 2009-11-03
Posts: 309

Re: Need to get cpu voltage to show in my bar

Succulent of your garden wrote:

How are you using strace to get the route ?

openat() is a right syscall.

strace -f -yy -e openat,read dmidecode --type processor

should be more meaningful.

Offline

#9 2025-01-17 12:31:52

Succulent of your garden
Member
Registered: 2024-02-29
Posts: 129

Re: Need to get cpu voltage to show in my bar

Thanks dimich, But viewing the routes it seems that dmidecode use binary files so I can't get the voltage from a file. Nevertheless many thanks for your help

Offline

#10 2025-01-17 16:27:10

dimich
Member
From: Kharkiv, Ukraine
Registered: 2009-11-03
Posts: 309

Re: Need to get cpu voltage to show in my bar

Succulent of your garden wrote:

But viewing the routes it seems that dmidecode use binary files so I can't get the voltage from a file.

On Linux dmidecode requires read access to two files: /sys/firmware/dmi/tables/smbios_entry_point and /sys/firmware/dmi/tables/DMI. It reads /dev/mem only if required enties aren't found in sysfs.
By default those files have root:root 0400 permissions.

So there are two options:
1) configure your system to allow your user to read from smbios_entry_point and DMI. It can be implemented, for example, with udev rules. In this case dmidecode will be able to read voltage without root permissions.
2) run dmidecode (or any other DMI table parser) as root and expose voltage for non-root user. For example, via d-bus interface.

Offline

Board footer

Powered by FluxBB