summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: d7c0080)
raw | patch | inline | side by side (parent: d7c0080)
author | Pierre-Yves Ritschard <pyr@spootnik.org> | |
Mon, 28 Oct 2013 12:47:03 +0000 (13:47 +0100) | ||
committer | Pierre-Yves Ritschard <pyr@spootnik.org> | |
Mon, 28 Oct 2013 12:47:03 +0000 (13:47 +0100) |
src/write_riemann.c | patch | blob | history |
diff --git a/src/write_riemann.c b/src/write_riemann.c
index 0bd8e3a029b231aa285128676f1c0d4a55b8dbe6..3a7738f626705b7bbdbf966895b751fdf46fada1 100644 (file)
--- a/src/write_riemann.c
+++ b/src/write_riemann.c
static char **riemann_tags;
static size_t riemann_tags_num;
+static char **riemann_attrs;
+static size_t riemann_attrs_num;
static void riemann_event_protobuf_free (Event *event) /* {{{ */
{
@@ -422,6 +424,11 @@ static Msg *riemann_notification_to_protobuf (struct riemann_host *host, /* {{{
riemann_event_add_attribute (event, "type_instance",
n->type_instance);
+ for (i = 0; i < riemann_attrs_num; i += 2)
+ riemann_event_add_attribute(event,
+ riemann_attrs[i],
+ riemann_attrs[i +1]);
+
for (i = 0; i < riemann_tags_num; i++)
riemann_event_add_tag (event, riemann_tags[i]);
@@ -511,6 +518,11 @@ static Event *riemann_value_to_protobuf (struct riemann_host const *host, /* {{{
riemann_event_add_attribute (event, "ds_index", ds_index);
}
+ for (i = 0; i < riemann_attrs_num; i += 2)
+ riemann_event_add_attribute(event,
+ riemann_attrs[i],
+ riemann_attrs[i +1]);
+
for (i = 0; i < riemann_tags_num; i++)
riemann_event_add_tag (event, riemann_tags[i]);
if (strcasecmp("Node", child->key) == 0) {
riemann_config_node (child);
+ } else if (strcasecmp(child->key, "attribute") == 0) {
+ char *key = NULL;
+ char *val = NULL;
+
+ if (child->values_num != 2) {
+ WARNING("riemann attributes need both a key and a value.");
+ return (-1);
+ }
+ if (child->values[0].type != OCONFIG_TYPE_STRING ||
+ child->values[1].type != OCONFIG_TYPE_STRING) {
+ WARNING("riemann attribute needs string arguments.");
+ return (-1);
+ }
+ if ((key = strdup(child->values[0].value.string)) == NULL) {
+ WARNING("cannot allocate memory for attribute key.");
+ return (-1);
+ }
+ if ((val = strdup(child->values[1].value.string)) == NULL) {
+ WARNING("cannot allocate memory for attribute value.");
+ return (-1);
+ }
+ strarray_add(&riemann_attrs, &riemann_attrs_num, key);
+ strarray_add(&riemann_attrs, &riemann_attrs_num, val);
+ DEBUG("write_riemann: got attr: %s => %s", key, val);
+ sfree(key);
+ sfree(val);
} else if (strcasecmp(child->key, "tag") == 0) {
char *tmp = NULL;
status = cf_util_get_string(child, &tmp);