From 16d2deacb576d32e304f7dd1143c434720676ab0 Mon Sep 17 00:00:00 2001 From: Scott Sanders Date: Sun, 2 Oct 2011 19:18:06 -0400 Subject: [PATCH] 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. --- src/write_graphite.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) 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')) -- 2.30.2