write_graphite plugin: Add the "SeparateInstances" option.
authorFlorian Forster <octo@collectd.org>
Mon, 20 Feb 2012 16:20:21 +0000 (17:20 +0100)
committerFlorian Forster <octo@collectd.org>
Mon, 20 Feb 2012 16:24:46 +0000 (17:24 +0100)
Change-Id: I8670b62ed323698c7764d3039ccd8af052bd1b6f

src/collectd.conf.pod
src/write_graphite.c

index fbdd23d..6f79266 100644 (file)
@@ -4818,6 +4818,13 @@ If set to B<true>, convert counter values to rates. If set to B<false> (the
 default) counter values are stored as is, i.E<nbsp>e. as an increasing integer
 number.
 
+=item B<SeparateInstances> B<false>|B<true>
+
+If set to B<true>, the plugin instance and type instance will be in their own
+path component, for example C<host.cpu.0.cpu.idle>. If set to B<false> (the
+default), the plugin and plugin instance (and likewise the type and type
+instance) are put into once component, for example C<host.cpu-0.cpu-idle>.
+
 =item B<AlwaysAppendDS> B<false>|B<true>
 
 If set the B<true>, append the name of the I<Data Source> (DS) to the "metric"
index 3ff8e04..e59572b 100644 (file)
@@ -85,6 +85,7 @@ struct wg_callback
     char     escape_char;
 
     _Bool    store_rates;
+    _Bool    separate_instances;
     _Bool    always_append_ds;
 
     char     send_buf[WG_SEND_BUF_SIZE];
@@ -410,14 +411,18 @@ static int wg_format_name (char *ret, int ret_len,
             sizeof (n_type_instance), cb->escape_char);
 
     if (n_plugin_instance[0] != '\0')
-        ssnprintf (tmp_plugin, sizeof (tmp_plugin), "%s-%s",
-            n_plugin, n_plugin_instance);
+        ssnprintf (tmp_plugin, sizeof (tmp_plugin), "%s%c%s",
+            n_plugin,
+            cb->separate_instances ? '.' : '-',
+            n_plugin_instance);
     else
         sstrncpy (tmp_plugin, n_plugin, sizeof (tmp_plugin));
 
     if (n_type_instance[0] != '\0')
-        ssnprintf (tmp_type, sizeof (tmp_type), "%s-%s",
-            n_type, n_type_instance);
+        ssnprintf (tmp_type, sizeof (tmp_type), "%s%c%s",
+            n_type,
+            cb->separate_instances ? '.' : '-',
+            n_type_instance);
     else
         sstrncpy (tmp_type, n_type, sizeof (tmp_type));
 
@@ -633,6 +638,8 @@ static int wg_config_carbon (oconfig_item_t *ci)
             cf_util_get_string (child, &cb->postfix);
         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)