8000 [collectd 6] src/exec.c make the existing PUTMETRIC command available to scripts by hnez · Pull Request #4074 · collectd/collectd · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[collectd 6] src/exec.c make the existing PUTMETRIC command available to scripts #4074

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 23, 2023

Conversation

hnez
Copy link
Contributor
@hnez hnez commented Jan 11, 2023

ChangeLog: exec plugin: Make PUTMETRIC available as command

This PR adds the PUTMETRIC command to the list of commands available in the evalplugin.
This means you can now have scripts like these that natively uses the metric_* types introduced with collectd 6.

#!/bin/bash

while true
do
    echo "PUTMETRIC unit_test 42"
    echo "PUTMETRIC gauge type=GAUGE 42"
    echo "PUTMETRIC counter type=Counter 42"
    echo "PUTMETRIC untyped type=untyped 42"
    echo "PUTMETRIC quoted_gauge type=\"GAUGE\" 42"
    echo "PUTMETRIC with_interval interval=10.0 42"
    echo "PUTMETRIC with_time time=1594806526 42"
    echo "PUTMETRIC with_label label:unquoted=bare 42"
    echo "PUTMETRIC with_label label:quoted=\"with space\" 42"
    echo "PUTMETRIC multiple_label label:foo=1 label:bar=2 42"
    sleep $COLLECTD_INTERVAL
done

Existing exec scripts can keep using the PUTVAL command via the backward compatibility layer implemented in plugin_dispatch_values.

I've checked if there are any changes to the exec plugin in the main branch that did not land in collectd-6 yet, which is not the case.

Issue #3629 tracks the exec plugin migration progress. As far as I can tell this PR should tick the Update the exec plugin to produce a metric_family_t check mark.

hnez added 2 commits January 5, 2023 10:41
Most existing setups using exec will use PUTVAL, which should just continue
to work with collectd 6 due to the plugin_dispatch_values compatibility
function.
New plugins should however use the new PUTMETRIC.
The respective command handler already exists. This commit just pipes it
through.

Signed-off-by: Leonard Göhrs <l.goehrs@pengutronix.de>
The cmd_handle_putmetric function checks if the command actually is
a PUTMETRIC command, at least that is what is supposed to check.
Prior to this fix it actually checked for PUTVAL and always prints a

    -1 Unexpected command: `PUTMETRIC'.

error. While at it also remove the development printf that results in

    set_option("type", "GAUGE")
    set_option("type", "Counter")
    …

being printed during normal operation.

Signed-off-by: Leonard Göhrs <l.goehrs@pengutronix.de>
@eero-t
Copy link
Contributor
eero-t commented Jan 11, 2023

Looks OK. How much did you test it?

@hnez
Copy link
Contributor Author
hnez commented Jan 30, 2023

How much did you test it?

Not much more than running the script in the initial PR comment for some iterations.
I will have to port the script we currently use via the exec plugin to PUTMETRIC to get some real-world experience.
To get said real-world collectd-6 experience we will however also have to change the plugin we use to get data out of the device away from the native network plugin, as that turned out to be a bit stubborn to port #3675.
So it could be some time before we see it in production.

@mrunge mrunge merged commit 7fa9584 into collectd:collectd-6.0 Apr 23, 2023
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.

4 participants
0