From: Dallin Young Date: Fri, 20 Feb 2015 18:33:00 +0000 (+0100) Subject: write_tsdb plugin: Add type and type_instance to the metric name in any case. X-Git-Tag: collectd-5.5.0~72 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=42e4d6cd43374ac5e954a02408e7e79734c90f90;p=collectd.git write_tsdb plugin: Add type and type_instance to the metric name in any case. Previously, the generated names were wrong, especially when no plugin instance was used for a metric. Fixes: #945 Signed-off-by: Florian Forster --- diff --git a/src/write_tsdb.c b/src/write_tsdb.c index b7f46f1b..bfac1a14 100644 --- a/src/write_tsdb.c +++ b/src/write_tsdb.c @@ -365,24 +365,32 @@ static int wt_format_name(char *ret, int ret_len, if (ds_name != NULL) { if (vl->plugin_instance[0] == '\0') { - ssnprintf(ret, ret_len, "%s%s.%s", - prefix, vl->plugin, ds_name); + if (vl->type_instance[0] == '\0') { + ssnprintf(ret, ret_len, "%s%s.%s.%s", + prefix, vl->plugin, vl->type, + ds_name); + } else { + ssnprintf(ret, ret_len, "%s%s.%s.%s", + prefix, vl->plugin, vl->type_instance, + ds_name); + } } else if (vl->type_instance[0] == '\0') { - ssnprintf(ret, ret_len, "%s%s.%s.%s.%s", - prefix, vl->plugin, vl->plugin_instance, - vl->type_instance, ds_name); - } else { ssnprintf(ret, ret_len, "%s%s.%s.%s.%s", prefix, vl->plugin, vl->plugin_instance, vl->type, ds_name); + } else { + ssnprintf(ret, ret_len, "%s%s.%s.%s.%s.%s", + prefix, vl->plugin, vl->plugin_instance, vl->type, + vl->type_instance, ds_name); } } else if (vl->plugin_instance[0] == '\0') { - if (vl->type_instance[0] == '\0') + if (vl->type_instance[0] == '\0') { ssnprintf(ret, ret_len, "%s%s.%s", prefix, vl->plugin, vl->type); - else + } else { ssnprintf(ret, ret_len, "%s%s.%s", prefix, vl->plugin, vl->type_instance); + } } else if (vl->type_instance[0] == '\0') { ssnprintf(ret, ret_len, "%s%s.%s.%s", prefix, vl->plugin, vl->plugin_instance, vl->type);