How to Configure the Conky System Monitor


1. Introduction

On Kubuntu I use a plasmoid for monitoring key system performance indicators like CPU Temperature, CPU Performance, Network traffic and memory usage. In GNOME you can use gDesklets http://www.gdesklets.de/ which are supposed to be the equivalent of KDEs Plasmiods. However, a more popular option is to use the light-weight system monitor called Conky http://conky.sourceforge.net/.

My preference is for Conky, lightweight, flexible and powerful. Its one downside is that it can be a pain to set-up unless you are given a helping hand. Hopefully, this blog will be of some assistance!

2. Installing Conky

As well as needing Conky installed, you also need to install lm-sensors http://www.lm-sensors.org/ which are the hardware monitoring sensors.

A. Install LM-SENSORS

To install lm-sensors enter from terminal:

sudo apt-get install lm-sensors

Now configure the sensors by entering:

sudo sensors-detect

Reply yes to all questions including the last one to insert the detected sensor modules into /etc/modules.

Now test what is being detected by entering:

sensors

This will display all detected sensor devices

B. Install Conky

To install Conky enter from terminal:

sudo apt-get install conky

From the root of your home drive, create a file in your favorite text editor called .conkyrc

Note the preceding period in front of the file name which makes this file hidden.

Below is my modified version of the Pengo script. Select the text and copy it into a file called .conkyrc. and save it in the root of your Home directory.

Alternatively, you can download a copy from here , again saving it in the root of your Home directory.

# UBUNTU-CONKY

# A comprehensive conky script, configured for use on

# Ubuntu / Debian Gnome, without the need for any external scripts.

#

# Based on conky-jc and the default .conkyrc.

# INCLUDES:

# – tail of /var/log/messages

# – netstat connections to your computer

#

# — Pengo (conky@pengo.us)

#

# Create own window instead of using desktop (required in nautilus)

own_window yes

own_window_type override

own_window_hints below

# Use double buffering (reduces flicker, may not work for everyone)

double_buffer yes

# fiddle with window

use_spacer yes

use_xft no

# Update interval in seconds

update_interval 3.0

#Maximum Width of Window

maximum_width 320

# Minimum size of text area

# minimum_size 250 5

# Draw shades?

draw_shades no

# Text stuff

draw_outline no # amplifies text if yes

draw_borders no

font arial

uppercase no # set to yes if you want all text to be in uppercase

# Stippled borders?

stippled_borders 3

# border margins

border_margin 5

# border width

border_width 6

# Default colors and also border colors, grey90 == #e5e5e5

default_color FFFFCC

own_window_colour brown

own_window_transparent yes

# Text alignment, other possible values are commented

#alignment top_left

alignment top_right

#alignment bottom_left

#alignment bottom_right

# Gap between borders of screen and text

gap_x 10

gap_y 10

# stuff after ‘TEXT’ will be formatted on screen

TEXT

$color

${color CC9900}SYSTEM ${hr 2}$color

$nodename $sysname $kernel on $machine

${color CC9900}CPU ${hr 2}$color

AMD Athlon(tm) 64 Socket 939 X2 Dual Core CPU 4200+

Total CPU: ${cpu cpu0}%

${color 597DB2}${cpubar}$color

${cpugraph 000000 597DB2}

Core 1: ${freq 1} MHz Temprature: $color ${exec sensors|grep ‘Core0’|awk ‘{print $3}’}

${cpu cpu1}% ${color 597DB2}${cpubar cpu1}$color

Core 2: ${freq 2} MHz Temprature: $color ${exec sensors|grep ‘Core1’|awk ‘{print $3}’}

${cpu cpu2}% ${color 597DB2}${cpubar cpu2}$color

NAME PID CPU% MEM%

${color CCFFFF}${top name 1} ${top pid 1} ${top cpu 1} ${top mem 1}

${top name 2} ${top pid 2} ${top cpu 2} ${top mem 2}

${top name 3} ${top pid 3} ${top cpu 3} ${top mem 3}

${top name 4} ${top pid 4} ${top cpu 4} ${top mem 4}$color

${color CC9900}MEMORY ${hr 2}$color

RAM Used: ${mem} RAM Free: ${memfree}/ ${memmax}

RAM: $memperc% ${color FF6600} ${membar 6}$color

Swap: $swapperc% ${color FF6600} ${swapbar 6}$color

${color CC9900}DISK ${hr 2}$color

sdc5 ${fs_type} (Root): ${fs_free_perc /}% ${color FFFF33} ${fs_bar 6 /}$color

