From 6c3106f61987a975dce7faed29c298cbeda0cfa8 Mon Sep 17 00:00:00 2001 From: Rafael Marinheiro Date: Fri, 23 Mar 2018 13:08:47 -0400 Subject: [PATCH] text protocol: Add support for meta_data in PUTVAL 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:=. As an example, meta:foo=bar will add an entry with key "foo" and value "bar". --- src/utils/cmds/putval.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/utils/cmds/putval.c b/src/utils/cmds/putval.c index b6d5ccc67..11f0fcb61 100644 --- a/src/utils/cmds/putval.c +++ b/src/utils/cmds/putval.c @@ -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 */ -- 2.47.2