X-Git-Url: https://git.octo.it/?p=collectd.git;a=blobdiff_plain;f=src%2Fwrite_riemann.c;h=86f0c1fac5e2dddd2543e69a480c86ff6f345c03;hp=9e07e75119bb0ba5be0e3704ee5b3598c226c620;hb=1159cb5d383c55a80a0db100b8f7aadcf44740a5;hpb=1035fba8812893e50d00a871e3399cc1ece3b384 diff --git a/src/write_riemann.c b/src/write_riemann.c index 9e07e751..86f0c1fa 100644 --- a/src/write_riemann.c +++ b/src/write_riemann.c @@ -214,6 +214,11 @@ wrr_notification_to_message(struct riemann_host *host, /* {{{ */ RIEMANN_EVENT_FIELD_SERVICE, &service_buffer[1], RIEMANN_EVENT_FIELD_NONE); +#if RCC_VERSION_NUMBER >= 0x010A00 + riemann_event_set(event, RIEMANN_EVENT_FIELD_TIME_MICROS, + (int64_t)CDTIME_T_TO_US(n->time)); +#endif + if (n->host[0] != 0) riemann_event_string_attribute_add(event, "host", n->host); if (n->plugin[0] != 0) @@ -288,18 +293,17 @@ wrr_value_to_event(struct riemann_host const *host, /* {{{ */ vl->type_instance); if (host->always_append_ds || (ds->ds_num > 1)) { if (host->event_service_prefix == NULL) - ssnprintf(service_buffer, sizeof(service_buffer), "%s/%s", - &name_buffer[1], ds->ds[index].name); + snprintf(service_buffer, sizeof(service_buffer), "%s/%s", &name_buffer[1], + ds->ds[index].name); else - ssnprintf(service_buffer, sizeof(service_buffer), "%s%s/%s", - host->event_service_prefix, &name_buffer[1], - ds->ds[index].name); + snprintf(service_buffer, sizeof(service_buffer), "%s%s/%s", + host->event_service_prefix, &name_buffer[1], ds->ds[index].name); } else { if (host->event_service_prefix == NULL) sstrncpy(service_buffer, &name_buffer[1], sizeof(service_buffer)); else - ssnprintf(service_buffer, sizeof(service_buffer), "%s%s", - host->event_service_prefix, &name_buffer[1]); + snprintf(service_buffer, sizeof(service_buffer), "%s%s", + host->event_service_prefix, &name_buffer[1]); } riemann_event_set( @@ -310,6 +314,11 @@ wrr_value_to_event(struct riemann_host const *host, /* {{{ */ vl->type, "ds_name", ds->ds[index].name, NULL, RIEMANN_EVENT_FIELD_SERVICE, service_buffer, RIEMANN_EVENT_FIELD_NONE); +#if RCC_VERSION_NUMBER >= 0x010A00 + riemann_event_set(event, RIEMANN_EVENT_FIELD_TIME_MICROS, + (int64_t)CDTIME_T_TO_US(vl->time)); +#endif + if (host->check_thresholds) { const char *state = NULL; @@ -342,8 +351,8 @@ wrr_value_to_event(struct riemann_host const *host, /* {{{ */ if ((ds->ds[index].type != DS_TYPE_GAUGE) && (rates != NULL)) { char ds_type[DATA_MAX_NAME_LEN]; - ssnprintf(ds_type, sizeof(ds_type), "%s:rate", - DS_TYPE_TO_STRING(ds->ds[index].type)); + snprintf(ds_type, sizeof(ds_type), "%s:rate", + DS_TYPE_TO_STRING(ds->ds[index].type)); riemann_event_string_attribute_add(event, "ds_type", ds_type); } else { riemann_event_string_attribute_add(event, "ds_type", @@ -353,7 +362,7 @@ wrr_value_to_event(struct riemann_host const *host, /* {{{ */ { char ds_index[DATA_MAX_NAME_LEN]; - ssnprintf(ds_index, sizeof(ds_index), "%zu", index); + snprintf(ds_index, sizeof(ds_index), "%zu", index); riemann_event_string_attribute_add(event, "ds_index", ds_index); } @@ -601,6 +610,7 @@ static void wrr_free(void *p) /* {{{ */ wrr_disconnect(host); + pthread_mutex_lock(&host->lock); pthread_mutex_destroy(&host->lock); sfree(host); } /* }}} void wrr_free */ @@ -792,8 +802,8 @@ static int wrr_config_node(oconfig_item_t *ci) /* {{{ */ return status; } - ssnprintf(callback_name, sizeof(callback_name), "write_riemann/%s", - host->name); + snprintf(callback_name, sizeof(callback_name), "write_riemann/%s", + host->name); user_data_t ud = {.data = host, .free_func = wrr_free};