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;