From: Florian Forster Date: Tue, 10 Mar 2015 14:34:10 +0000 (+0100) Subject: write_tsdb plugin: Fix name generation even more. X-Git-Tag: collectd-5.5.0~71 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=68b76e9e32d172936e7f01d6ac0cd5e4d49f8d46;p=collectd.git write_tsdb plugin: Fix name generation even more. There were more cases in which "type" or "type_instance" were omitted. Fixes: #945 --- diff --git a/src/write_tsdb.c b/src/write_tsdb.c index bfac1a14..9008a67b 100644 --- a/src/write_tsdb.c +++ b/src/write_tsdb.c @@ -366,37 +366,40 @@ static int wt_format_name(char *ret, int ret_len, if (ds_name != NULL) { if (vl->plugin_instance[0] == '\0') { if (vl->type_instance[0] == '\0') { - ssnprintf(ret, ret_len, "%s%s.%s.%s", - prefix, vl->plugin, vl->type, - ds_name); + 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); + ssnprintf(ret, ret_len, "%s%s.%s.%s.%s", prefix, vl->plugin, + vl->type, vl->type_instance, ds_name); + } + } else { /* vl->plugin_instance != "" */ + if (vl->type_instance[0] == '\0') { + 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->type_instance[0] == '\0') { - 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') { - ssnprintf(ret, ret_len, "%s%s.%s", - prefix, vl->plugin, vl->type); - } else { - ssnprintf(ret, ret_len, "%s%s.%s", - prefix, vl->plugin, vl->type_instance); + } else { /* ds_name == NULL */ + if (vl->plugin_instance[0] == '\0') { + if (vl->type_instance[0] == '\0') { + ssnprintf(ret, ret_len, "%s%s.%s", prefix, vl->plugin, + vl->type); + } else { + ssnprintf(ret, ret_len, "%s%s.%s.%s", prefix, vl->plugin, + vl->type_instance, vl->type); + } + } else { /* vl->plugin_instance != "" */ + if (vl->type_instance[0] == '\0') { + ssnprintf(ret, ret_len, "%s%s.%s.%s", prefix, vl->plugin, + vl->plugin_instance, vl->type); + } else { + ssnprintf(ret, ret_len, "%s%s.%s.%s.%s", prefix, vl->plugin, + vl->plugin_instance, vl->type, 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); - } else { - ssnprintf(ret, ret_len, "%s%s.%s.%s.%s", - prefix, vl->plugin, vl->plugin_instance, vl->type, vl->type_instance); } sfree(temp);