} /* value_cache_t *cache_search */
static int cache_alloc_name (char *ret, int ret_len,
+ const char *hostname,
const char *plugin, const char *plugin_instance,
const char *type, const char *type_instance)
{
if ((plugin_instance == NULL) || (strlen (plugin_instance) == 0))
{
if ((type_instance == NULL) || (strlen (type_instance) == 0))
- status = snprintf (ret, ret_len, "%s/%s",
- plugin, type);
+ status = snprintf (ret, ret_len, "%s/%s/%s",
+ hostname, plugin, type);
else
- status = snprintf (ret, ret_len, "%s/%s-%s",
- plugin, type, type_instance);
+ status = snprintf (ret, ret_len, "%s/%s/%s-%s",
+ hostname, plugin, type, type_instance);
}
else
{
if ((type_instance == NULL) || (strlen (type_instance) == 0))
- status = snprintf (ret, ret_len, "%s-%s/%s",
- plugin, plugin_instance, type);
+ status = snprintf (ret, ret_len, "%s/%s-%s/%s",
+ hostname, plugin, plugin_instance, type);
else
- status = snprintf (ret, ret_len, "%s-%s/%s-%s",
- plugin, plugin_instance,
- type, type_instance);
+ status = snprintf (ret, ret_len, "%s/%s-%s/%s-%s",
+ hostname, plugin, plugin_instance, type, type_instance);
}
if ((status < 1) || (status >= ret_len))
}
if (cache_alloc_name (vc->name, sizeof (vc->name),
- vl->plugin, vl->plugin_instance,
+ vl->host, vl->plugin, vl->plugin_instance,
ds->type, vl->type_instance) != 0)
{
pthread_mutex_unlock (&cache_lock);
int i;
if (cache_alloc_name (name, sizeof (name),
+ vl->host,
vl->plugin, vl->plugin_instance,
ds->type, vl->type_instance) != 0)
return (-1);
/ (vl->time - vc->time);
}
- DBG ("name = %s; old counter: %llu; new counter: %llu; rate: %lf;",
- name,
- vc->counter[i], vl->values[i].counter,
- vc->gauge[i]);
-
vc->counter[i] = vl->values[i].counter;
}
else if (ds->ds[i].type == DS_TYPE_GAUGE)
{
vc->gauge[i] = vl->values[i].gauge;
vc->counter[i] = 0;
-
- DBG ("name, %s; gauge: %lf;",
- name, vc->gauge[i]);
}
else
{
static int us_handle_getval (FILE *fh, char **fields, int fields_num)
{
- char *plugin = fields[1];
+ char *hostname = fields[1];
+ char *plugin;
char *plugin_instance;
char *type;
char *type_instance;
if (fields_num != 2)
return (-1);
+ plugin = strchr (hostname, '/');
+ if (plugin == NULL)
+ return (-1);
+ *plugin = '\0'; plugin++;
+
type = strchr (plugin, '/');
if (type == NULL)
return (-1);
}
status = cache_alloc_name (name, sizeof (name),
- plugin, plugin_instance, type, type_instance);
+ hostname, plugin, plugin_instance, type, type_instance);
if (status != 0)
return (-1);
int status;
int *remote_fd;
pthread_t th;
+ pthread_attr_t th_attr;
if (us_open_socket () != 0)
pthread_exit ((void *) 1);
DBG ("Spawning child to handle connection on fd #%i", *remote_fd);
- status = pthread_create (&th, NULL, us_handle_client, (void *) remote_fd);
+ pthread_attr_init (&th_attr);
+ pthread_attr_setdetachstate (&th_attr, PTHREAD_CREATE_DETACHED);
+
+ status = pthread_create (&th, &th_attr, us_handle_client, (void *) remote_fd);
if (status != 0)
{
syslog (LOG_WARNING, "unixsock plugin: pthread_create failed: %s",
pthread_join (listen_thread, &ret);
}
+ plugin_unregister_init ("unixsock");
+ plugin_unregister_write ("unixsock");
+ plugin_unregister_shutdown ("unixsock");
+
return (0);
} /* int us_shutdown */