]> git.ipfire.org Git - thirdparty/collectd.git/commitdiff
[collectd 6] users: migration to v6.0
authorManuel Luis Sanmartín Rozada <manuel.luis@gmail.com>
Wed, 20 Jan 2021 22:29:30 +0000 (23:29 +0100)
committerManuel Luis Sanmartín Rozada <manuel.luis@gmail.com>
Wed, 20 Jan 2021 22:29:30 +0000 (23:29 +0100)
src/users.c

index 768d48818fb1c7e17835860270fe02a282e15a56..e5790cd097275b43aa4039b47689341e8358793d 100644 (file)
 #endif
 
 static void users_submit(gauge_t value) {
-  value_list_t vl = VALUE_LIST_INIT;
-
-  vl.values = &(value_t){.gauge = value};
-  vl.values_len = 1;
-  sstrncpy(vl.plugin, "users", sizeof(vl.plugin));
-  sstrncpy(vl.type, "users", sizeof(vl.plugin));
+  metric_family_t fam = {
+      .name = "users",
+      .type = METRIC_TYPE_GAUGE,
+  };
+
+  metric_family_metric_append(&fam, (metric_t){
+                                        .value.gauge = value,
+                                    });
+
+  int status = plugin_dispatch_metric_family(&fam);
+  if (status != 0) {
+    ERROR("users plugin: plugin_dispatch_metric_family failed: %s",
+          STRERROR(status));
+  }
 
-  plugin_dispatch_values(&vl);
-} /* void users_submit */
+  metric_family_metric_reset(&fam);
+}
 
 static int users_read(void) {
 #if HAVE_GETUTXENT