summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 602c80f)
raw | patch | inline | side by side (parent: 602c80f)
author | Kevin Bowling <kbowling@llnw.com> | |
Tue, 3 Jun 2014 04:11:27 +0000 (21:11 -0700) | ||
committer | Marc Fournier <marc.fournier@camptocamp.com> | |
Wed, 13 Aug 2014 12:05:21 +0000 (14:05 +0200) |
src/collectd.conf.in | patch | blob | history | |
src/write_tsdb.c | patch | blob | history |
diff --git a/src/collectd.conf.in b/src/collectd.conf.in
index 637705ec5e86e744d99af1a862c45a5bd730f843..00d44497669d4bbaa7877d01c2b08cc8011adbf6 100644 (file)
--- a/src/collectd.conf.in
+++ b/src/collectd.conf.in
# <Node>
# Host "localhost"
# Port "4242"
-# Prefix "sys"
+# HostTags "status=production"
# </Node>
#</Plugin>
diff --git a/src/write_tsdb.c b/src/write_tsdb.c
index 8a793b5c2b704825ccaf8434d99ae72cf6fe24fb..8b10fd6193344ca2c06fbd2966b56b7cc63bf546 100644 (file)
--- a/src/write_tsdb.c
+++ b/src/write_tsdb.c
const char *ds_name)
{
int status;
- char *temp;
- char *prefix;
+ char *temp = NULL;
+ char *prefix = "";
const char *meta_prefix = "tsdb_prefix";
- status = meta_data_get_string(vl->meta, meta_prefix, &temp);
- if (status == -ENOENT) {
- prefix = "";
- } else if (status < 0) {
- sfree(temp);
- return status;
- } else {
- prefix = temp;
+ if (vl->meta) {
+ status = meta_data_get_string(vl->meta, meta_prefix, &temp);
+ if (status == -ENOENT) {
+ /* defaults to empty string */
+ } else if (status < 0) {
+ sfree(temp);
+ return status;
+ } else {
+ prefix = temp;
+ }
}
if (ds_name != NULL) {
if (vl->plugin_instance[0] == '\0') {
- ssnprintf(ret, ret_len, "%s.%s.%s",
+ ssnprintf(ret, ret_len, "%s%s.%s",
prefix, vl->plugin, ds_name);
} else if (vl->type_instance == '\0') {
- ssnprintf(ret, ret_len, "%s.%s.%s.%s.%s",
+ 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",
+ ssnprintf(ret, ret_len, "%s%s.%s.%s.%s",
prefix, vl->plugin, vl->plugin_instance, vl->type,
ds_name);
}
} else if (vl->plugin_instance[0] == '\0') {
if (vl->type_instance[0] == '\0')
- ssnprintf(ret, ret_len, "%s.%s.%s",
+ ssnprintf(ret, ret_len, "%s%s.%s",
prefix, vl->plugin, vl->type);
else
- ssnprintf(ret, ret_len, "%s.%s.%s",
+ 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",
+ 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",
+ ssnprintf(ret, ret_len, "%s%s.%s.%s",
prefix, vl->plugin, vl->plugin_instance, vl->type_instance);
}
{
int status;
int message_len;
- char *temp, *tags;
+ char *temp = NULL;
+ char *tags = "";
char message[1024];
const char *message_fmt;
const char *meta_tsdb = "tsdb_tags";
if (value[0] == 'n')
return 0;
- status = meta_data_get_string(md, meta_tsdb, &temp);
- if (status == -ENOENT) {
- tags = "";
- } else if (status < 0) {
- ERROR("write_tsdb plugin: tags metadata get failure");
- sfree(temp);
- pthread_mutex_unlock(&cb->send_lock);
- return status;
- } else {
- tags = temp;
+ if (md) {
+ status = meta_data_get_string(md, meta_tsdb, &temp);
+ if (status == -ENOENT) {
+ /* defaults to empty string */
+ } else if (status < 0) {
+ ERROR("write_tsdb plugin: tags metadata get failure");
+ sfree(temp);
+ pthread_mutex_unlock(&cb->send_lock);
+ return status;
+ } else {
+ tags = temp;
+ }
}
message_fmt = "put %s %u %s fqdn=%s %s %s\r\n";
tags,
cb->host_tags);
- sfree(tags);
+ sfree(temp);
if (message_len >= sizeof(message)) {
ERROR("write_tsdb plugin: message buffer too small: "