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 Conkyhttp://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-00c3http://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 temp1and 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.