sdc1 NTFS (Data): ${fs_free_perc /media/data}% ${color FFFF33} ${fs_bar 6 /media/data}$color

${color CC9900}NETWORK (${addr eth1}) ${hr 2}$color

Down: $color${downspeed eth1} k/s ${alignr}Up: ${upspeed eth1} k/s

${downspeedgraph eth1 25,140 000000 ff0000} ${alignr}${upspeedgraph eth1

25,140 000000 00ff00}$color

Total: ${totaldown eth1} ${alignr}Total: ${totalup eth1}

Inbound: ${tcp_portmon 1 32767 count} Outbound: ${tcp_portmon 32768

61000 count}${alignr}Total: ${tcp_portmon 1 65535 count}

${color CC9900}LOGGING ${hr 2}$color

${color 339900}${execi 30 tail -n3 /var/log/messages | fold -w50}$color

3. Running Conky

When you are ready, either press <ALT>+<F2> and enter conky or from terminal enter conky. Either way, Conky will run based on the configuration of your .conkyrc file you saved earlier.

4. Customising Conky

Two useful tables detailing the syntax of commands used in the .conkyrc file are available from theConky website

Config Settings http://conky.sourceforge.net/config_settings.html

Config Variables http://conky.sourceforge.net/variables.html

For ACSII colour codes see http://html-color-codes.com/

The .conkyrc configuration file is split into two sections:

  • Section 1 – General Configuration: This is text between # UBUNTU-CONKY line and # stuff after ‘TEXT’ will be formatted on screen
  • Section 2 – System Monitoring Parameters: This is text after # stuff after ‘TEXT’ will be formatted on screen onwards!

Section 1 – General Configuration

These lines detail the general layout, colours, size and behavior of the Conky window. Reference the Config Settings link above for more information.

The elements which I found useful for setting up my display were:

maximum_width 320

Sets the maximum width of the window. Height is variable depending on the number of lines of information you display.

default_color FFFFCC

Sets the default colour of text, in this case to Light yellow, See the ACSII colour code table link above for more colour codes

own_window_colour brown

Sets window background colour, this can be a name of a colour or ASCII colour code

own_window_transparent yes

Makes the background transparent or not (yes or no), depends on the colour of your wallpaper whether this is useful. On the default Ubuntu wallpaper it was unhelpful as the text colours merged with the background.

own_window_type override

Stops the Conky window disappearing when you click on the desktop! Highly recommended!

Section 2 – System Monitoring Parameters

This is laid out in the order it will be displayed in the window. So the first element is

