You are not logged in.

#1 2012-03-05 08:44:43

Lockheed
Member
Registered: 2010-03-16
Posts: 1,550

Adcanved conky codding

I can read the CPU's MSR like that

# rdmsr -0 0x198 
 061b4c2686004b26

This is the only way I can do it on my laptop.

This reads register 0x198 from the first CPU. The current voltage ID (VID) is in hexadecimal the last 2 digits and might fluctuate with the core clock if Speedstep is enabled.
In my case it is 26, or 38 in decimal. On a mobile Core2Duo, the formula is 0.7125V + VID*0.0125V. In my case that corresponds to 1.1875V. (keep in mind that VID is in hex, and desktop CPUs use another formula, too).

Now, how can I feed this value translated into Volts into conky display?

Last edited by Lockheed (2012-03-05 08:45:33)

Offline

#2 2012-03-05 08:55:30

Wilco
Member
Registered: 2008-11-09
Posts: 440

Re: Adcanved conky codding

You can use conky's exec variable and some fancy sed, awk magic to translate the values to something readable. If you can code C, you can add this functionality to the conky code and add a patch for yourself.

Offline

#3 2012-03-05 09:09:43

Lockheed
Member
Registered: 2010-03-16
Posts: 1,550

Re: Adcanved conky codding

Wilco wrote:

You can use conky's exec variable and some fancy sed, awk magic to translate the values to something readable.

Yes, the forula for this magic is what I am asking about.

Offline

#4 2012-03-05 09:11:51

livibetter
Member
From: Taipei
Registered: 2008-05-14
Posts: 95
Website

Re: Adcanved conky codding

I don't have conky or rdmsr, but this should be able to get you going, although it looks relatively ugly to me:

$ echo 061b4c2686004b26 | awk '{split(substr($1,length($1)-1),s,"") ; print 0.7125+(s[1]*16+s[2])*0.0125}'
1.1875

Edited: oops I forgot hex contains a-f, will fix the code.

Edited 2: this should work

echo 061b4c2686004b26 | awk --non-decimal-data '{s="0x" substr($1,length($1)-1) ; print 0.7125+s*0.0125}'
1.1875

Last edited by livibetter (2012-03-05 09:23:01)

Offline

#5 2012-03-05 09:34:02

Lockheed
Member
Registered: 2010-03-16
Posts: 1,550

Re: Adcanved conky codding

Ok, but 061b4c2686004b26 is a dynamic number and is supposed to change on the fly, that's why I'd like the code to call rdmsr each time it takes a read.

Offline

#6 2012-03-05 09:39:20

.:B:.
Forum Fellow
Registered: 2006-11-26
Posts: 5,819
Website

Re: Adcanved conky codding

The conky homepage has all the details on how to make this happen.


Got Leenucks? :: Arch: Power in simplicity :: Get Counted! Registered Linux User #392717 :: Blog thingy

Offline

#7 2012-03-05 09:45:04

livibetter
Member
From: Taipei
Registered: 2008-05-14
Posts: 95
Website

Re: Adcanved conky codding

Lockheed wrote:

Ok, but 061b4c2686004b26 is a dynamic number and is supposed to change on the fly, that's why I'd like the code to call rdmsr each time it takes a read.

Aww.. I was thinking you understood, just replace echo part with that rdmsr command. IIRC, the conky code should look like:

${execi 60 rdmsr -0 0x198 | awk --non-decimal-data '{s="0x" substr($1,length($1)-1) ; print 0.7125+s*0.0125}'}

Offline

#8 2012-03-05 09:56:37

Lockheed
Member
Registered: 2010-03-16
Posts: 1,550

Re: Adcanved conky codding

Thanks, livibetter. You are great help. However, the problem is rdmsr requires sudo to be able to access msr table.

Offline

#9 2012-03-05 10:19:03

Wilco
Member
Registered: 2008-11-09
Posts: 440

Re: Adcanved conky codding

You can make a cronjob that read this value every 2 seconds as root and put the output in some /tmp file that you can read as a normal user.

Or you can add yourself to the wheel group, make wheel group sufficient for su (so you can su without a pw) and run it with su - ... to execute the command as root

Offline

#10 2012-03-05 11:15:32

Lockheed
Member
Registered: 2010-03-16
Posts: 1,550

Re: Adcanved conky codding

I got that line into conky config, but it displays nothing at all:

${execi 60 ${exec cat /tmp/voltage} | awk --non-decimal-data '{s="0x" substr($1,length($1)-1) ; print 0.7125+s*0.0125}'}

Last edited by Lockheed (2012-03-05 11:15:54)

Offline

#11 2012-03-05 14:25:30

livibetter
Member
From: Taipei
Registered: 2008-05-14
Posts: 95
Website

Re: Adcanved conky codding

Lockheed wrote:

I got that line into conky config, but it displays nothing at all:

${execi 60 ${exec cat /tmp/voltage} | awk --non-decimal-data '{s="0x" substr($1,length($1)-1) ; print 0.7125+s*0.0125}'}

It should be:

${execi 60 cat /tmp/voltage | awk --non-decimal-data '{s="0x" substr($1,length($1)-1) ; print 0.7125+s*0.0125}'}

Last edited by livibetter (2012-03-05 14:25:46)

Offline

#12 2012-03-05 14:55:30

Lockheed
Member
Registered: 2010-03-16
Posts: 1,550

Re: Adcanved conky codding

Actually, I found the ideal solution to be

#!/bin/bash
while true
do
    rdmsr -0 0x198 | awk --non-decimal-data '{s="0x" substr($1,length($1)-1) ; print 0.7125+s*0.0125}' > /tmp/voltage
    sleep 2
done

and then call it from rc.local at boot, adding 'cat /tmp/voltage' to conky.

Offline

Board footer

Powered by FluxBB