X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fwrite_sensu.c;h=cb0c2fe2dc4ce8cac97f7cb7fc7ef7f82bdb21a5;hb=0c88d3b2d330c152be0bc6af8faecef0211a705e;hp=aef97e5bf2e37c3d450b8f13c38f6229c3b30b26;hpb=021237b2bf08bd39f93ac44f88d56f3193f63078;p=collectd.git diff --git a/src/write_sensu.c b/src/write_sensu.c index aef97e5b..cb0c2fe2 100644 --- a/src/write_sensu.c +++ b/src/write_sensu.c @@ -469,7 +469,7 @@ static char *sensu_value_to_json(struct sensu_host const *host, /* {{{ */ // calculate the value and set to a string if (ds->ds[index].type == DS_TYPE_GAUGE) { double tmp_v = (double) vl->values[index].gauge; - res = asprintf(&value_str, "%.8f", tmp_v, sensu_tags); + res = asprintf(&value_str, "%.8f", tmp_v); if (res == -1) { free(ret_str); ERROR("write_sensu plugin: Unable to alloc memory"); @@ -477,25 +477,36 @@ static char *sensu_value_to_json(struct sensu_host const *host, /* {{{ */ } } else if (rates != NULL) { double tmp_v = (double) rates[index]; - res = asprintf(&value_str, "%.8f", tmp_v, sensu_tags); + res = asprintf(&value_str, "%.8f", tmp_v); if (res == -1) { free(ret_str); ERROR("write_sensu plugin: Unable to alloc memory"); return NULL; } } else { - int64_t tmp_v; - if (ds->ds[index].type == DS_TYPE_DERIVE) - tmp_v = (int64_t) vl->values[index].derive; - else if (ds->ds[index].type == DS_TYPE_ABSOLUTE) - tmp_v = (int64_t) vl->values[index].absolute; - else - tmp_v = (int64_t) vl->values[index].counter; - res = asprintf(&value_str, "%lld", tmp_v, sensu_tags); - if (res == -1) { - free(ret_str); - ERROR("write_sensu plugin: Unable to alloc memory"); - return NULL; + if (ds->ds[index].type == DS_TYPE_DERIVE) { + res = asprintf(&value_str, "%"PRIi64, vl->values[index].derive); + if (res == -1) { + free(ret_str); + ERROR("write_sensu plugin: Unable to alloc memory"); + return NULL; + } + } + else if (ds->ds[index].type == DS_TYPE_ABSOLUTE) { + res = asprintf(&value_str, "%"PRIu64, vl->values[index].absolute); + if (res == -1) { + free(ret_str); + ERROR("write_sensu plugin: Unable to alloc memory"); + return NULL; + } + } + else { + res = asprintf(&value_str, "%llu", vl->values[index].counter); + if (res == -1) { + free(ret_str); + ERROR("write_sensu plugin: Unable to alloc memory"); + return NULL; + } } }