X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fwrite_riemann.c;h=20f2e10b91b50b4fe0165db17dec7ff9b7449ef3;hb=4d370741101aeb037ae52f3529a4a0869e0dc08a;hp=261327a37b750796c603e990650cb45e70e5d89a;hpb=1d18c92a85f0265d5fcddf0853b57288e7def20a;p=collectd.git diff --git a/src/write_riemann.c b/src/write_riemann.c index 261327a3..20f2e10b 100644 --- a/src/write_riemann.c +++ b/src/write_riemann.c @@ -31,7 +31,6 @@ #include "collectd.h" #include "common.h" -#include "configfile.h" #include "plugin.h" #include "utils_cache.h" #include "utils_complain.h" @@ -101,6 +100,7 @@ static int wrr_connect(struct riemann_host *host) /* {{{ */ node, port); return -1; } +#if RCC_VERSION_NUMBER >= 0x010800 if (host->timeout.tv_sec != 0) { if (riemann_client_set_timeout(host->client, &host->timeout) != 0) { riemann_client_free(host->client); @@ -111,6 +111,9 @@ static int wrr_connect(struct riemann_host *host) /* {{{ */ return -1; } } +#endif + + set_sock_opts(riemann_client_get_fd(host->client)); c_release(LOG_INFO, &host->init_complaint, "write_riemann plugin: Successfully connected to %s:%d", node, @@ -186,8 +189,6 @@ wrr_notification_to_message(struct riemann_host *host, /* {{{ */ riemann_event_t *event; char service_buffer[6 * DATA_MAX_NAME_LEN]; char const *severity; - notification_meta_t *meta; - size_t i; switch (n->severity) { case NOTIF_OKAY: @@ -228,18 +229,18 @@ wrr_notification_to_message(struct riemann_host *host, /* {{{ */ riemann_event_string_attribute_add(event, "type_instance", n->type_instance); - for (i = 0; i < riemann_attrs_num; i += 2) + for (size_t i = 0; i < riemann_attrs_num; i += 2) riemann_event_string_attribute_add(event, riemann_attrs[i], riemann_attrs[i + 1]); - for (i = 0; i < riemann_tags_num; i++) + for (size_t i = 0; i < riemann_tags_num; i++) riemann_event_tag_add(event, riemann_tags[i]); if (n->message[0] != 0) riemann_event_string_attribute_add(event, "description", n->message); /* Pull in values from threshold and add extra attributes */ - for (meta = n->meta; meta != NULL; meta = meta->next) { + for (notification_meta_t *meta = n->meta; meta != NULL; meta = meta->next) { if (strcasecmp("CurrentValue", meta->name) == 0 && meta->type == NM_TYPE_DOUBLE) { riemann_event_set(event, RIEMANN_EVENT_FIELD_METRIC_D, @@ -612,7 +613,6 @@ static int wrr_config_node(oconfig_item_t *ci) /* {{{ */ int i; oconfig_item_t *child; char callback_name[DATA_MAX_NAME_LEN]; - user_data_t ud; if ((host = calloc(1, sizeof(*host))) == NULL) { ERROR("write_riemann plugin: calloc failed."); @@ -681,9 +681,13 @@ static int wrr_config_node(oconfig_item_t *ci) /* {{{ */ if (status != 0) break; } else if (strcasecmp("Timeout", child->key) == 0) { +#if RCC_VERSION_NUMBER >= 0x010800 status = cf_util_get_int(child, (int *)&host->timeout.tv_sec); if (status != 0) break; +#else + WARNING("write_riemann plugin: The Timeout option is not supported. Please upgrade the Riemann client to at least 1.8.0."); +#endif } else if (strcasecmp("Port", child->key) == 0) { host->port = cf_util_get_port_number(child); if (host->port == -1) { @@ -790,8 +794,11 @@ static int wrr_config_node(oconfig_item_t *ci) /* {{{ */ ssnprintf(callback_name, sizeof(callback_name), "write_riemann/%s", host->name); - ud.data = host; - ud.free_func = wrr_free; + + user_data_t ud = { + .data = host, + .free_func = wrr_free + }; pthread_mutex_lock(&host->lock);