$[color ######} text xyz $color

This sets the colour of the preceding text and the text colour is reverted back to the default colour (set by default_colour in section 1) with $color

In our example each section is grouped, the first one is SYSTEM which is preceded with ${hr 2} this sets the height of the line, this has already been set to light brown by the color command.

If you want to enter text to be displayed as part of the window content, you just enter it as normal e.g. AMD Athlon(tm) 64 Socket 939 X2 Dual Core CPU 4200+. Anything not prefixed with a $ is treated as text.

The horizontal positioning of the text can be done either with the <TAB> key or the <space-bar>. Vertical spacing is done by pressing the <Enter> key.

Using the Config Variables (see link above) you can probably work out the rest of the code in the file, with one exception!

Whilst most CPUs can be read using acpixxxxx variables e.g. acpitemp to read the CPU temperature, AMD CPUs can not be read in this way as they use k8temp-pci-00c3 http://www.mjmwired.net/kernel/Documentation/hwmon/k8temp.

You would have established when configuring LM-SENSORS if the k8temp sensor was being used on your motherboard. As you would have had a result like

8temp-pci-00c3

Adapter: PCI adapter

Core0 Temp: +35.0°C

Core1 Temp: +30.0°C

The lines

Core 1: ${freq 1} MHz Temprature: $color ${exec sensors|grep ‘Core0’|awk ‘{print $3}’}

Core 2: ${freq 2} MHz Temprature: $color ${exec sensors|grep ‘Core1’|awk ‘{print $3}’}

in .conkyrc are used to display the core temperature results which are obtained from the temp1 and temp3 files located in /sys/bus/pci/drivers/k8temp/0000:00:18.3.

I’ve now explained the essentials necessary to getting started in creating your own customised Conky display. Hopefully, the rest of the code in .conkyrc should now be more meaningful.

TIP: When making code changes, copy and paste the code you wish to change below the old code. Modify the pasted version, save and reload Conky from terminal.

5. Automatically Running Conky at Boot

If you want to automatically load Conky every time yo run Ubuntu, then you will need to write a short script to delay Conky starting immediately on boot, otherwise you will get a shadow behind your Conky Window.

The script looks like

#!/bin/bash

#Conky start-up delay script

sleep 20 && conky;

A copy of the script can be downloaded from here.

The sleep 20 parameter causes the script to wait 20 seconds before conky is started. I’ve found on my PC that a 10 second delay is sufficient.

I would recommend you create a scripts directory in the root of your home drive and save it in it with a meaningful name like conky_delay_start.

Having created and saved your script, you now need to change it from a plain text file in to an executable text file.

From the scripts directory enter

chmod 755 conky_delay_start

to make the script executable.

Now to get the script to run on boot-up, add it to Preference > Start-up Applications like so

Restart your PC and Conky will load automatically.

=-=-=-=-=
Powered by Bilbo Blogger

19 thoughts on “How to Configure the Conky System Monitor

  1. I learned a whole lot browsing and reading through your blog. Reading different points of view does help me think outside my box. Appreciate the information. Thanks.

  2. Thank you so much for this howto; I was beginning to go “conky” because everybody on the net keeps babbling about how awesome their configs are, but nobody told me how it WORKS and how to set it up proper.

    Well done, sir.

  3. Many thanks for the tutorial. I modified your script for my own settings, disks, etc. It was a great help getting me started. I’m running Arch with openbox.

  4. Two questions:
    I have AMD Athlon 64 X2 Dual Core4200+ but the sensors command reports two temperatures for each core instead of just one temp for each core. I’ve googled it out a bit and it seems that it could have to do with hyperthreading so it’s ok, I guess. The problem is how do I show just one temperature in conky? Which temperature is important? For example, sensors | grep ‘Core’ gives:
    Core0 Temp: +49.0°C
    Core0 Temp: +46.0°C
    Core1 Temp: +52.0°C
    Core1 Temp: +46.0°C

    Second problem is (which by your screenshot I see you have too) that conky shows some strange symbols/characters after floated-point number that represents temperature.
    The character is A with some dot on top and it’s between the temperature number and Celsius symbol (and that small circle).
    How to fix that?

  5. Thank you…I finaly have my temperatures in conky.

    BTW: for my intel i5 I modify it like this:

    ${exec sensors|grep “Core 0″|cut -c18-24}

    Do not forget run $ sensors-detect…and than run sensors daemon (add it to rc.conf)

  6. u r the wonderful teacher..

    i have one problem .. temp not detect..

    i had done ..
    sudo apt-get install lm-sensors .. done

    sudo sensors-detect ….done

    sensors ………not detected sensor devices

    please help me.
    THANK YOU.

    1. If sensors-detect returned “no” to all the possibilities, maybe you need to run it again and let it probe for more sensor types? The only thing I can think of…

  7. I have an old AMD processor and had to use:

    ${color grey}Temperature:$color ${color red} ${exec sensors | grep ‘temp2:’ | awk ‘{print $2}’}$color

    Your hack is beautiful in its exquisite ugliness…but if someone knows a better way, I am all ears. I have an AMD Athlon 2600+, 333 MHz FSB, on an ASROCK K7S41GX motherboard. sensors returns:

    w83697hf-isa-0290
    Adapter: ISA adapter
    in0: +1.66 V (min = +0.00 V, max = +0.13 V) ALARM
    in2: +3.33 V (min = +0.03 V, max = +0.26 V) ALARM
    in3: +2.94 V (min = +0.13 V, max = +0.00 V) ALARM
    in4: +3.17 V (min = +0.16 V, max = +0.02 V) ALARM
    in5: +3.20 V (min = +1.09 V, max = +3.07 V) ALARM
    in6: +3.25 V (min = +0.06 V, max = +0.86 V) ALARM
    in7: +3.28 V (min = +0.13 V, max = +0.00 V) ALARM
    in8: +3.47 V (min = +0.29 V, max = +0.06 V) ALARM
    fan1: 0 RPM (min = 84375 RPM, div = 8) ALARM
    fan2: 2812 RPM (min = 1318 RPM, div = 8)
    temp1: +30.0°C (high = +9.0°C, hyst = +14.0°C) ALARM sensor = thermistor
    temp2: +46.5°C (high = +120.0°C, hyst = +120.0°C) sensor = thermistor
    beep_enable:enabled

    which is clearly largely screwed up, but I’m gambling that temp2 is an actual temperature…

Leave a comment