Conky config with Lua
Conky is weird, Lua is weird... Why use it then? Well, a Conky dashboard on my desktop still looks cool.
Data to display
I want to see at a glance how much CPU, memory, GPU, network throughput, disk IO, etc. my system is using as well as current temperatures. Next to that I added "more static" information about OS, kernel, disk space, SMB shares.
In the second part I display server status like temperatures, fan speeds and power usage. This until I figure out how to do the same with Grafana. I think it has too much lag in updating the information. Besides, only one server runs non-stop, so Conky is needlessly polling the others most of the time, resulting in timeouts delaying Conky updates even more.
Hardware specs used for my config
- PC
- Lenovo P340
- CPU: Intel Xeon W-2150 (6-core, 12 threads)
- GPU: Nvidia Quadro P620
- SSD: Samsung NVMe PCIe gen 3x4
- Nic: 1 Gbit (configured as bridge)
- Server 1 (data backup server)
- Dell T320
- CPU: E5-2430 v2
- OS: Truenas Scale
- Server 2 (main server)
- HP DL380p G9
- CPU: E5-2640 v4
- OS: Proxmox
- Server 3 (jodiBooks test server)
- HP ML350p G9
- CPU: 2x E5-2640 v4
- OS: Proxmox
- Server 4 (test server / backup of main)
- Custom build, Supermicro X10SRi-F
- CPU: E5-2640 v4
- OS: Proxmox
Template using Lua
The config is based on https://www.github.com/SZinedine/pomaria-side. The full code for my config is available on Github: https://github.com/joeplaa/joeplaa-conky.
I re-arranged the template a lot and added additional data. The main change is the addition of a second panel that displays server information gathered with ssh
and ipmitool
. This cannot be the best way to poll servers, but I still have to figure out a better way to visualize this data. I think a combination of SNMP, Prometheus/Influx and Grafana would be better.
This is not a regular plain Conky config file. It uses Lua to write functions that can be re-used throughout the configuration. Lua is very limited compared to other languages and documentation and examples are not always easy to find. Especially the combination of Lua with Conky. Conky has variables to read and parse data, but how this is implemented in this template is still a mystery to me. It took me a while to understand this enough to customize it to my needs, but I got there.
Setup
The template consist of 3 main files containing all the basic information:
env.lua
stores all credentials. In my case ipmi credentials for my servers.settings.lua
contains settings like network interface name, maximum network/internet speeds, CPU cores/threads, etc.abstract.lua
contains all the functions to read, manipulate and display data.
Then there are two plain conkyrc
files that describe the Conky layout. One for the PC panel, one for the server panel. These point to the Lua config files which are used to describe the layout of all the data that is displayed in the panels:
start_pc.lua
start_server.lua
Start/stop during development
I haven't found an easier way to stop/reload Conky during development. If you update the start_xx.lua
files, the changes are reloaded automatically. But a change in settings
or abstract
doesn't trigger a reload. I had to manually stop the running conky process and restart it.
- In a terminal either start conky using the script
./start_conky_pc.sh
or runconky -c conkyrc_pc
- Edit files and save.
- In a second terminal open
htop
and search (F3
) forconkyrc_pc
- Press
F9
twice and pressenter
- The conky window should disappear. If not, try again.
Start on boot
To start Conky on boot run the shell scripts after logging in. In Ubuntu:
- Go to "Activities" or "Applications" and search for "Startup".
- Open the "Startup Applications Preferences" app.
- Add a new program:
- Name:Conky PC
- Command:<path to repository>/joeplaa-conky/start_conky_pc.sh
- Comment: leave blank or enter whatever you like - Add a new program:
- Name:Conky Servers
- Command:<path to repository>/joeplaa-conky/start_conky_server.sh
- Comment: leave blank or enter whatever you like
- Add a new program: