summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: a53a376)
raw | patch | inline | side by side (parent: a53a376)
author | Scott Sanders <scott@jssjr.com> | |
Sun, 9 Oct 2011 23:02:06 +0000 (19:02 -0400) | ||
committer | Scott Sanders <scott@jssjr.com> | |
Sun, 9 Oct 2011 23:02:06 +0000 (19:02 -0400) |
The user should be able to append a string to the hostname to provide
better organization if they wish. The directive used to set this option
is Postfix.
better organization if they wish. The directive used to set this option
is Postfix.
src/write_graphite.c | patch | blob | history |
diff --git a/src/write_graphite.c b/src/write_graphite.c
index 0de419f2b635960d99e89c61c4737b35a0d5b312..4fc38fb31df94aae02e478266c2f55c112348ce9 100644 (file)
--- a/src/write_graphite.c
+++ b/src/write_graphite.c
#define WG_FORMAT_NAME(ret, ret_len, vl, cb, name) \
wg_format_name (ret, ret_len, (vl)->host, (vl)->plugin, \
(vl)->plugin_instance, (vl)->type, \
- (vl)->type_instance, (cb)->prefix, name, (cb)->dotchar)
+ (vl)->type_instance, (cb)->prefix, (cb)->postfix, \
+ name, (cb)->dotchar)
#endif
#ifndef WG_SEND_BUF_SIZE
char *host;
int port;
char *prefix;
+ char *postfix;
char dotchar;
char send_buf[WG_SEND_BUF_SIZE];
close(cb->sock_fd);
sfree(cb->host);
sfree(cb->prefix);
+ sfree(cb->postfix);
sfree(cb);
}
const char *hostname,
const char *plugin, const char *plugin_instance,
const char *type, const char *type_instance,
- const char *prefix, const char *ds_name, const char dotchar)
+ const char *prefix, const char *postfix,
+ const char *ds_name, const char dotchar)
{
int status;
char *n_hostname = 0;
if ((n_type_instance == NULL) || (n_type_instance[0] == '\0'))
{
if ((ds_name == NULL) || (ds_name[0] == '\0'))
- status = ssnprintf (ret, ret_len, "%s.%s.%s.%s",
- prefix, n_hostname, plugin, type);
+ status = ssnprintf (ret, ret_len, "%s.%s%s.%s.%s",
+ prefix, n_hostname, postfix, plugin, type);
else
- status = ssnprintf (ret, ret_len, "%s.%s.%s.%s.%s",
- prefix, n_hostname, plugin, type, ds_name);
+ status = ssnprintf (ret, ret_len, "%s.%s%s.%s.%s.%s",
+ prefix, n_hostname, postfix, plugin, type, ds_name);
}
else
{
if ((ds_name == NULL) || (ds_name[0] == '\0'))
- status = ssnprintf (ret, ret_len, "%s.%s.%s.%s-%s",
- prefix, n_hostname, plugin, type,
+ status = ssnprintf (ret, ret_len, "%s.%s%s.%s.%s-%s",
+ prefix, n_hostname, postfix, plugin, type,
n_type_instance);
else
- status = ssnprintf (ret, ret_len, "%s.%s.%s.%s-%s.%s",
- prefix, n_hostname, plugin, type,
+ status = ssnprintf (ret, ret_len, "%s.%s%s.%s.%s-%s.%s",
+ prefix, n_hostname, postfix, plugin, type,
n_type_instance, ds_name);
}
}
if ((n_type_instance == NULL) || (n_type_instance[0] == '\0'))
{
if ((ds_name == NULL) || (ds_name[0] == '\0'))
- status = ssnprintf (ret, ret_len, "%s.%s.%s.%s.%s",
- prefix, n_hostname, plugin,
+ status = ssnprintf (ret, ret_len, "%s.%s%s.%s.%s.%s",
+ prefix, n_hostname, postfix, plugin,
plugin_instance, type);
else
- status = ssnprintf (ret, ret_len, "%s.%s.%s.%s.%s.%s",
- prefix, n_hostname, plugin,
+ status = ssnprintf (ret, ret_len, "%s.%s%s.%s.%s.%s.%s",
+ prefix, n_hostname, postfix, plugin,
plugin_instance, type, ds_name);
}
else
{
if ((ds_name == NULL) || (ds_name[0] == '\0'))
- status = ssnprintf (ret, ret_len, "%s.%s.%s.%s.%s-%s",
- prefix, n_hostname, plugin,
+ status = ssnprintf (ret, ret_len, "%s.%s%s.%s.%s.%s-%s",
+ prefix, n_hostname, postfix, plugin,
plugin_instance, type, n_type_instance);
else
- status = ssnprintf (ret, ret_len, "%s.%s.%s.%s.%s-%s.%s",
- prefix, n_hostname, plugin,
+ status = ssnprintf (ret, ret_len, "%s.%s%s.%s.%s.%s-%s.%s",
+ prefix, n_hostname, postfix, plugin,
plugin_instance, type, n_type_instance, ds_name);
}
}
cb->host = NULL;
cb->port = 2003;
cb->prefix = NULL;
+ cb->postfix = NULL;
cb->server = NULL;
cb->dotchar = '_';
config_set_number (&cb->port, child);
else if (strcasecmp ("Prefix", child->key) == 0)
config_set_string (&cb->prefix, child);
+ else if (strcasecmp ("Postfix", child->key) == 0)
+ config_set_string (&cb->postfix, child);
else if (strcasecmp ("DotCharacter", child->key) == 0)
config_set_char (&cb->dotchar, child);
else
}
}
+ if (cb->postfix == NULL) {
+ if ((cb->postfix = malloc((int)sizeof(char))) == NULL)
+ {
+ ERROR ("Unable to allocate memory for normalized hostname buffer");
+ return (-1);
+ }
+ cb->postfix[0] = '\0';
+ }
+
DEBUG ("write_graphite: Registering write callback to carbon agent "
"%s:%d", cb->host, cb->port);