When it comes to monitoring your Linux system, few tools can rival Conky. This lightweight system monitoring utility can help you to keep an eye on virtually any aspect of your system, and it offers a huge list of options to choose from. But this flexibility comes at a price: all Conky’s settings are stored in the .conkyrc file, which you have to create and tweak manually. The good news is that once you’ve understood the inner workings of the .conkyrc file, you can easily create rather powerful Conky configuration profiles.
Figure 1: Conky on ASUS Eee PC 701 4G
The .conkyrc file consists of two sections: the first one controls Conky’s appearance, while the second one determines what data to monitor. To separate these sections, Conky uses the TEXT marker. Since the .conkyrc file is just a plain text file, you can use your favorite text editor to work with it. The very first thing you have to do is to specify the update interval, or how often Conky “collects” the monitored data. This is done by specifying the update_interval option in seconds, for example: update_interval 1.0 or update_interval 3.0. Obviously, the exact value depends on how up-to-date data you need. On my Eee PC, changing the update interval doesn’t seem to have any adverse effect on the performance, so I usually set it to 1 second. By default, Conky is designed to superimpose the monitoring data directly onto your desktop (or as Conky’s documentation puts it “draw to the root desktop window”). While this looks pretty good, it quite often causes Conky to flicker, which can be quite annoying. Conky has two options to help you to deal with this problem. The double_buffer setting lets Conky use the X double-buffer extension that can eliminate flickering. If enabling double_buffer doesn’t help, you can use the own_window option that forces Conky to run in a separate window. To enable these options, add them to the .conkyrc file as follows:
double_buffer yes own_window yes
By default, Conky uses a monospaced font, but you can instruct it to use any font installed on your system by specifying the use_xft option followed by the xftfont setting. For example, if you want Conky to use the Bitstream Vera Sans 8pt font, these options will look like this:
use_xft yes xftfont Bitstream Vera Sans:size=8
Next step is to specify the Conky window’s settings, including its width, alignment, and default color. In the example below, the window width is set to 270 pixels, it uses white as its default color, and it is aligned to the top left corner.
maximum_width 270 default_color white alignment top_right
If you don’t want text in the Conky window to appear in all caps, use the uppercase option:
uppercase no
These are just a few essential configuration options that you can specify, but Conky has a lot more to choose from. Check the list of all available Conky configuration options on Conky’s Web site.
With the basic display options in place, you can start working on what system parameters you want Conky to monitor. This is done using so-called variables. For example, to display the kernel version of your system, you can use the kernel variable, and if you want Conky to show the hostname, you can do this by adding the nodename variable:
$nodename - $kernel
Note that each variable in the conkyrc file is preceded by the $ sign. Conky also includes a few variables that allow you to control the appearance of the output. The color variable lets you specify text color, while the alignr variable allows you to right-justify text. To see how this works in practice, let’s take a look at the following example:
${color lightgrey}Uptime:$color $uptime $alignr${color lightgrey}Load:$color $loadavg
The ${color lightgrey} variable sets the text color to light grey. To switch back to the default color (white), you can use the color variable without any parameter. As the name suggests, the uptime variable displays your machine’s uptime. As you can see from the example, you can combine several variables to achieve the desired effect. In this case, the $alignr${color lightgrey} variables are used to set color and right-justify text for the word “Load:” and the output of the loadavg variable, which displays the average processor load. In a similar manner, you can specify variables that display processor speed, and CPU usage:
${color lightgrey}CPU: $color ${freq} Mhz $alignr${color lightgrey} Usage:$color $cpu%
Conky also allows you to visualize monitored data using graphs. The cpugraph variable, for example, displays the CPU usage as a graph. When used without any parameters, the graph is shown using default solid color, but you can use HEX color values to specify gradients, which make the graph look much better:
${cpugraph 000000 ffffff}
You can use the memory-related variables to display the total amount of RAM (memmax), amount of memory in use (mem), and percentage of memory in use (memperc):
${color lightgrey}RAM usage:$color $mem/$memmax - $memperc%
You can also display these data as a bar graph using the membar variable: ${membar}.
<p>When it comes to monitoring disk usage, you have a few variables to choose from, including fs_free (free space) and fs_size (total size), and fs_bar (spaced used bar):</p>
${color grey}Disk usage: $color${fs_free /} of ${fs_size /}
${fs_bar 6 /}
Finally, let’s take a look at the variables that allow you to monitor wireless network connections. First of all, you have to find out the name of the network interface you want to monitor. To do this, you can use the ifconfig command, which returns a list of available network interfaces. Conky has quite a few variables that you can use to monitor the wireless connection, including the following:
wireless_essid (returns the ESSID name of the access point)wireless_mode (returns the wireless mode, e.g. Managed/Ad-Hoc/Master)wireless_bitrate (returns bitrate or speed, e.g. 11Mb/s)wireless_link_qual (returns wireless link quality)wireless_link_qual_perc (returns wireless link quality in percents)wireless_link_bar (returns the wireless link quality displays as a bar)Here is an example of how these variables can be used in the .conkyrc file:
${color #ffcb48}Wi-Fi ${hr 1}
${color lightgrey}Wireless signal: $color${wireless_link_qual ath0}%
${color lightgrey}IP address: $color${addr ath0}
If you want to monitor the download and upload speed, you can use the downspeedf and upspeedf variables (or downspeed and upspeed if you don’t want to display the trailing decimal):
${color lightgrey}Download speed: $color${downspeedf wifi0} Kb/sec
There are also the downspeedgraph and upspeedgraph variables, which can display the download and upload speeds as graphs. And if you want to monitor the total amount of downloaded and uploaded data (handy if you are using a connection where you pay for transfered data), then you can use the totaldown and totalup variables:
${color red}Downloaded: $color${totaldown wifi0} $alignr ${color green}Uploaded: $color${totalup wifi0}
To summarize all the above, here is a sample .conkyrc configuration file you can use as it is or tweak to fit your needs:
# .conkyrc
update_interval 1.0
double_buffer yes
own_window yes
use_xft yes
xftfont Bitstream Vera Sans:size=8
maximum_width 270
default_color white
alignment top_right
uppercase no
TEXT
$nodename - $kernel
${color lightgrey}Uptime:$color $uptime $alignr${color lightgrey}Load:$color $loadavg
${color lightgrey}CPU: $color ${freq} Mhz $alignr${color lightgrey} Usage:$color $cpu%
$color${cpugraph}
${color lightgrey}Processor temperature: $color${acpitemp}°C
${color lightgrey}Battery: $color ${battery}
${color lightgrey}RAM usage:$color $mem/$memmax - $memperc%
${membar}
${color grey}Disk usage: $color${fs_free /} of ${fs_size /}
${fs_bar 6 /}
${color #ffcb48}Wi-Fi ${hr 1}
${color lightgrey}Wireless signal: $color${wireless_link_qual ath0}%
${color lightgrey}IP address: $color${addr ath0}
${color lightgrey}Download speed: $color${downspeedf wifi0} Kb/sec
${downspeedgraph wifi0}
${color red}Downloaded: $color${totaldown wifi0} $alignr ${color green}Uploaded: $color${totalup wifi0}
${color #ffcb48}Ethernet ${hr 1}
${color lightgrey}IP address: $alignr$color${addr eth0}
For more Conky goodness, make sure to visit the Conky thread in the Ubuntu forums.
Related articles:
| Get the most out of your mouse with btnx | ||
| No-nonsense guide to configuring Conky |