]> git.ipfire.org Git - thirdparty/collectd.git/commitdiff
text protocol: Add support for meta_data in PUTVAL
authorRafael Marinheiro <marinheiro@google.com>
Fri, 23 Mar 2018 17:08:47 +0000 (13:08 -0400)
committerDagobert Michelsen <dam@opencsw.org>
Wed, 19 Feb 2020 16:58:55 +0000 (17:58 +0100)
This adds the support for string meta_data in PUTVAL. This allows users
to send meta_data using either the unixsock plugin or the exec plugin.

The meta_data is specified using options of the form meta:<KEY>=<VALUE>.
As an example, meta:foo=bar will add an entry with key "foo" and value
"bar".

src/utils/cmds/putval.c

index b6d5ccc67ca9745bf4cade937d4fb82bf44e4a83..11f0fcb61edf4dacfec4a4000980066f2a12723b 100644 (file)
@@ -49,9 +49,17 @@ static int set_option(value_list_t *vl, const char *key, const char *value) {
 
     if ((errno == 0) && (endptr != NULL) && (endptr != value) && (tmp > 0.0))
       vl->interval = DOUBLE_TO_CDTIME_T(tmp);
-  } else
+  } else if (strncasecmp("meta:", key, 5) == 0) {
+    if (vl->meta == NULL) {
+      vl->meta = meta_data_create();
+      if (vl->meta == NULL) {
+        return 1;
+      }
+    }
+    return meta_data_add_string(vl->meta, key + 5, value);
+  } else {
     return 1;
-
+  }
   return 0;
 } /* int set_option */