From 2baa8ad07f638f826d250e1cd5dec09e2a775ca7 Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Mon, 20 Feb 2012 17:20:21 +0100 Subject: [PATCH] write_graphite plugin: Add the "SeparateInstances" option. Change-Id: I8670b62ed323698c7764d3039ccd8af052bd1b6f --- src/collectd.conf.pod | 7 +++++++ src/write_graphite.c | 15 +++++++++++---- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/collectd.conf.pod b/src/collectd.conf.pod index fbdd23d7..6f79266a 100644 --- a/src/collectd.conf.pod +++ b/src/collectd.conf.pod @@ -4818,6 +4818,13 @@ If set to B, convert counter values to rates. If set to B (the default) counter values are stored as is, i.Ee. as an increasing integer number. +=item B B|B + +If set to B, the plugin instance and type instance will be in their own +path component, for example C. If set to B (the +default), the plugin and plugin instance (and likewise the type and type +instance) are put into once component, for example C. + =item B B|B If set the B, append the name of the I (DS) to the "metric" diff --git a/src/write_graphite.c b/src/write_graphite.c index 3ff8e04d..e59572b1 100644 --- a/src/write_graphite.c +++ b/src/write_graphite.c @@ -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) -- 2.11.0