summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: bc348a3)
raw | patch | inline | side by side (parent: bc348a3)
author | Kevin Bowling <kbowling@llnw.com> | |
Tue, 3 Jun 2014 04:11:27 +0000 (21:11 -0700) | ||
committer | Kevin Bowling <kbowling@llnw.com> | |
Tue, 3 Jun 2014 04:35:36 +0000 (21:35 -0700) |
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 26be4d3e3d65b92f63212404bd15a5caaa0c6180..851e8eb6e590c5097080cb9dd5a54f39024f41f6 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: "