Skip to content

contrib: add a lua module allowing to display cdba board status with conky - #99

Open
brgl wants to merge 1 commit into
linux-msm:masterfrom
brgl:contrib/conky-lua
Open

contrib: add a lua module allowing to display cdba board status with conky#99
brgl wants to merge 1 commit into
linux-msm:masterfrom
brgl:contrib/conky-lua

Conversation

@brgl

@brgl brgl commented Sep 3, 2026

Copy link
Copy Markdown

Conky is a light-weight system monitor that can be easily customized with lua scripts.

I'm running my cdba lab with a small display using conky to display system information. I wrote this lua script that uses the information about the cdba lock files and the cdba config to determine which boards are being used and for how long.

It can be easily integrated into conky.conf like so:

$hr
${color grey}cdba:$color
${lua cdba 1 status}
${lua cdba 2 status}
${lua cdba 3 status}
${lua cdba 4 status}

I figured it may be useful to others and it makes sense to carry it in the cdba repo.

…conky

Conky is a light-weight system monitor that can be easily customized
with lua scripts. This adds a module that can be directly loaded via
conky.conf and be used to display information about current usage of
boards controlled by cdba.

Put the script under a new directory: contrib/. It'll be used to store
misc files that don't fit anywhere else.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Comment thread contrib/cdba.lua
local unistd = require("posix.unistd")

local function read_cdba_cfg()
local fd = assert(io.open("/home/cdba/.cdba", "r"))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

System-specific details. Also cdba might be using a central db (/etc/cdba) instead.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any suggestion on how to handle that?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use posix.getpwnam to locate cdba's home dir. If ~cdba/.cdba doesn't exist, resort to /etc/cdba.

Comment thread contrib/cdba.lua
return "ERROR: " .. err
end

local lock = match_lock(locks, st)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be easier to use luaflock instead of parsing /proc/locks?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, that requires CAP_SYS_PTRACE, my solution does not as it uses info available to an unprivileged user.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants