From: Manuel Luis SanmartĂ­n Rozada Date: Wed, 20 Jan 2021 23:02:18 +0000 (+0100) Subject: [collectd 6] contextswitch: migration to v6.0 X-Git-Tag: 6.0.0-rc0~72 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d0a61a43de12763fa1d121a5b871b3124369c91b;p=thirdparty%2Fcollectd.git [collectd 6] contextswitch: migration to v6.0 --- 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) {