]> git.ipfire.org Git - thirdparty/collectd.git/commitdiff
[collectd 6] cpusleep: migration to v6.0
authorManuel Luis SanmartĂ­n Rozada <manuel.luis@gmail.com>
Wed, 20 Jan 2021 23:37:12 +0000 (00:37 +0100)
committerMatthias Runge <mrunge@matthias-runge.de>
Thu, 9 Sep 2021 05:47:29 +0000 (07:47 +0200)
src/cpusleep.c

index ee26b0b3d23ef55610a098280476ecf1b6510da9..2d4e7f05b59211b377a5944ac44f3aec2477d5ea 100644 (file)
 #include "utils/common/common.h"
 #include <time.h>
 
-static void cpusleep_submit(derive_t cpu_sleep) {
-  value_list_t vl = VALUE_LIST_INIT;
+static void cpusleep_submit(counter_t cpu_sleep) {
+  metric_family_t fam = {
+      .name = "cpusleep_milliseconds_total",
+      .type = METRIC_TYPE_COUNTER,
+  };
 
-  vl.values = &(value_t){.derive = cpu_sleep};
-  vl.values_len = 1;
-  sstrncpy(vl.plugin, "cpusleep", sizeof(vl.plugin));
-  sstrncpy(vl.type, "total_time_in_ms", sizeof(vl.type));
+  metric_family_metric_append(&fam, (metric_t){
+                                        .value.counter = cpu_sleep,
+                                    });
 
-  plugin_dispatch_values(&vl);
+  int status = plugin_dispatch_metric_family(&fam);
+  if (status != 0) {
+    ERROR("cpusleep plugin: plugin_dispatch_metric_family failed: %s",
+          STRERROR(status));
+  }
+
+  metric_family_metric_reset(&fam);
 }
 
 static int cpusleep_read(void) {