Code

refactor prefix feature - cast directly to service_buffer
author~/.gitconfig <moshe@forter.com>
Thu, 14 Aug 2014 13:50:24 +0000 (16:50 +0300)
committer~/.gitconfig <moshe@forter.com>
Thu, 14 Aug 2014 13:50:24 +0000 (16:50 +0300)
src/collectd.conf.in
src/write_riemann.c

index 5780722e72f259ed1cac0630294725e2ea498aad..bdc4969cd4aaf55eafc84b8edd2aa192a8d4521c 100644 (file)
 #              StoreRates true
 #              AlwaysAppendDS false
 #              TTLFactor 2.0
+#              Prefix ServicePrefix
 #      </Node>
 #      Tag "foobar"
 #       Attribute "foo" "bar"
index 56752124faade07ea8053edbd0cc7e06cabd366b..1ce6bfb410bb5274b5790be1bc3f1a11fdc1a700 100644 (file)
@@ -431,7 +431,7 @@ static Msg *riemann_notification_to_protobuf (struct riemann_host *host, /* {{{
                riemann_event_add_tag (event, riemann_tags[i]);
 
        format_name (service_buffer, sizeof (service_buffer),
-                       /* host = */ host->prefix, n->plugin, n->plugin_instance,
+                       /* host = */ "", n->plugin, n->plugin_instance,
                        n->type, n->type_instance);
        event->service = strdup (&service_buffer[1]);
 
@@ -567,14 +567,14 @@ static Event *riemann_value_to_protobuf (struct riemann_host const *host, /* {{{
        }
 
        format_name (name_buffer, sizeof (name_buffer),
-                       /* host = */ host->prefix, vl->plugin, vl->plugin_instance,
+                       /* host = */ "", vl->plugin, vl->plugin_instance,
                        vl->type, vl->type_instance);
        if (host->always_append_ds || (ds->ds_num > 1))
-               ssnprintf (service_buffer, sizeof (service_buffer),
-                               "%s/%s", &name_buffer[1], ds->ds[index].name);
+    ssnprintf (service_buffer, sizeof (service_buffer),
+        "%s/%s/%s", host->prefix, &name_buffer[1], ds->ds[index].name);
        else
-               sstrncpy (service_buffer, &name_buffer[1],
-                               sizeof (service_buffer));
+    ssnprintf (service_buffer, sizeof (service_buffer),
+        "%s/%s", host->prefix, &name_buffer[1]);
 
        event->service = strdup (service_buffer);