X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fwrite_sensu.c;h=d764d2605351cefd716547a055d09437cac39ccb;hb=1aa4295ba6875ceb02a7383237bc2485ffab9c1e;hp=b07b3bf21f371b15d71f9ae796f99076b60cb28b;hpb=da612fa9c6a3343b43789569d64197d7c690be52;p=collectd.git diff --git a/src/write_sensu.c b/src/write_sensu.c index b07b3bf2..d764d260 100644 --- a/src/write_sensu.c +++ b/src/write_sensu.c @@ -30,7 +30,6 @@ #include "plugin.h" #include "common.h" -#include "configfile.h" #include "utils_cache.h" #include #include @@ -196,6 +195,8 @@ static int sensu_connect(struct sensu_host *host) /* {{{ */ if (setsockopt(host->s, SOL_SOCKET, SO_LINGER, &so_linger, sizeof so_linger) != 0) WARNING("write_sensu plugin: failed to set socket close() lingering"); + set_sock_opts(host->s); + // connect the socket if (connect(host->s, ai->ai_addr, ai->ai_addrlen) != 0) { close(host->s); @@ -530,7 +531,7 @@ static char *sensu_value_to_json(struct sensu_host const *host, /* {{{ */ in_place_replace_sensu_name_reserved(service_buffer); // finalize the buffer by setting the output and closing curly bracket - res = my_asprintf(&temp_str, "%s, \"output\": \"%s %s %ld\"}\n", ret_str, service_buffer, value_str, CDTIME_T_TO_TIME_T(vl->time)); + res = my_asprintf(&temp_str, "%s, \"output\": \"%s %s %lld\"}\n",ret_str, service_buffer, value_str, (long long)CDTIME_T_TO_TIME_T(vl->time)); free(ret_str); free(value_str); if (res == -1) { @@ -666,7 +667,7 @@ static char *sensu_notification_to_json(struct sensu_host *host, /* {{{ */ ret_str = temp_str; // incorporate the timestamp - res = my_asprintf(&temp_str, "%s, \"timestamp\": %ld", ret_str, CDTIME_T_TO_TIME_T(n->time)); + res = my_asprintf(&temp_str, "%s, \"timestamp\": %lld", ret_str, (long long)CDTIME_T_TO_TIME_T(n->time)); free(ret_str); if (res == -1) { ERROR("write_sensu plugin: Unable to alloc memory"); @@ -977,7 +978,6 @@ static int sensu_config_node(oconfig_item_t *ci) /* {{{ */ int status = 0; oconfig_item_t *child; char callback_name[DATA_MAX_NAME_LEN]; - user_data_t ud; if ((host = calloc(1, sizeof(*host))) == NULL) { ERROR("write_sensu plugin: calloc failed."); @@ -1107,8 +1107,11 @@ static int sensu_config_node(oconfig_item_t *ci) /* {{{ */ } ssnprintf(callback_name, sizeof(callback_name), "write_sensu/%s", host->name); - ud.data = host; - ud.free_func = sensu_free; + + user_data_t ud = { + .data = host, + .free_func = sensu_free + }; pthread_mutex_lock(&host->lock);