summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 2d962f9)
raw | patch | inline | side by side (parent: 2d962f9)
author | Sebastian Harl <sh@tokkee.org> | |
Sat, 5 Jul 2014 08:40:44 +0000 (10:40 +0200) | ||
committer | Sebastian Harl <sh@tokkee.org> | |
Sat, 5 Jul 2014 08:40:44 +0000 (10:40 +0200) |
src/backend/collectd/unixsock.c | patch | blob | history |
index 1faa9c80394aca5db5f5cc390ba6ed49b5521ddd..7145e9d2dc45c387fade499c992428286ce2efac 100644 (file)
} /* sdb_collectd_store_host */
static int
-sdb_collectd_add_svc(const char *hostname, const char *plugin,
- const char *type, sdb_time_t last_update)
+sdb_collectd_add_svc(const char *hostname, char *plugin, char *type,
+ sdb_time_t last_update)
{
- char name[strlen(plugin) + strlen(type) + 2];
+ char name[strlen(plugin) + strlen(type) + 2];
+ char *plugin_instance, *type_instance;
+
+ sdb_data_t data = { SDB_TYPE_STRING, { .string = NULL } };
+
int status;
snprintf(name, sizeof(name), "%s/%s", plugin, type);
"store/update service '%s/%s'.", hostname, name);
return -1;
}
+
+ plugin_instance = strchr(plugin, '-');
+ if (plugin_instance) {
+ *plugin_instance = '\0';
+ ++plugin_instance;
+
+ data.data.string = plugin_instance;
+ sdb_store_service_attr(hostname, name,
+ "plugin_instance", &data, last_update);
+ }
+
+ type_instance = strchr(type, '-');
+ if (type_instance) {
+ *type_instance = '\0';
+ ++type_instance;
+
+ data.data.string = type_instance;
+ sdb_store_service_attr(hostname, name,
+ "type_instance", &data, last_update);
+ }
+
+ data.data.string = plugin;
+ sdb_store_service_attr(hostname, name, "plugin", &data, last_update);
+ data.data.string = type;
+ sdb_store_service_attr(hostname, name, "type", &data, last_update);
return 0;
} /* sdb_collectd_add_svc */
size_t n, sdb_data_t *data, sdb_object_t *user_data)
{
sdb_collectd_state_t *state;
+ sdb_data_t last_update;
char *hostname;
- const char *plugin;
- const char *type;
- sdb_data_t last_update;
+ char *plugin;
+ char *type;
assert(user_data);