]> git.ipfire.org Git - thirdparty/collectd.git/commitdiff
[collectd 6] mmc: port to collectd 6
authorLeonard Göhrs <l.goehrs@pengutronix.de>
Wed, 14 Dec 2022 12:23:14 +0000 (13:23 +0100)
committerMatthias Runge <mrunge@matthias-runge.de>
Fri, 17 Feb 2023 11:11:48 +0000 (12:11 +0100)
Signed-off-by: Leonard Göhrs <l.goehrs@pengutronix.de>
src/mmc.c

index e802f9ea275ba97004cd18d3a3c70c80051acb10..6ab286f566bd8439fb8a8a0714d572b1256fe0a4 100644 (file)
--- a/src/mmc.c
+++ b/src/mmc.c
@@ -85,16 +85,28 @@ static int mmc_config(const char *key, const char *value) {
   return 0;
 }
 
-static void mmc_submit(const char *dev_name, const char *type, gauge_t value) {
-  value_list_t vl = VALUE_LIST_INIT;
+static void mmc_submit(const char *dev_name, char *type, gauge_t value) {
+  metric_family_t fam = {
+      .name = type,
+      .type = METRIC_TYPE_GAUGE,
+  };
+
+  metric_t m = {
+      .family = &fam,
+      .value = (value_t){.gauge = value},
+  };
 
-  vl.values = &(value_t){.gauge = value};
-  vl.values_len = 1;
-  sstrncpy(vl.plugin, PLUGIN_NAME, sizeof(vl.plugin));
-  sstrncpy(vl.plugin_instance, dev_name, sizeof(vl.plugin_instance));
-  sstrncpy(vl.type, type, sizeof(vl.type));
+  metric_label_set(&m, "device", dev_name);
+  metric_family_metric_append(&fam, m);
+
+  int status = plugin_dispatch_metric_family(&fam);
+  if (status != 0) {
+    ERROR(PLUGIN_NAME ": plugin_dispatch_metric_family failed: %s",
+          STRERROR(status));
+  }
 
-  plugin_dispatch_values(&vl);
+  metric_reset(&m);
+  metric_family_metric_reset(&fam);
 }
 
 static int mmc_read_manfid(struct udev_device *mmc_dev, int *value) {