]> git.ipfire.org Git - thirdparty/collectd.git/commitdiff
[collectd 6] contextswitch: migration to v6.0
authorManuel Luis SanmartĂ­n Rozada <manuel.luis@gmail.com>
Wed, 20 Jan 2021 23:02:18 +0000 (00:02 +0100)
committerMatthias Runge <mrunge@matthias-runge.de>
Fri, 10 Feb 2023 17:42:01 +0000 (18:42 +0100)
src/contextswitch.c

index d23d071713b0e77e5152d0e1c98673ce057c167a..544830494143c082a09a2276fa23286b6df47ac6 100644 (file)
 #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) {