How to collecd-mod-exec

I am struggling with the collecd-mod-exec plugin to add rrd data to luci-app-statistics.

What I would like to do, is to find out how to output a value from an arbitrary python skript in to luci-app-statistics graph.

I read that the user has to be setup correctly to execute the script so i have installed opkg install shadow and setup an user myusr that has execution rights on that file /home/myusr/ as described here.

I read that python print() by default writes to stdout, so the script could look like this to make it simple:

import time

timestamp = time.time()
value = '23.1'
sensor = '1'
print(f'PUTVAL {timestamp}, {sensor}:{value}')

How do I have to configure collectd-mod-exec to take the time and value and add it to the graph?

They are talking about regular Linux, not OpenWrt. Almost everything runs as root on OpenWrt and usually none of that is needed.

usualy yes, but not for collectd-mod-exec as described in the doc's it says:

The security concerns are addressed by forcing the plugin to check that custom programs are never executed with superuser privileges. If the daemon runs as root, you have to configure another user ID with which the new process is created. To circumvent missing access privileges to files, you need to lean on the unix group concept. I.e. your script requires access to /var/log/messages, which is owned by root, its common practice to have this file being group readable by the admin-group. Given the used ID corrosponds to MyWatcherUser, you need to add that user to the admin group via /etc/group (or what else manages users / groups on your system).

That's why I did all that user stuff.

My question is how to address luci-app-statistics graph trough collectd-mod-exec.

Look for the SQM stats module for example.
It has config and the graph definition in the Luci stats, but the main SQM stats collection script is in collectd


Thanks for that help.
I still have trouble to understand how to use collecd-mod-exec.

My config looks like this now:

config collectd_exec_input
	option cmdline '/home/novski/templogger/'
	option cmduser 'novski'
	option cmdgroup 'novski'

And this now appears in the graphical config of luci/statistics as well.

(I tried to use nobody and nogroup here unsuccessfully.)

I have saved a simple script in /home/novski/templogger and made it executable:

 while sleep "$INTERVAL"; do
   echo "PUTVAL \"$HOSTNAME/home/novski/templogger/\" interval=$INTERVAL N:$VALUE"

It prints the PUTVAL every 60s to stdout like this:

PUTVAL "localhost/home/novski/templogger/" interval=60 N:21.3
PUTVAL "localhost/home/novski/templogger/" interval=60 N:21.3

But luci/statistics still says:

How do I make my sample script to be shown as a graph in luci statistics?