From: Rafael Marinheiro Date: Fri, 23 Mar 2018 17:08:47 +0000 (-0400) Subject: text protocol: Add support for meta_data in PUTVAL X-Git-Tag: collectd-5.11.0~20^2~10 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6c3106f61987a975dce7faed29c298cbeda0cfa8;p=thirdparty%2Fcollectd.git 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". --- 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 */