Small naming conventions fixes, let the user to choose its delimiter
[collectd.git] / src / write_riemann.c
index a3b655a..61c1391 100644 (file)
@@ -48,7 +48,7 @@ int write_riemann_threshold_check(const data_set_t *, const value_list_t *, int
 
 struct riemann_host {
        char                    *name;
-       char                    *prefix;
+       char                    *event_service_prefix;
 #define F_CONNECT               0x01
        uint8_t                  flags;
        pthread_mutex_t          lock;
@@ -569,21 +569,20 @@ static Event *riemann_value_to_protobuf (struct riemann_host const *host, /* {{{
        format_name (name_buffer, sizeof (name_buffer),
                        /* host = */ "", vl->plugin, vl->plugin_instance,
                        vl->type, vl->type_instance);
-       if (host->always_append_ds || (ds->ds_num > 1)) {
-    if (host->prefix == NULL)
-    ssnprintf (service_buffer, sizeof (service_buffer),
-        "%s/%s", &name_buffer[1], ds->ds[index].name);
-    else
-    ssnprintf (service_buffer, sizeof (service_buffer),
-        "%s/%s/%s", host->prefix, &name_buffer[1], ds->ds[index].name);
-  } else {
-    if (host->prefix == NULL)
-      sstrncpy (service_buffer, &name_buffer[1],
-          sizeof (service_buffer));
-    else
-    ssnprintf (service_buffer, sizeof (service_buffer),
-        "%s/%s", host->prefix, &name_buffer[1]);
-  }
+       if (host->always_append_ds || (ds->ds_num > 1))
+               if (host->event_service_prefix == NULL || host->event_service_prefix[0] == '\0')
+                       ssnprintf (service_buffer, sizeof (service_buffer),
+                                       "%s/%s", &name_buffer[1], ds->ds[index].name);
+               else
+                       ssnprintf (service_buffer, sizeof (service_buffer),
+                                       "%s%s/%s", host->event_service_prefix, &name_buffer[1], ds->ds[index].name);
+       else
+               if (host->event_service_prefix == NULL || host->event_service_prefix[0] == '\0')
+                       sstrncpy (service_buffer, &name_buffer[1],
+                                       sizeof (service_buffer));
+               else
+                       ssnprintf (service_buffer, sizeof (service_buffer),
+                                       "%s%s", host->event_service_prefix, &name_buffer[1]);
 
        event->service = strdup (service_buffer);
 
@@ -765,8 +764,9 @@ static int riemann_config_node(oconfig_item_t *ci) /* {{{ */
             status = cf_util_get_boolean(child, &host->notifications);
             if (status != 0)
                 break;
-        } else if (strcasecmp ("Prefix", child->key) == 0) {
-            status = cf_util_get_string (child, &host->prefix);
+        } else if (strcasecmp ("EventServicePrefix", child->key) == 0) {
+            status = cf_util_get_string (child, &host->event_service_prefix);
+            if (status != 0)
                 break;
         } else if (strcasecmp ("CheckThresholds", child->key) == 0) {
             status = cf_util_get_boolean(child, &host->check_thresholds);