Turbostat: downcase plugin name in log messages
[collectd.git] / src / write_tsdb.c
index 8b10fd6..b7f46f1 100644 (file)
@@ -47,7 +47,6 @@
 #include "configfile.h"
 
 #include "utils_cache.h"
-#include "utils_parse_option.h"
 
 #include <pthread.h>
 #include <sys/socket.h>
@@ -80,10 +79,8 @@ struct wt_callback
     char     *node;
     char     *service;
     char     *host_tags;
-    char     escape_char;
 
     _Bool    store_rates;
-    _Bool    separate_instances;
     _Bool    always_append_ds;
 
     char     send_buf[WT_SEND_BUF_SIZE];
@@ -370,7 +367,7 @@ static int wt_format_name(char *ret, int ret_len,
         if (vl->plugin_instance[0] == '\0') {
             ssnprintf(ret, ret_len, "%s%s.%s",
                       prefix, vl->plugin, ds_name);
-        } else if (vl->type_instance == '\0') {
+        } else if (vl->type_instance[0] == '\0') {
             ssnprintf(ret, ret_len, "%s%s.%s.%s.%s",
                       prefix, vl->plugin, vl->plugin_instance,
                       vl->type_instance, ds_name);
@@ -390,8 +387,8 @@ static int wt_format_name(char *ret, int ret_len,
         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);
+        ssnprintf(ret, ret_len, "%s%s.%s.%s.%s",
+                  prefix, vl->plugin, vl->plugin_instance, vl->type, vl->type_instance);
     }
 
     sfree(temp);
@@ -407,7 +404,7 @@ static int wt_send_message (const char* key, const char* value,
     char *temp = NULL;
     char *tags = "";
     char message[1024];
-    const char *message_fmt;
+    char *host_tags = cb->host_tags ? cb->host_tags : "";
     const char *meta_tsdb = "tsdb_tags";
 
     /* skip if value is NaN */
@@ -428,16 +425,15 @@ static int wt_send_message (const char* key, const char* value,
         }
     }
 
-    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,
-                                      cb->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);
 
@@ -564,37 +560,6 @@ static int wt_write(const data_set_t *ds, const value_list_t *vl,
     return status;
 }
 
-static int config_set_char(char *dest,
-                           oconfig_item_t *ci)
-{
-    char buffer[4];
-    int status;
-
-    memset(buffer, 0, sizeof(buffer));
-
-    status = cf_util_get_string_buffer(ci, buffer, sizeof(buffer));
-    if (status != 0)
-        return (status);
-
-    if (buffer[0] == 0)
-    {
-        ERROR("write_tsdb plugin: Cannot use an empty string for the "
-              "\"EscapeCharacter\" option.");
-        return -1;
-    }
-
-    if (buffer[1] != 0)
-    {
-        WARNING("write_tsdb plugin: Only the first character of the "
-                "\"EscapeCharacter\" option ('%c') will be used.",
-                (int) buffer[0]);
-    }
-
-    *dest = buffer[0];
-
-    return 0;
-}
-
 static int wt_config_tsd(oconfig_item_t *ci)
 {
     struct wt_callback *cb;
@@ -613,8 +578,7 @@ static int wt_config_tsd(oconfig_item_t *ci)
     cb->node = NULL;
     cb->service = NULL;
     cb->host_tags = NULL;
-    cb->escape_char = WT_DEFAULT_ESCAPE;
-    cb->store_rates = 1;
+    cb->store_rates = 0;
 
     pthread_mutex_init (&cb->send_lock, NULL);
 
@@ -630,12 +594,8 @@ static int wt_config_tsd(oconfig_item_t *ci)
             cf_util_get_string(child, &cb->host_tags);
         else if (strcasecmp("StoreRates", child->key) == 0)
             cf_util_get_boolean(child, &cb->store_rates);
-        else if (strcasecmp("SeparateInstances", child->key) == 0)
-            cf_util_get_boolean(child, &cb->separate_instances);
         else if (strcasecmp("AlwaysAppendDS", child->key) == 0)
             cf_util_get_boolean(child, &cb->always_append_ds);
-        else if (strcasecmp("EscapeCharacter", child->key) == 0)
-            config_set_char(&cb->escape_char, child);
         else
         {
             ERROR("write_tsdb plugin: Invalid configuration "