System Monitoring on Ubuntu 18.04 Linux with Conky

Objective

The objective is to help reader to get started with system monitoring basics with Conky on Ubuntu 18.04 Bionic Beaver Linux.

Operating System and Software Versions

  • Operating System: – Ubuntu 18.04 Bionic Beaver Linux
  • Software: – conky 1.10.8

Requirements

Privileged access to your Ubuntu System as root or via sudo command is required.

Conventions

  • # – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
  • $ – requires given linux commands to be executed as a regular non-privileged user

Other Versions of this Tutorial

Ubuntu 20.04 (Focal Fossa)

Instructions

Conky is one of the oldest and perhaps most useful system monitoring utilities available on Linux. It is highly configurable as it is able to monitor literally any aspect of your system from hard-drive temperature through number of users logged in to currently played music song.

Conky installation on Ubuntu 18.04

Installation of Conky is plain simple. Open up terminal and enter:

$ sudo apt install conky-all


Enable Conky to Start at Boot

Next step is to enable conky to automaticaly start at the boot:

Startup Applications - Ubuntu 18.04

Find and open the Startup Applications which we will use to set Conky to start at the boot time.
 new startup program on Ubuntu 18.04

Hit the Add button and enter the application’s name and path /usr/bin/conky. Once ready Add the new startup program and reboot or re-login into your Ubuntu 18.04 system.
System monitoring on Ubuntu 18.04 - conky

Upon reboot or re-login you will be greeted with Conky’s default get you started system monitoring widget on your desktop.


Customizing Conky

At this stage we should have conky up and running so let’s do some basic customization. It is now obvious that running Conky system monitoring in the top-left position is not ideal.

For this, we need to change the alignment = 'top_left' line within /etc/conky/conky.conf to alignment = 'top_right'. This can be easily accomplished with the sed command:

$ sudo sed -i 's/left/right/' /etc/conky/conky.conf

Changing the system wide /etc/conky/conky.conf will result in changing the Conky configuration for all users registered on your Ubuntu system. Let’s create a single user defined Conky configuration file:

$ cp /etc/conky/conky.conf ~/.conkyrc

The above command created a user based Conky configuration file located at ~/.conkyrc. To apply changes we need to re-login or reboot our system.

Next, you may have noticed that network monitoring is not working. The reason for this is that Conky is listening on a front network interface.

Obtain the network interface name you wish to monitor and edit the Conky’s configuration file ~/.conkyrc by replacing all instances of the eth0 keyword with your network interface name. Once you perform the change Conky will automatically refresh.

Next, you can possibly make the Conky widget transparent and more smooth looking by adding the following lines into the top main config section of your ~/.conkyrc file:

	own_window_argb_visual = true,
	own_window_argb_value = 50,
	double_buffer = true,

Let’s add a new feature for example to display our external IP address.

Retrieve external IP address feature

Once again open your Conky configuration file ~/.conkyrc and add the following line which will retrieve your IP address:

