Merge remote-tracking branch 'github/pr/706'
authorFlorian Forster <octo@collectd.org>
Fri, 22 Aug 2014 05:23:28 +0000 (07:23 +0200)
committerFlorian Forster <octo@collectd.org>
Fri, 22 Aug 2014 05:23:28 +0000 (07:23 +0200)
Conflicts:
src/write_riemann.c

src/collectd.conf.in
src/collectd.conf.pod
src/write_riemann.c

index 4d5abe0..21de844 100644 (file)
 #              StoreRates true
 #              AlwaysAppendDS false
 #              TTLFactor 2.0
+#              EventServicePrefix ""
 #      </Node>
 #      Tag "foobar"
 #       Attribute "foo" "bar"
index 3a8af84..bba9055 100644 (file)
@@ -6918,6 +6918,12 @@ useful to avoid getting notification events.
 If set to B<true>, attach state to events based on thresholds defined
 in the B<Threshold> plugin. Defaults to B<false>.
 
+=item B<EventServicePrefix> I<String>
+
+Add the given string as a prefix to the event service name.
+If B<EventServicePrefix> not set or set to an empty string (""),
+no prefix will be used.
+
 =back
 
 =item B<Tag> I<String>
index b59c3e3..c3740e1 100644 (file)
@@ -48,6 +48,7 @@ int write_riemann_threshold_check(const data_set_t *, const value_list_t *, int
 
 struct riemann_host {
        char                    *name;
+       char                    *event_service_prefix;
 #define F_CONNECT               0x01
        uint8_t                  flags;
        pthread_mutex_t          lock;
@@ -569,11 +570,22 @@ static Event *riemann_value_to_protobuf(struct riemann_host const *host, /* {{{
                        /* 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);
+       {
+               if (host->event_service_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->event_service_prefix, &name_buffer[1], ds->ds[index].name);
+       }
        else
-               sstrncpy (service_buffer, &name_buffer[1],
-                               sizeof (service_buffer));
+       {
+               if (host->event_service_prefix == NULL)
+                       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);
 
@@ -755,6 +767,10 @@ static int riemann_config_node(oconfig_item_t *ci) /* {{{ */
                        status = cf_util_get_boolean(child, &host->notifications);
                        if (status != 0)
                                break;
+               } 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);
                        if (status != 0)