X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fwrite_kafka.c;h=3c573801c22823d992835585530d4b8afca3cb1e;hb=e746ad785774de37a30302fef65f1c4aaf8698ab;hp=1712a478dbca635394f1b0f6de854adcd419979a;hpb=11011dc93691989513ff2101c221ea15dab5658a;p=collectd.git diff --git a/src/write_kafka.c b/src/write_kafka.c index 1712a478..3c573801 100644 --- a/src/write_kafka.c +++ b/src/write_kafka.c @@ -89,7 +89,7 @@ static uint32_t kafka_hash(const char *keydata, size_t keylen) { #define KAFKA_RANDOM_KEY_BUFFER \ (char[KAFKA_RANDOM_KEY_SIZE]) { "" } static char *kafka_random_key(char buffer[static KAFKA_RANDOM_KEY_SIZE]) { - ssnprintf(buffer, KAFKA_RANDOM_KEY_SIZE, "%08" PRIX32, cdrand_u()); + snprintf(buffer, KAFKA_RANDOM_KEY_SIZE, "%08" PRIX32, cdrand_u()); return buffer; } @@ -113,12 +113,12 @@ static int kafka_handle(struct kafka_topic_context *ctx) /* {{{ */ rd_kafka_topic_conf_t *topic_conf; if (ctx->kafka != NULL && ctx->topic != NULL) - return (0); + return 0; if (ctx->kafka == NULL) { if ((conf = rd_kafka_conf_dup(ctx->kafka_conf)) == NULL) { ERROR("write_kafka plugin: cannot duplicate kafka config"); - return (1); + return 1; } if ((ctx->kafka = rd_kafka_new(RD_KAFKA_PRODUCER, conf, errbuf, @@ -158,7 +158,7 @@ static int kafka_handle(struct kafka_topic_context *ctx) /* {{{ */ rd_kafka_topic_name(ctx->topic)); } - return (0); + return 0; } /* }}} int kafka_handle */ @@ -186,9 +186,10 @@ static int kafka_write(const data_set_t *ds, /* {{{ */ switch (ctx->format) { case KAFKA_FORMAT_COMMAND: - status = create_putval(buffer, sizeof(buffer), ds, vl); + status = cmd_create_putval(buffer, sizeof(buffer), ds, vl); if (status != 0) { - ERROR("write_kafka plugin: create_putval failed with status %i.", status); + ERROR("write_kafka plugin: cmd_create_putval failed with status %i.", + status); return status; } blen = strlen(buffer); @@ -370,6 +371,10 @@ static void kafka_config_topic(rd_kafka_conf_t *conf, status = cf_util_get_flag(child, &tctx->graphite_flags, GRAPHITE_ALWAYS_APPEND_DS); + } else if (strcasecmp("GraphitePreserveSeparator", child->key) == 0) { + status = cf_util_get_flag(child, &tctx->graphite_flags, + GRAPHITE_PRESERVE_SEPARATOR); + } else if (strcasecmp("GraphitePrefix", child->key) == 0) { status = cf_util_get_string(child, &tctx->prefix); } else if (strcasecmp("GraphitePostfix", child->key) == 0) { @@ -393,12 +398,14 @@ static void kafka_config_topic(rd_kafka_conf_t *conf, rd_kafka_topic_conf_set_partitioner_cb(tctx->conf, kafka_partition); rd_kafka_topic_conf_set_opaque(tctx->conf, tctx); - ssnprintf(callback_name, sizeof(callback_name), "write_kafka/%s", - tctx->topic_name); - - user_data_t ud = {.data = tctx, .free_func = kafka_topic_context_free}; + snprintf(callback_name, sizeof(callback_name), "write_kafka/%s", + tctx->topic_name); - status = plugin_register_write(callback_name, kafka_write, &ud); + status = plugin_register_write( + callback_name, kafka_write, + &(user_data_t){ + .data = tctx, .free_func = kafka_topic_context_free, + }); if (status != 0) { WARNING("write_kafka plugin: plugin_register_write (\"%s\") " "failed with status %i.", @@ -474,7 +481,7 @@ static int kafka_config(oconfig_item_t *ci) /* {{{ */ } if (conf != NULL) rd_kafka_conf_destroy(conf); - return (0); + return 0; errout: if (conf != NULL) rd_kafka_conf_destroy(conf);