${color grey}External IP: $color${execi 1000  wget -q -O- http://ipecho.net/plain; echo}
Monitoring external IP address

Conky is now monitoring your external IP address.


Conclusion

The possibility for the system monitoring of your Ubuntu 18.04 system with Conky are literally infinite. All you need is lots of imagination and knowledge. For more information and documentation run:

$ man conky

or visit the official Conky git page. Below you can find additional example for system monitoring with Conky on Ubuntu to get you started:

System Monitoring with Conky on Ubuntu 18.04 Linux

More feature rich and eye candy Conky configuration. The source code is included below.
conky.config = {
	
	update_interval = 1,
	cpu_avg_samples = 2,
	net_avg_samples = 2,
	out_to_console = false,
	override_utf8_locale = true,
	double_buffer = true,
	no_buffers = true,
	text_buffer_size = 32768,
	imlib_cache_size = 0,
	own_window = true,
	own_window_type = 'normal',
	own_window_argb_visual = true,
	own_window_argb_value = 50,
	own_window_hints = 'undecorated,below,sticky,skip_taskbar,skip_pager',
	border_inner_margin = 5,
	border_outer_margin = 0,
	xinerama_head = 1,
	alignment = 'bottom_right',
	gap_x = 0,
	gap_y = 33,
	draw_shades = false,
	draw_outline = false,
	draw_borders = false,
	draw_graph_borders = false,
	use_xft = true,
	font = 'Ubuntu Mono:size=12',
	xftalpha = 0.8,
	uppercase = false,
	default_color = 'white',
	own_window_colour = '#000000',
	minimum_width = 300, minimum_height = 0,
	alignment = 'top_right',

};
conky.text = [[
${time %H:%M:%S}${alignr}${time %d-%m-%y}
${voffset -16}${font sans-serif:bold:size=18}${alignc}${time %H:%M}${font}
${voffset 4}${alignc}${time %A %B %d, %Y}
${font}${voffset -4}
${font sans-serif:bold:size=10}SYSTEM ${hr 2}
${font sans-serif:normal:size=8}$sysname $kernel $alignr $machine
Host:$alignr$nodename
Uptime:$alignr$uptime
File System: $alignr${fs_type}
Processes: $alignr ${execi 1000 ps aux | wc -l}

${font sans-serif:bold:size=10}CPU ${hr 2}
${font sans-serif:normal:size=8}${execi 1000 grep model /proc/cpuinfo | cut -d : -f2 | tail -1 | sed 's/\s//'}
${font sans-serif:normal:size=8}${cpugraph cpu1}
CPU: ${cpu cpu1}% ${cpubar cpu1}

${font sans-serif:bold:size=10}MEMORY ${hr 2}
${font sans-serif:normal:size=8}RAM $alignc $mem / $memmax $alignr $memperc%
$membar
SWAP $alignc ${swap} / ${swapmax} $alignr ${swapperc}%
${swapbar}

${font sans-serif:bold:size=10}DISK USAGE ${hr 2}
${font sans-serif:normal:size=8}/ $alignc ${fs_used /} / ${fs_size /} $alignr ${fs_used_perc /}%
${fs_bar /}

${font Ubuntu:bold:size=10}NETWORK ${hr 2}
${font sans-serif:normal:size=8}Local IPs:${alignr}External IP:
${execi 1000 ip a | grep inet | grep -vw lo | grep -v inet6 | cut -d \/ -f1 | sed 's/[^0-9\.]*//g'}  ${alignr}${execi 1000  wget -q -O- http://ipecho.net/plain; echo}
${font sans-serif:normal:size=8}Down: ${downspeed enp0s3}  ${alignr}Up: ${upspeed enp0s3} 
${color lightgray}${downspeedgraph enp0s3 80,130 } ${alignr}${upspeedgraph enp0s3 80,130 }$color
${font sans-serif:bold:size=10}TOP PROCESSES ${hr 2}
${font sans-serif:normal:size=8}Name $alignr PID   CPU%   MEM%${font sans-serif:normal:size=8}
${top name 1} $alignr ${top pid 1} ${top cpu 1}% ${top mem 1}%
${top name 2} $alignr ${top pid 2} ${top cpu 2}% ${top mem 2}%
${top name 3} $alignr ${top pid 3} ${top cpu 3}% ${top mem 3}%
${top name 4} $alignr ${top pid 4} ${top cpu 4}% ${top mem 4}%
${top name 5} $alignr ${top pid 5} ${top cpu 5}% ${top mem 5}%
${top name 6} $alignr ${top pid 6} ${top cpu 6}% ${top mem 6}%
${top name 7} $alignr ${top pid 7} ${top cpu 7}% ${top mem 7}%
${top name 8} $alignr ${top pid 8} ${top cpu 8}% ${top mem 8}%
${top name 9} $alignr ${top pid 9} ${top cpu 9}% ${top mem 9}%
${top name 10} $alignr ${top pid 10} ${top cpu 10}% ${top mem 10}%
]];