Conky: Dual Core Processors in .conkyrc

Posted by on Mar 27, 2008 in Conky, Programming, Technology, Ubuntu9 commentsPrint This Post

OK, this is a bit of a cheeky post, since I’m merely extending a previous post “Conky on Ubuntu 64 Bit – .conkyrc” – or elaborating on it – to clarify setting up .conkyrc for Dual Core Processors – specifically for my AMD Turion 64 X2. I’ve had a few requests specifically about this, so here goes…

Now, the part of my .conkyrc file that deals with my Dual Core looks like this:

${color #42AE4A}Usage (Avg):${color #42AE4A} ${freq_dyn_g}Ghz ${color lightgrey}${cpu cpu0}% ${alignr}${color #42AE4A}${cpubar cpu0 5,80}
${color #42AE4A}Usage (Core 1):${color #42AE4A} ${freq_dyn_g cpu1}Ghz ${color lightgrey}${cpu cpu1}% ${alignr}${color #42AE4A}${cpubar cpu1 5,80}
${color #42AE4A}Usage (Core 2):${color #42AE4A} ${freq_dyn_g cpu2}Ghz ${color lightgrey}${cpu cpu2}% ${alignr}${color #42AE4A}${cpubar cpu2 5,80}
${color #42AE4A}Average
${cpugraph cpu0 42AE4A eeeeee}
${color #42AE4A}Core 1 $alignr Core 2
${color #42AE4A}${cpugraph cpu1 25,120 42AE4A eeeeee} ${color #42AE4A} $alignr${color #42AE4A}${cpugraph cpu2 25,120 42AE4A eeeeee}
${color #42AE4A}Processes:${color lightgrey} $processes ${color #42AE4A}Run:${color lightgrey} $running_processes ${color #42AE4A}CPU Temp:${color lightgrey} ${execi 1100 cat /proc/acpi/thermal_zone/THRM/temperature | grep -o "[0-9]* C"}
${color #42AE4A}Core 1 Temp: ${color lightgrey}${execi 8 sensors | grep -A 1 'Core0' | cut -c13-16 | sed '/^$/d'} C ${color #42AE4A}Core 2 Temp: ${color lightgrey}${execi 8 sensors | grep -A 1 'Core1' | cut -c13-16 | sed '/^$/d'} C

This outputs the following to Conky:

Conky Dual Core CPU Output

Stripping out all the formatting, and colouring gives this:

Usage (Avg): ${freq_dyn_g}Ghz ${cpu cpu0}% ${alignr}${cpubar cpu0 5,80}
Usage (Core 1): ${freq_dyn_g cpu1}Ghz ${cpu cpu1}% ${alignr}${cpubar cpu1 5,80}
Usage (Core 2): ${freq_dyn_g cpu2}Ghz ${cpu cpu2}% ${alignr}${cpubar cpu2 5,80}
Average
${cpugraph cpu0 42AE4A eeeeee}
Core 1 $alignr Core 2
${cpugraph cpu1 25,120 42AE4A eeeeee} $alignr${cpugraph cpu2 25,120 42AE4A eeeeee}
Processes: $processes Run: $running_processes CPU Temp: ${execi 1100 cat /proc/acpi/thermal_zone/THRM/temperature | grep -o "[0-9]* C"}
Core 1 Temp: ${execi 8 sensors | grep -A 1 'Core0' | cut -c13-16 | sed '/^$/d'} C Core 2 Temp: ${execi 8 sensors | grep -A 1 'Core1' | cut -c13-16 | sed '/^$/d'} C

Now the walk through. The first line, Usage (Avg): ${freq_dyn_g}Ghz ${cpu cpu0}% ${alignr}${cpubar cpu0 5,80} gives the Average clock speed usage for both cores – ${freq_dyn_g} with no parameters, will output the current clock speed usage for the CPU as a whole. Passing cpu0 as a parameter to ${cpu} will output the overall CPU % used, and similarly, passing cpu0 to ${cpubar} will draw the overall % used graph (the parameters 5,80 are just for the height and width.

Now, by passing cpu1 or cpu2 to ${freq_dny_g}, ${cpu} and ${cpubar} Conky will output the same data but for each individual core. This can be extended by passing cpuN where N is the core number, for quad core etc. this could be cpu3 cpu4. So, the first three lines:

Usage (Avg): ${freq_dyn_g}Ghz ${cpu cpu0}% ${alignr}${cpubar cpu0 5,80}
Usage (Core 1): ${freq_dyn_g cpu1}Ghz ${cpu cpu1}% ${alignr}${cpubar cpu1 5,80}
Usage (Core 2): ${freq_dyn_g cpu2}Ghz ${cpu cpu2}% ${alignr}${cpubar cpu2 5,80}

Outputs:

Conky Dual Core CPU Usage

The next lines of the file deal with throughput/usage graphs, ${cpugraph cpu0 42AE4A eeeeee} being the average for the CPU as a whole, since cpu0 is passed as a parameter. 42AE4A and eeeeee are just colour parameters to create a gradient overlay on the graph. As before, passing cpu1 and cpu2 will draw the graphs for the individual cores. The additional parameters, 25,120 are again just height and width parameters.

So, the lines

Average
${cpugraph cpu0 42AE4A eeeeee}
Core 1 $alignr Core 2
${cpugraph cpu1 25,120 42AE4A eeeeee} $alignr${cpugraph cpu2 25,120 42AE4A eeeeee}

Will output:

Conky Dual Core CPU Throughput Graphs

Finally, I have a bunch of other data output, such as total processes, processes running, and CPU temperature. The first line outputs general information about the CPU as a whole:

Processes: $processes Run: $running_processes CPU Temp: ${execi 1100 cat /proc/acpi/thermal_zone/THRM/temperature | grep -o "[0-9]* C"}

$processes outputs the total number of processes, while $running_processes outputs the number of currently running processes on the CPU. To output the overall temperature, I had to call the execi function, and do some tweaking of the output to get the number, so ${execi 1100 cat /proc/acpi/thermal_zone/THRM/temperature | grep -o “[0-9]* C”} basically outputs /proc/acpi/thermal_zone/THRM/temperature, pipes the output through grep which searches for the regular expression ‘[0-9]* C’ (which matches a string of numbers followed by a space followed by an upper-case C), and thus outputs just the temperature value – e.g. “45 C”.

To output the temperature of each Core, I once again run the execi function on a couple of piped shell commands, and pipe the output through other shell commands to get the number I want:

Core 1 Temp: ${execi 8 sensors | grep -A 1 'Core0' | cut -c13-16 | sed '/^$/d'} C Core 2 Temp: ${execi 8 sensors | grep -A 1 'Core1' | cut -c13-16 | sed '/^$/d'} C

Basically what is happening here is I’m running the shell command sensors, piping to grep to search for the string “Core0“, piing this output to cut to trim it, and finally editing out some of the crap I don’t want by piping to sed. This is just repeated for Core1. You may need to customise the output from sensors, by greping, cutting and seding different stuff – experiment by opening a terminal, and running sensors, then just pipe it through the grep, cut, and sed commands until you get the data you want.

So, the final lines together:

Processes: $processes Run: $running_processes CPU Temp: ${execi 1100 cat /proc/acpi/thermal_zone/THRM/temperature | grep -o "[0-9]* C"}
Core 1 Temp: ${execi 8 sensors | grep -A 1 'Core0' | cut -c13-16 | sed '/^$/d'} C Core 2 Temp: ${execi 8 sensors | grep -A 1 'Core1' | cut -c13-16 | sed '/^$/d'} C

Output:

Conky Dual Core CPU Misc Info

Of course, this should work on any Linux distro with Conky installed.

Hope that helps someone.


Something not quite right? Inaccuracies or invalid code? Didn’t work for you? Don’t like me using Ss instead of Zs? Add a comment below! All comments are welcome. Except spam, because spam is a bit crap.



ASUS Lamborghini VX6-PU17-BK 12.1-Inch Eee PC Netbook (Black)


ASUS Lamborghini VX6-PU17-BK 12.1-Inch Eee PC Netbook (Black)


$685.70


Asus Lamborghini VX6-PU17-BK 12.1″ LED Netbook – Atom D525 1.80 GHz – Black VX6-PU17-BK 41…

T101MT-BU17-BK 10.1 Netbook


T101MT-BU17-BK 10.1 Netbook


$599.99


Asus Eee PC T101MT-BU17-BK 10.1″ LED Net-tablet PC – Atom N450 1.66 GHz – Black T101MT-BU17-BK 202…

CellularFactory: Laptop Computer Security Cable Lock (Silver) for Asus laptop


CellularFactory: Laptop Computer Security Cable Lock (Silver) for Asus laptop


$7.99


Laptop Computer Security Cable Lock (Silver) for Asus laptop . Laptop Computer Security Cable Lock for you to use to lock your laptop computer in an easy way.Features:Lock down your notebooks laptop computer with this unique, individual keys and locks for each computer. Galvanized steel cable for strong protectionEffective protection, anti-thief design keeps the sneakers away The T-bar mechanism b…

ASUS Eee PC For Dummies


ASUS Eee PC For Dummies


$7.21


What can you do with your Eee PC? Find out how to get the most from this mini-laptop with Asus Eee PC For Dummies. It shows you how to get things done—using the Linux operating system and applications, navigating the tabbed desktop, adding hardware and software, backing up and restoring the Eee PC, and more.You’ll learn how to set up Windows, take advantage of all the pre-installed softw…

KOREAN KEYBOARD STICKERS WITH WHITE LETTERING ON TRANSPARENT BACKGROUND FOR DESKTOP, LAPTOP AND NOTEBOOK


KOREAN KEYBOARD STICKERS WITH WHITE LETTERING ON TRANSPARENT BACKGROUND FOR DESKTOP, LAPTOP AND NOTEBOOK


$2.36


High-quality stickers for different keyboards Desktop, Laptop and Notebook such as: Sony, Toshiba, HP, Dell, Compaq, Panasonic, Acer, Gateway, Sharp, eMachines, Ashton Digital’s Passport, Averatec, Systemax, IBM, Lenovo, NEC, Alienware, AST, Asus, Samsung, Cybertron, Apple, Macintosh Computers, Power Mac, Apple iBook, Apple PowerBook, Apple iMac etc. The Korean Alphabet is spread onto transparent …

No related posts.

Related posts brought to you by Yet Another Related Posts Plugin.

Tags: , , , , , ,

9 comments

» Comments RSS Feed
  1. [...] I’ve also recently written a post which deals specifically with setting up Dual Core processors – Conky: Dual Core Processors in .conkyrc [...]

  2. [...] ser exactos estas 2: Conky-gon (sacado del repositorio de configuraciones oficiales de conky) y Conky: Dual Core Processors in .conkyrc Tomé lo que me agradó más de cada una y lo uní o modifiqué a mi archivo de [...]

  3. “…pipes the output through grep searching for the string ‘temperature’, and finally pipes this output through sed to edit it and strip out the string “temperature: ” (including lots of space characters, for me anyway – I probably should write a regex for this, but just can’t be arsed at the moment).”

    ?? why do you need the grep AND the sed?

    ‘cat /proc/acpi/thermal_zone/THRM/temperature’ for me just outputs ‘temperature: 43 C’

    so this will do:

    cat /proc/acpi/thermal_zone/THRM/temperature | grep -o “[0-9]* C”

  4. Simon: no idea mate, lol. Seemed like a good idea at the time.
    Tutorial update, cheers :)

  5. Thank you very very much

  6. when i set up the separate temps for the cores, i get three valueson core 0 and two on core one. which is the value needed, and how do i remove the others i don’t need?

  7. Thanks! Ive been looking around for a good example like this! Time to tweak it a bit =0

  8. [...] Weitere interessante Seiten: Dual Core Processors in Conky [...]

  9. Thanks, you solved my problem whit a i5 650, but my conky output shows, just after the code that is supposed to be hidden.

Leave a comment