diff --git a/src/write_tsdb.c b/src/write_tsdb.c
index 9dff2904fbff14e81cca8dff62a5faf8d6cb800e..27ea4738051c9d6f6192b5cb76149816a5831c8a 100644 (file)
--- a/src/write_tsdb.c
+++ b/src/write_tsdb.c
#include "configfile.h"
#include "utils_cache.h"
#include "configfile.h"
#include "utils_cache.h"
-#include "utils_parse_option.h"
#include <pthread.h>
#include <sys/socket.h>
#include <pthread.h>
#include <sys/socket.h>
} while (0)
if (ds->ds[ds_num].type == DS_TYPE_GAUGE)
} while (0)
if (ds->ds[ds_num].type == DS_TYPE_GAUGE)
- BUFFER_ADD("%f", vl->values[ds_num].gauge);
+ BUFFER_ADD(GAUGE_FORMAT, vl->values[ds_num].gauge);
else if (store_rates)
{
if (rates == NULL)
else if (store_rates)
{
if (rates == NULL)
"uc_get_rate failed.");
return -1;
}
"uc_get_rate failed.");
return -1;
}
- BUFFER_ADD("%f", rates[ds_num]);
+ BUFFER_ADD(GAUGE_FORMAT, rates[ds_num]);
}
else if (ds->ds[ds_num].type == DS_TYPE_COUNTER)
BUFFER_ADD("%llu", vl->values[ds_num].counter);
}
else if (ds->ds[ds_num].type == DS_TYPE_COUNTER)
BUFFER_ADD("%llu", vl->values[ds_num].counter);
if (ds_name != NULL) {
if (vl->plugin_instance[0] == '\0') {
if (ds_name != NULL) {
if (vl->plugin_instance[0] == '\0') {
- ssnprintf(ret, ret_len, "%s%s.%s",
- prefix, vl->plugin, ds_name);
- } else if (vl->type_instance == '\0') {
- ssnprintf(ret, ret_len, "%s%s.%s.%s.%s",
- prefix, vl->plugin, vl->plugin_instance,
- vl->type_instance, ds_name);
- } else {
- ssnprintf(ret, ret_len, "%s%s.%s.%s.%s",
- prefix, vl->plugin, vl->plugin_instance, vl->type,
- ds_name);
+ if (vl->type_instance[0] == '\0') {
+ ssnprintf(ret, ret_len, "%s%s.%s.%s", prefix, vl->plugin,
+ vl->type, ds_name);
+ } else {
+ ssnprintf(ret, ret_len, "%s%s.%s.%s.%s", prefix, vl->plugin,
+ vl->type, vl->type_instance, ds_name);
+ }
+ } else { /* vl->plugin_instance != "" */
+ if (vl->type_instance[0] == '\0') {
+ ssnprintf(ret, ret_len, "%s%s.%s.%s.%s", prefix, vl->plugin,
+ vl->plugin_instance, vl->type, ds_name);
+ } else {
+ ssnprintf(ret, ret_len, "%s%s.%s.%s.%s.%s", prefix,
+ vl->plugin, vl->plugin_instance, vl->type,
+ vl->type_instance, ds_name);
+ }
+ }
+ } else { /* ds_name == NULL */
+ if (vl->plugin_instance[0] == '\0') {
+ if (vl->type_instance[0] == '\0') {
+ ssnprintf(ret, ret_len, "%s%s.%s", prefix, vl->plugin,
+ vl->type);
+ } else {
+ ssnprintf(ret, ret_len, "%s%s.%s.%s", prefix, vl->plugin,
+ vl->type_instance, vl->type);
+ }
+ } else { /* vl->plugin_instance != "" */
+ if (vl->type_instance[0] == '\0') {
+ ssnprintf(ret, ret_len, "%s%s.%s.%s", prefix, vl->plugin,
+ vl->plugin_instance, vl->type);
+ } else {
+ ssnprintf(ret, ret_len, "%s%s.%s.%s.%s", prefix, vl->plugin,
+ vl->plugin_instance, vl->type, vl->type_instance);
+ }
}
}
- } else if (vl->plugin_instance[0] == '\0') {
- if (vl->type_instance[0] == '\0')
- ssnprintf(ret, ret_len, "%s%s.%s",
- prefix, vl->plugin, vl->type);
- else
- ssnprintf(ret, ret_len, "%s%s.%s",
- prefix, vl->plugin, vl->type_instance);
- } else if (vl->type_instance[0] == '\0') {
- ssnprintf(ret, ret_len, "%s%s.%s.%s",
- prefix, vl->plugin, vl->plugin_instance, vl->type);
- } else {
- ssnprintf(ret, ret_len, "%s%s.%s.%s",
- prefix, vl->plugin, vl->plugin_instance, vl->type_instance);
}
sfree(temp);
}
sfree(temp);
char *tags = "";
char message[1024];
char *host_tags = cb->host_tags ? cb->host_tags : "";
char *tags = "";
char message[1024];
char *host_tags = cb->host_tags ? cb->host_tags : "";
- const char *message_fmt;
const char *meta_tsdb = "tsdb_tags";
/* skip if value is NaN */
const char *meta_tsdb = "tsdb_tags";
/* skip if value is NaN */
}
}
}
}
- message_fmt = "put %s %u %s fqdn=%s %s %s\r\n";
- message_len = ssnprintf (message, sizeof(message),
- message_fmt,
- key,
- (unsigned int)CDTIME_T_TO_TIME_T(
- time),
- value,
- host,
- tags,
- host_tags);
+ message_len = ssnprintf (message,
+ sizeof(message),
+ "put %s %.0f %s fqdn=%s %s %s\r\n",
+ key,
+ CDTIME_T_TO_DOUBLE(time),
+ value,
+ host,
+ tags,
+ host_tags);
sfree(temp);
sfree(temp);