From: Scott Sanders Date: Sun, 2 Oct 2011 23:18:06 +0000 (-0400) Subject: Converts . to _ in datasource names X-Git-Tag: collectd-5.1.0~35^2~25^2~11 X-Git-Url: https://git.octo.it/?a=commitdiff_plain;h=16d2deacb576d32e304f7dd1143c434720676ab0;p=collectd.git Converts . to _ in datasource names This came up during testing with the ntp plugin. The ds_name was being sent with an ip in the string. This will prevent the result from nesting in the carbon store. --- diff --git a/src/write_graphite.c b/src/write_graphite.c index e8bdc65c..2d80dbb7 100644 --- a/src/write_graphite.c +++ b/src/write_graphite.c @@ -308,7 +308,7 @@ static int wg_format_values (char *ret, size_t ret_len, return (0); } -static int normalize_hostname (char *dst, const char *src) +static int mangle_dots (char *dst, const char *src) { size_t i; @@ -336,7 +336,8 @@ static int wg_format_name (char *ret, int ret_len, const char *prefix, const char *ds_name) { int status; - char *n_hostname; + char *n_hostname = 0; + char *n_ds_name = 0; assert (plugin != NULL); assert (type != NULL); @@ -347,12 +348,20 @@ static int wg_format_name (char *ret, int ret_len, return (-1); } - if (normalize_hostname(n_hostname, hostname) == -1) + if (mangle_dots(n_hostname, hostname) == -1) { ERROR ("Unable to normalize hostname"); return (-1); } + if (ds_name && ds_name[0] != '\0') { + if (mangle_dots(n_ds_name, ds_name) == -1) + { + ERROR ("Unable to normalize datasource name"); + return (-1); + } + } + if ((plugin_instance == NULL) || (plugin_instance[0] == '\0')) { if ((type_instance == NULL) || (type_instance[0] == '\0'))