From d0a61a43de12763fa1d121a5b871b3124369c91b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Manuel=20Luis=20Sanmart=C3=ADn=20Rozada?= Date: Thu, 21 Jan 2021 00:02:18 +0100 Subject: [PATCH] [collectd 6] contextswitch: migration to v6.0 --- src/contextswitch.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/contextswitch.c b/src/contextswitch.c index d23d07171..544830494 100644 --- a/src/contextswitch.c +++ b/src/contextswitch.c @@ -45,14 +45,22 @@ #endif static void cs_submit(derive_t context_switches) { - value_list_t vl = VALUE_LIST_INIT; + metric_family_t fam = { + .name = "context_switches_total", + .type = METRIC_TYPE_COUNTER, + }; - vl.values = &(value_t){.derive = context_switches}; - vl.values_len = 1; - sstrncpy(vl.plugin, "contextswitch", sizeof(vl.plugin)); - sstrncpy(vl.type, "contextswitch", sizeof(vl.type)); + metric_family_metric_append(&fam, (metric_t){ + .value.counter = context_switches, + }); - plugin_dispatch_values(&vl); + int status = plugin_dispatch_metric_family(&fam); + if (status != 0) { + ERROR("contextswitch plugin: plugin_dispatch_metric_family failed: %s", + STRERROR(status)); + } + + metric_family_metric_reset(&fam); } static int cs_read(void) { -- 2.47.2