#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);