summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 81947b2)
raw | patch | inline | side by side (parent: 81947b2)
author | Florian Forster <octo@collectd.org> | |
Mon, 3 Sep 2012 06:52:32 +0000 (08:52 +0200) | ||
committer | Florian Forster <octo@collectd.org> | |
Mon, 3 Sep 2012 06:52:32 +0000 (08:52 +0200) |
Don't use the instance name in the identifier when we're using the legacy
configuration mode.
configuration mode.
src/memcached.c | patch | blob | history |
diff --git a/src/memcached.c b/src/memcached.c
index a4dbae222e1595e59b6de198f14a2d95867a305f..59973b0b09bf32ef374e70d35443621acc42853b 100644 (file)
--- a/src/memcached.c
+++ b/src/memcached.c
@@ -231,20 +231,36 @@ static int memcached_query_daemon (char *buffer, size_t buffer_size, memcached_t
return (status);
} /* int memcached_query_daemon */
+static void memcached_init_vl (value_list_t *vl, memcached_t const *st)
+{
+ sstrncpy (vl->plugin, "memcached", sizeof (vl->plugin));
+ if (strcmp (st->name, "__legacy__") == 0) /* legacy mode */
+ {
+ sstrncpy (vl->host, hostname_g, sizeof (vl->host));
+ }
+ else
+ {
+ if (st->socket != NULL)
+ sstrncpy (vl->host, hostname_g, sizeof (vl->host));
+ else
+ sstrncpy (vl->host,
+ (st->host != NULL) ? st->host : MEMCACHED_DEF_HOST,
+ sizeof (vl->host));
+ sstrncpy (vl->plugin_instance, st->name, sizeof (vl->plugin_instance));
+ }
+}
+
static void submit_derive (const char *type, const char *type_inst,
derive_t value, memcached_t *st)
{
value_t values[1];
value_list_t vl = VALUE_LIST_INIT;
+ memcached_init_vl (&vl, st);
values[0].derive = value;
vl.values = values;
vl.values_len = 1;
- sstrncpy (vl.host, hostname_g, sizeof (vl.host));
- sstrncpy (vl.plugin, "memcached", sizeof (vl.plugin));
- if (st->name != NULL)
- sstrncpy (vl.plugin_instance, st->name, sizeof (vl.plugin_instance));
sstrncpy (vl.type, type, sizeof (vl.type));
if (type_inst != NULL)
sstrncpy (vl.type_instance, type_inst, sizeof (vl.type_instance));
{
value_t values[2];
value_list_t vl = VALUE_LIST_INIT;
+ memcached_init_vl (&vl, st);
values[0].derive = value0;
values[1].derive = value1;
vl.values = values;
vl.values_len = 2;
- sstrncpy (vl.host, hostname_g, sizeof (vl.host));
- sstrncpy (vl.plugin, "memcached", sizeof (vl.plugin));
- if (st->name != NULL)
- sstrncpy (vl.plugin_instance, st->name, sizeof (vl.plugin_instance));
sstrncpy (vl.type, type, sizeof (vl.type));
if (type_inst != NULL)
sstrncpy (vl.type_instance, type_inst, sizeof (vl.type_instance));
{
value_t values[1];
value_list_t vl = VALUE_LIST_INIT;
+ memcached_init_vl (&vl, st);
values[0].gauge = value;
vl.values = values;
vl.values_len = 1;
- sstrncpy (vl.host, hostname_g, sizeof (vl.host));
- sstrncpy (vl.plugin, "memcached", sizeof (vl.plugin));
- if (st->name != NULL)
- sstrncpy (vl.plugin_instance, st->name, sizeof (vl.plugin_instance));
sstrncpy (vl.type, type, sizeof (vl.type));
if (type_inst != NULL)
sstrncpy (vl.type_instance, type_inst, sizeof (vl.type_instance));
{
value_t values[2];
value_list_t vl = VALUE_LIST_INIT;
+ memcached_init_vl (&vl, st);
values[0].gauge = value0;
values[1].gauge = value1;
vl.values = values;
vl.values_len = 2;
- sstrncpy (vl.host, hostname_g, sizeof (vl.host));
- sstrncpy (vl.plugin, "memcached", sizeof (vl.plugin));
- if (st->name != NULL)
- sstrncpy (vl.plugin_instance, st->name, sizeof (vl.plugin_instance));
sstrncpy (vl.type, type, sizeof (vl.type));
if (type_inst != NULL)
sstrncpy (vl.type_instance, type_inst, sizeof (vl.type_instance));
st->port = NULL;
if (strcasecmp (ci->key, "Plugin") == 0) /* default instance */
- st->name = sstrdup ("default");
+ st->name = sstrdup ("__legacy__");
else /* <Instance /> block */
status = cf_util_get_string (ci, &st->name);
if (status != 0)
if (st == NULL)
return (ENOMEM);
memset (st, 0, sizeof (*st));
- st->name = sstrdup ("default");
+ st->name = sstrdup ("__legacy__");
st->socket = NULL;
st->host = NULL;
st->port = NULL;