From 28088a38826a276541a6e729c1752d6cb9b538d0 Mon Sep 17 00:00:00 2001 From: John-John Tedro Date: Mon, 2 Sep 2013 21:53:34 +0000 Subject: [PATCH] write_riemann: Add extra meta strings as attributes in notifications --- src/write_riemann.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/write_riemann.c b/src/write_riemann.c index 3345d044..42e11f9d 100644 --- a/src/write_riemann.c +++ b/src/write_riemann.c @@ -353,15 +353,20 @@ static Msg *riemann_notification_to_protobuf (struct riemann_host *host, /* {{{ n->type, n->type_instance); event->service = strdup (&service_buffer[1]); - /* Pull in values from threshold */ + /* Pull in values from threshold and add extra attributes */ for (meta = n->meta; meta != NULL; meta = meta->next) { - if (strcasecmp ("CurrentValue", meta->name) != 0) + if (strcasecmp ("CurrentValue", meta->name) == 0 && meta->type == NM_TYPE_DOUBLE) + { + event->metric_d = meta->nm_value.nm_double; + event->has_metric_d = 1; continue; + } - event->metric_d = meta->nm_value.nm_double; - event->has_metric_d = 1; - break; + if (meta->type == NM_TYPE_STRING) { + riemann_event_add_attribute (event, meta->name, meta->nm_value.nm_string); + continue; + } } DEBUG ("write_riemann plugin: Successfully created protobuf for notification: " -- 2.11.0