From cf65f7ec5e19a99dd972a78e6c798fd478710663 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Ritschard Date: Tue, 22 Jul 2014 15:23:27 +0200 Subject: [PATCH] make threshold checking optional --- src/write_riemann.c | 39 +++++++++++++++++++++-------------- src/write_riemann_threshold.c | 2 -- 2 files changed, 24 insertions(+), 17 deletions(-) diff --git a/src/write_riemann.c b/src/write_riemann.c index 2875a017..9d2b5398 100644 --- a/src/write_riemann.c +++ b/src/write_riemann.c @@ -47,6 +47,7 @@ struct riemann_host { uint8_t flags; pthread_mutex_t lock; _Bool notifications; + _Bool check_thresholds; _Bool store_rates; _Bool always_append_ds; char *node; @@ -478,20 +479,22 @@ static Event *riemann_value_to_protobuf (struct riemann_host const *host, /* {{{ event->time = CDTIME_T_TO_TIME_T (vl->time); event->has_time = 1; - switch (status) { - case STATE_OKAY: - event->state = strdup("ok"); - break; - case STATE_ERROR: - event->state = strdup("critical"); - break; - case STATE_WARNING: - event->state = strdup("warning"); - break; - case STATE_MISSING: - event->state = strdup("unknown"); - break; - } + if (host->check_thresholds) { + switch (status) { + case STATE_OKAY: + event->state = strdup("ok"); + break; + case STATE_ERROR: + event->state = strdup("critical"); + break; + case STATE_WARNING: + event->state = strdup("warning"); + break; + case STATE_MISSING: + event->state = strdup("unknown"); + break; + } + } ttl = CDTIME_T_TO_DOUBLE (vl->interval) * host->ttl_factor; event->ttl = (float) ttl; @@ -662,7 +665,8 @@ static int riemann_write(const data_set_t *ds, /* {{{ */ struct riemann_host *host = ud->data; Msg *msg; - write_riemann_threshold_check(ds, vl, statuses); + if (host->check_thresholds) + write_riemann_threshold_check(ds, vl, statuses); msg = riemann_value_list_to_protobuf (host, ds, vl, statuses); if (msg == NULL) return (-1); @@ -717,6 +721,7 @@ static int riemann_config_node(oconfig_item_t *ci) /* {{{ */ host->node = NULL; host->service = NULL; host->notifications = 1; + host->check_thresholds = 0; host->store_rates = 1; host->always_append_ds = 0; host->use_tcp = 0; @@ -743,6 +748,10 @@ static int riemann_config_node(oconfig_item_t *ci) /* {{{ */ break; } else if (strcasecmp ("Notifications", child->key) == 0) { status = cf_util_get_boolean(child, &host->notifications); + if (status != 0) + break; + } else if (strcasecmp ("CheckThresholds", child->key) == 0) { + status = cf_util_get_boolean(child, &host->check_thresholds); if (status != 0) break; } else if (strcasecmp ("Port", child->key) == 0) { diff --git a/src/write_riemann_threshold.c b/src/write_riemann_threshold.c index 9f497741..ff96843b 100644 --- a/src/write_riemann_threshold.c +++ b/src/write_riemann_threshold.c @@ -280,8 +280,6 @@ int write_riemann_threshold_check (const data_set_t *ds, const value_list_t *vl, int status; memset(statuses, 0, vl->values_len * sizeof(*statuses)); - - if (threshold_tree == NULL) return 0; -- 2.30.2