author | Sebastian Harl <sh@tokkee.org> | |
Sun, 29 Jun 2014 15:35:39 +0000 (17:35 +0200) | ||
committer | Sebastian Harl <sh@tokkee.org> | |
Sun, 29 Jun 2014 15:35:39 +0000 (17:35 +0200) |
19 files changed:
diff --git a/configure.ac b/configure.ac
index 5f778027b601b44d25473a1bae31d88c24db816a..b94b2a0e0fca679d3f55f697649f177d39e64e51 100644 (file)
--- a/configure.ac
+++ b/configure.ac
AC_SUBST([COVERAGE_CFLAGS])
AC_SUBST([COVERAGE_LDFLAGS])
+AC_ARG_ENABLE([gprof],
+ AS_HELP_STRING([--enable-gprof],
+ [Gprof profiling @<:@default=no@:>@]),
+ [enable_gprof="$enableval"],
+ [enable_gprof="no"])
+
+PROFILING_CFLAGS=""
+PROFILING_LDFLAGS=""
+if test "x$enable_gprof" = "xyes"; then
+ PROFILING_CFLAGS="-O0"
+ profiling_flag_have_problem="no"
+
+ AC_MSG_CHECKING([whether $CC accepts -pg])
+ if test_cc_flags -pg; then
+ PROFILING_CFLAGS="$PROFILING_CFLAGS -pg"
+ PROFILING_LDFLAGS="$PROFILING_LDFLAGS -pg"
+ AC_MSG_RESULT([yes])
+ else
+ AC_MSG_RESULT([no])
+ profiling_flag_have_problem="yes"
+ fi
+
+ for flag in -fprofile-arcs; do
+ AC_MSG_CHECKING([whether $CC accepts $flag])
+ if test_cc_flags $flag; then
+ PROFILING_CFLAGS="$PROFILING_CFLAGS $flag"
+ AC_MSG_RESULT([yes])
+ fi
+ # else: this is not a serious problem
+ done
+
+ if test "x$profiling_flag_have_problem" != "xno"; then
+ AC_MSG_WARN([Some profiling flags are not supported by your compiler!])
+ fi
+fi
+AC_SUBST([PROFILING_CFLAGS])
+AC_SUBST([PROFILING_LDFLAGS])
+
m4_divert_once([HELP_ENABLE], [
Build dependencies:])
AC_MSG_RESULT([ stdio mocking: . . . . . $have_fopencookie])
AC_MSG_RESULT([ coverage testing: . . . . . $enable_gcov])
AC_MSG_RESULT([ integration testing: . . . $integration_tests])
+AC_MSG_RESULT([ profiling: . . . . . . . . $enable_gprof])
AC_MSG_RESULT()
AC_MSG_RESULT([ Libraries:])
AC_MSG_RESULT([ libdbi: . . . . . . . . . . $with_libdbi])
diff --git a/src/Makefile.am b/src/Makefile.am
index d851492580b9d4620b272e2a76d96254a8936cf4..686827b5a470ca2a8f5af18cd39c3832219f928e 100644 (file)
--- a/src/Makefile.am
+++ b/src/Makefile.am
SUBDIRS = liboconfig
# coverage related flags are only set when gcov is enabled
-AM_CFLAGS = @STRICT_CFLAGS@ @COVERAGE_CFLAGS@
-AM_LDFLAGS = @COVERAGE_LDFLAGS@
+AM_CFLAGS = @STRICT_CFLAGS@ @COVERAGE_CFLAGS@ @PROFILING_CFLAGS@
+AM_LDFLAGS = @COVERAGE_LDFLAGS@ @PROFILING_LDFLAGS@
AM_CPPFLAGS = -I"${top_srcdir}/src/include"
AM_CPPFLAGS += -DSYSCONFDIR='"${sysconfdir}"'
AM_CPPFLAGS += -DLOCALSTATEDIR='"${localstatedir}"'
noinst_LTLIBRARIES += libsysdb_fe_parser.la
libsysdb_fe_parser_la_SOURCES = \
frontend/grammar.y frontend/scanner.l
-libsysdb_fe_parser_la_CFLAGS = -DBUILD_DATE="\"$$( date --utc '+%F %T' ) (UTC)\""
+libsysdb_fe_parser_la_CFLAGS = @COVERAGE_CFLAGS@ @PROFILING_CFLAGS@ \
+ -DBUILD_DATE="\"$$( date --utc '+%F %T' ) (UTC)\""
libsysdb_la_SOURCES = \
sysdb.c include/sysdb.h \
core/object.c include/core/object.h \
# don't use strict CFLAGS for flex code
noinst_LTLIBRARIES += libsysdb_scanner.la
libsysdb_scanner_la_SOURCES = tools/sysdb/scanner.l
-libsysdb_scanner_la_CFLAGS = -DBUILD_DATE="\"$$( date --utc '+%F %T' ) (UTC)\""
+libsysdb_scanner_la_CFLAGS = @COVERAGE_CFLAGS@ @PROFILING_CFLAGS@ \
+ -DBUILD_DATE="\"$$( date --utc '+%F %T' ) (UTC)\""
sysdb_SOURCES = tools/sysdb/main.c include/client/sysdb.h \
tools/sysdb/command.c tools/sysdb/command.h \
tools/sysdb/input.c tools/sysdb/input.h \
index 8ac829d117c85c5ccae04bba44be92da7aa13c0f..00e1258eb222761d052a556824deac68fb690997 100644 (file)
char *name = NULL;
char *socket_path = NULL;
- char cb_name[1024];
-
sdb_object_t *user_data;
sdb_unixsock_client_t *client;
return -1;
}
- snprintf(cb_name, sizeof(cb_name), "collectd::unixsock::%s", name);
- cb_name[sizeof(cb_name) - 1] = '\0';
-
client = sdb_unixsock_client_create(socket_path);
if (! client) {
char errbuf[1024];
return -1;
}
- sdb_plugin_register_init(cb_name, sdb_collectd_init, user_data);
- sdb_plugin_register_shutdown(cb_name, sdb_collectd_shutdown, user_data);
+ sdb_plugin_register_init(name, sdb_collectd_init, user_data);
+ sdb_plugin_register_shutdown(name, sdb_collectd_shutdown, user_data);
- sdb_plugin_register_collector(cb_name, sdb_collectd_collect,
+ sdb_plugin_register_collector(name, sdb_collectd_collect,
/* interval */ NULL, user_data);
/* pass control to the list */
int
sdb_module_init(sdb_plugin_info_t *info)
{
- sdb_plugin_set_info(info, SDB_PLUGIN_INFO_NAME, "collectd::unixsock");
sdb_plugin_set_info(info, SDB_PLUGIN_INFO_DESC,
"backend accessing the system statistics collection daemon "
"throught the UNIXSOCK interface");
sdb_plugin_set_info(info, SDB_PLUGIN_INFO_VERSION, SDB_VERSION);
sdb_plugin_set_info(info, SDB_PLUGIN_INFO_PLUGIN_VERSION, SDB_VERSION);
- sdb_plugin_register_config("collectd::unixsock", sdb_collectd_config);
+ sdb_plugin_register_config(sdb_collectd_config);
return 0;
} /* sdb_version_extra */
index e631ae7525acee7c8426563ed51c8531f5825a0f..6481807637fb9bfba7ffeb5d584a19b083cf7410 100644 (file)
char *name = NULL;
char *socket_path = NULL;
- char cb_name[1024];
-
sdb_object_t *user_data;
sdb_unixsock_client_t *client;
return -1;
}
- snprintf(cb_name, sizeof(cb_name), "mk-livestatus::%s", name);
- cb_name[sizeof(cb_name) - 1] = '\0';
-
client = sdb_unixsock_client_create(socket_path);
if (! client) {
char errbuf[1024];
return -1;
}
- sdb_plugin_register_init(cb_name, sdb_livestatus_init, user_data);
- sdb_plugin_register_shutdown(cb_name, sdb_livestatus_shutdown, user_data);
- sdb_plugin_register_collector(cb_name, sdb_livestatus_collect,
+ sdb_plugin_register_init(name, sdb_livestatus_init, user_data);
+ sdb_plugin_register_shutdown(name, sdb_livestatus_shutdown, user_data);
+ sdb_plugin_register_collector(name, sdb_livestatus_collect,
/* interval */ NULL, user_data);
/* pass control to the list */
int
sdb_module_init(sdb_plugin_info_t *info)
{
- sdb_plugin_set_info(info, SDB_PLUGIN_INFO_NAME, "MK-Livestatus");
sdb_plugin_set_info(info, SDB_PLUGIN_INFO_DESC,
"backend accessing Nagios/Icinga/Shinken using MK Livestatus");
sdb_plugin_set_info(info, SDB_PLUGIN_INFO_COPYRIGHT,
sdb_plugin_set_info(info, SDB_PLUGIN_INFO_VERSION, SDB_VERSION);
sdb_plugin_set_info(info, SDB_PLUGIN_INFO_PLUGIN_VERSION, SDB_VERSION);
- sdb_plugin_register_config("mk-livestatus", sdb_livestatus_config);
+ sdb_plugin_register_config(sdb_livestatus_config);
return 0;
} /* sdb_version_extra */
index c2f4d084048c71fbccb945b4f38dd753fda24d8d..ebe5dbd6468821d929a43d31d5e53178069063af 100644 (file)
sdb_puppet_stcfg_config_conn(oconfig_item_t *ci)
{
char *name = NULL;
- char cb_name[1024];
sdb_object_t *user_data;
sdb_dbi_client_t *client;
return -1;
}
- snprintf(cb_name, sizeof(cb_name), "puppet::storeconfigs::%s", name);
- cb_name[sizeof(cb_name) - 1] = '\0';
-
client = sdb_dbi_client_create(driver, database);
if (! client) {
char errbuf[1024];
return -1;
}
- sdb_plugin_register_init(cb_name, sdb_puppet_stcfg_init, user_data);
- sdb_plugin_register_shutdown(cb_name, sdb_puppet_stcfg_shutdown,
+ sdb_plugin_register_init(name, sdb_puppet_stcfg_init, user_data);
+ sdb_plugin_register_shutdown(name, sdb_puppet_stcfg_shutdown,
user_data);
- sdb_plugin_register_collector(cb_name, sdb_puppet_stcfg_collect,
+ sdb_plugin_register_collector(name, sdb_puppet_stcfg_collect,
/* interval */ NULL, user_data);
/* pass control to the list */
int
sdb_module_init(sdb_plugin_info_t *info)
{
- sdb_plugin_set_info(info, SDB_PLUGIN_INFO_NAME, "puppet::store-configs");
sdb_plugin_set_info(info, SDB_PLUGIN_INFO_DESC,
"backend accessing the Puppet stored configuration database");
sdb_plugin_set_info(info, SDB_PLUGIN_INFO_COPYRIGHT,
sdb_plugin_set_info(info, SDB_PLUGIN_INFO_VERSION, SDB_VERSION);
sdb_plugin_set_info(info, SDB_PLUGIN_INFO_PLUGIN_VERSION, SDB_VERSION);
- sdb_plugin_register_config("puppet::store-configs",
- sdb_puppet_stcfg_config);
+ sdb_plugin_register_config(sdb_puppet_stcfg_config);
return 0;
} /* sdb_version_extra */
diff --git a/src/core/plugin.c b/src/core/plugin.c
index b3d5973178dffed19411af5d5acea45a99b718e3..36f80f6e6c29296322fac9979632a0e32ea05f29 100644 (file)
--- a/src/core/plugin.c
+++ b/src/core/plugin.c
char *filename;
/* public attributes */
- char *name;
-
char *description;
char *copyright;
char *license;
int plugin_version;
};
#define SDB_PLUGIN_INFO_INIT { \
- /* plugin_name */ NULL, /* filename */ NULL, \
- /* name */ NULL, /* desc */ NULL, \
+ /* plugin_name */ NULL, /* filename */ NULL, /* desc */ NULL, \
/* copyright */ NULL, /* license */ NULL, \
/* version */ -1, /* plugin_version */ -1 }
#define INFO_GET(i, attr) \
if (info->filename)
free(info->filename);
- if (info->name)
- free(info->name);
if (info->description)
free(info->description);
if (info->copyright)
sdb_llist_append(all_plugins, SDB_OBJ(ctx));
sdb_log(SDB_LOG_INFO, "core: Successfully loaded "
- "plugin '%s' v%i (%s)\n\t%s\n\tLicense: %s",
- INFO_GET(&ctx->info, name), ctx->info.plugin_version,
- INFO_GET(&ctx->info, description),
+ "plugin %s v%i (%s)", ctx->info.plugin_name,
+ ctx->info.plugin_version,
+ INFO_GET(&ctx->info, description));
+ sdb_log(SDB_LOG_INFO, "core: Plugin %s: %s, License: %s",
+ ctx->info.plugin_name,
INFO_GET(&ctx->info, copyright),
INFO_GET(&ctx->info, license));
return 0;
} /* module_load */
+static char *
+plugin_get_name(const char *name, char *buf, size_t bufsize)
+{
+ ctx_t *ctx = ctx_get();
+
+ if (ctx)
+ snprintf(buf, bufsize, "%s::%s", ctx->info.plugin_name, name);
+ else
+ snprintf(buf, bufsize, "core::%s", name);
+ return buf;
+} /* plugin_get_name */
+
static int
plugin_add_callback(sdb_llist_t **list, const char *type,
const char *name, void *callback, sdb_object_t *user_data)
return status;
sdb_log(SDB_LOG_INFO, "core: Successfully reloaded plugin "
- "'%s' (%s)", INFO_GET(&ctx->info, name),
+ "'%s' (%s)", ctx->info.plugin_name,
INFO_GET(&ctx->info, description));
ctx_set(old_ctx);
}
va_start(ap, type);
switch (type) {
- case SDB_PLUGIN_INFO_NAME:
- {
- char *name = va_arg(ap, char *);
- if (name) {
- if (info->name)
- free(info->name);
- info->name = strdup(name);
- }
- }
- break;
case SDB_PLUGIN_INFO_DESC:
{
char *desc = va_arg(ap, char *);
} /* sdb_plugin_set_info */
int
-sdb_plugin_register_config(const char *name, sdb_plugin_config_cb callback)
+sdb_plugin_register_config(sdb_plugin_config_cb callback)
{
- return plugin_add_callback(&config_list, "init", name,
+ ctx_t *ctx = ctx_get();
+
+ if (! ctx) {
+ sdb_log(SDB_LOG_ERR, "core: Invalid attempt to register a "
+ "config callback from outside a plugin");
+ return -1;
+ }
+ return plugin_add_callback(&config_list, "init", ctx->info.plugin_name,
(void *)callback, NULL);
} /* sdb_plugin_register_config */
sdb_plugin_register_init(const char *name, sdb_plugin_init_cb callback,
sdb_object_t *user_data)
{
- return plugin_add_callback(&init_list, "init", name,
+ char cb_name[1024];
+ return plugin_add_callback(&init_list, "init",
+ plugin_get_name(name, cb_name, sizeof(cb_name)),
(void *)callback, user_data);
} /* sdb_plugin_register_init */
sdb_plugin_register_shutdown(const char *name, sdb_plugin_shutdown_cb callback,
sdb_object_t *user_data)
{
- return plugin_add_callback(&shutdown_list, "shutdown", name,
+ char cb_name[1024];
+ return plugin_add_callback(&shutdown_list, "shutdown",
+ plugin_get_name(name, cb_name, sizeof(cb_name)),
(void *)callback, user_data);
} /* sdb_plugin_register_shutdown */
sdb_plugin_register_log(const char *name, sdb_plugin_log_cb callback,
sdb_object_t *user_data)
{
- return plugin_add_callback(&log_list, "log", name, (void *)callback,
- user_data);
+ char cb_name[1024];
+ return plugin_add_callback(&log_list, "log",
+ plugin_get_name(name, cb_name, sizeof(cb_name)),
+ callback, user_data);
} /* sdb_plugin_register_log */
int
sdb_plugin_register_cname(const char *name, sdb_plugin_cname_cb callback,
sdb_object_t *user_data)
{
- return plugin_add_callback(&cname_list, "cname", name, (void *)callback,
- user_data);
+ char cb_name[1024];
+ return plugin_add_callback(&cname_list, "cname",
+ plugin_get_name(name, cb_name, sizeof(cb_name)),
+ callback, user_data);
} /* sdb_plugin_register_cname */
int
sdb_plugin_register_collector(const char *name, sdb_plugin_collector_cb callback,
const sdb_time_t *interval, sdb_object_t *user_data)
{
+ char cb_name[1024];
sdb_object_t *obj;
if ((! name) || (! callback))
@@ -741,7 +756,9 @@ sdb_plugin_register_collector(const char *name, sdb_plugin_collector_cb callback
if (! collector_list)
return -1;
- obj = sdb_object_create(name, sdb_plugin_collector_cb_type,
+ plugin_get_name(name, cb_name, sizeof(cb_name));
+
+ obj = sdb_object_create(cb_name, sdb_plugin_collector_cb_type,
&collector_list, "collector", callback, user_data);
if (! obj)
return -1;
@@ -775,7 +792,7 @@ sdb_plugin_register_collector(const char *name, sdb_plugin_collector_cb callback
sdb_object_deref(obj);
sdb_log(SDB_LOG_INFO, "core: Registered collector callback '%s' "
- "(interval = %.3fs).", name,
+ "(interval = %.3fs).", cb_name,
SDB_TIME_TO_DOUBLE(SDB_PLUGIN_CCB(obj)->ccb_interval));
return 0;
} /* sdb_plugin_register_collector */
if (! plugin) {
ctx_t *ctx = CTX(sdb_llist_search_by_name(all_plugins, name));
if (! ctx)
- sdb_log(SDB_LOG_ERR, "core: Plugin '%s' not loaded.", name);
+ sdb_log(SDB_LOG_ERR, "core: Cannot configure unknown "
+ "plugin '%s'. Missing 'LoadPlugin \"%s\"'?",
+ name, name);
else
sdb_log(SDB_LOG_ERR, "core: Plugin '%s' did not register "
"a config callback.", name);
index e501b2cd830169b2b7de01660207c976ca66f089..14201fe071a77a65ba20b0b17b36a80f1a35d3fd 100644 (file)
--- a/src/core/store-private.h
+++ b/src/core/store-private.h
extern "C" {
#endif
-struct sdb_store_base {
+struct sdb_store_obj {
sdb_object_t super;
/* object type */
/* common meta information */
sdb_time_t last_update;
sdb_time_t interval; /* moving average */
- sdb_store_base_t *parent;
+ sdb_store_obj_t *parent;
};
-#define STORE_BASE(obj) ((sdb_store_base_t *)(obj))
-#define STORE_CONST_BASE(obj) ((const sdb_store_base_t *)(obj))
+#define STORE_OBJ(obj) ((sdb_store_obj_t *)(obj))
+#define STORE_CONST_OBJ(obj) ((const sdb_store_obj_t *)(obj))
typedef struct {
- sdb_store_base_t super;
+ sdb_store_obj_t super;
sdb_data_t value;
} sdb_attribute_t;
-#define SDB_ATTR(obj) ((sdb_attribute_t *)(obj))
-#define SDB_CONST_ATTR(obj) ((const sdb_attribute_t *)(obj))
+#define ATTR(obj) ((sdb_attribute_t *)(obj))
+#define CONST_ATTR(obj) ((const sdb_attribute_t *)(obj))
typedef struct {
- sdb_store_base_t super;
+ sdb_store_obj_t super;
+
+ sdb_llist_t *attributes;
+} sdb_service_t;
+#define SVC(obj) ((sdb_service_t *)(obj))
+#define CONST_SVC(obj) ((const sdb_service_t *)(obj))
+
+typedef struct {
+ sdb_store_obj_t super;
sdb_llist_t *services;
sdb_llist_t *attributes;
-} sdb_store_obj_t;
-#define SDB_STORE_OBJ(obj) ((sdb_store_obj_t *)(obj))
-#define SDB_CONST_STORE_OBJ(obj) ((const sdb_store_obj_t *)(obj))
+} sdb_host_t;
+#define HOST(obj) ((sdb_host_t *)(obj))
+#define CONST_HOST(obj) ((const sdb_host_t *)(obj))
-/* shortcuts for accessing the sdb_store_obj_t attributes
- * of inheriting objects */
+/* shortcuts for accessing service/host attributes */
#define _last_update super.last_update
#define _interval super.interval
* conditionals
*/
-/* compares a store object using the specified conditional */
-typedef int (*cmp_cb)(sdb_store_base_t *, sdb_store_cond_t *);
+/* compares a host using the specified conditional */
+typedef int (*cmp_cb)(sdb_host_t *, sdb_store_cond_t *);
struct sdb_store_cond {
sdb_object_t super;
diff --git a/src/core/store.c b/src/core/store.c
index bb37e26a7d9e074466f70d724a8943acabd03747..1b8243b091d4149a98dabea39927b5eb661b122c 100644 (file)
--- a/src/core/store.c
+++ b/src/core/store.c
*/
static sdb_llist_t *host_list = NULL;
-static pthread_rwlock_t obj_lock = PTHREAD_RWLOCK_INITIALIZER;
+static pthread_rwlock_t host_lock = PTHREAD_RWLOCK_INITIALIZER;
/*
* private types
*/
-static sdb_type_t sdb_store_obj_type;
+static sdb_type_t sdb_host_type;
+static sdb_type_t sdb_service_type;
static sdb_type_t sdb_attribute_type;
static int
-store_base_init(sdb_object_t *obj, va_list ap)
+store_obj_init(sdb_object_t *obj, va_list ap)
{
- sdb_store_base_t *sobj = STORE_BASE(obj);
+ sdb_store_obj_t *sobj = STORE_OBJ(obj);
sobj->type = va_arg(ap, int);
sobj->interval = 0;
sobj->parent = NULL;
return 0;
-} /* store_base_init */
+} /* store_obj_init */
static void
-store_base_destroy(sdb_object_t *obj)
+store_obj_destroy(sdb_object_t *obj)
{
- const sdb_store_base_t *sobj = STORE_CONST_BASE(obj);
+ const sdb_store_obj_t *sobj = STORE_CONST_OBJ(obj);
if (sobj->parent)
sdb_object_deref(SDB_OBJ(sobj->parent));
-} /* store_base_destroy */
+} /* store_obj_destroy */
static int
-sdb_store_obj_init(sdb_object_t *obj, va_list ap)
+sdb_host_init(sdb_object_t *obj, va_list ap)
{
- sdb_store_obj_t *sobj = SDB_STORE_OBJ(obj);
+ sdb_host_t *sobj = HOST(obj);
int ret;
/* this will consume the first argument (type) of ap */
- ret = store_base_init(obj, ap);
+ ret = store_obj_init(obj, ap);
if (ret)
return ret;
if (! sobj->attributes)
return -1;
return 0;
-} /* sdb_store_obj_init */
+} /* sdb_host_init */
static void
-sdb_store_obj_destroy(sdb_object_t *obj)
+sdb_host_destroy(sdb_object_t *obj)
{
- sdb_store_obj_t *sobj = SDB_STORE_OBJ(obj);
-
+ sdb_host_t *sobj = HOST(obj);
assert(obj);
- store_base_destroy(obj);
+ store_obj_destroy(obj);
if (sobj->services)
sdb_llist_destroy(sobj->services);
if (sobj->attributes)
sdb_llist_destroy(sobj->attributes);
-} /* sdb_store_obj_destroy */
+} /* sdb_host_destroy */
+
+static int
+sdb_service_init(sdb_object_t *obj, va_list ap)
+{
+ sdb_service_t *sobj = SVC(obj);
+ int ret;
+
+ /* this will consume the first argument (type) of ap */
+ ret = store_obj_init(obj, ap);
+ if (ret)
+ return ret;
+
+ sobj->attributes = sdb_llist_create();
+ if (! sobj->attributes)
+ return -1;
+ return 0;
+} /* sdb_service_init */
+
+static void
+sdb_service_destroy(sdb_object_t *obj)
+{
+ sdb_service_t *sobj = SVC(obj);
+ assert(obj);
+
+ store_obj_destroy(obj);
+
+ if (sobj->attributes)
+ sdb_llist_destroy(sobj->attributes);
+} /* sdb_service_destroy */
static int
sdb_attr_init(sdb_object_t *obj, va_list ap)
/* this will consume the first two arguments
* (type and last_update) of ap */
- ret = store_base_init(obj, ap);
+ ret = store_obj_init(obj, ap);
if (ret)
return ret;
value = va_arg(ap, const sdb_data_t *);
if (value)
- if (sdb_data_copy(&SDB_ATTR(obj)->value, value))
+ if (sdb_data_copy(&ATTR(obj)->value, value))
return -1;
return 0;
} /* sdb_attr_init */
{
assert(obj);
- store_base_destroy(obj);
- sdb_data_free_datum(&SDB_ATTR(obj)->value);
+ store_obj_destroy(obj);
+ sdb_data_free_datum(&ATTR(obj)->value);
} /* sdb_attr_destroy */
-static sdb_type_t sdb_store_obj_type = {
- sizeof(sdb_store_obj_t),
+static sdb_type_t sdb_host_type = {
+ sizeof(sdb_host_t),
+ sdb_host_init,
+ sdb_host_destroy
+};
- sdb_store_obj_init,
- sdb_store_obj_destroy
+static sdb_type_t sdb_service_type = {
+ sizeof(sdb_service_t),
+ sdb_service_init,
+ sdb_service_destroy
};
static sdb_type_t sdb_attribute_type = {
sizeof(sdb_attribute_t),
-
sdb_attr_init,
sdb_attr_destroy
};
* private helper functions
*/
-static sdb_store_obj_t *
+static sdb_host_t *
lookup_host(const char *name)
{
- return SDB_STORE_OBJ(sdb_llist_search_by_name(host_list, name));
+ return HOST(sdb_llist_search_by_name(host_list, name));
} /* lookup_host */
-/* The obj_lock has to be acquired before calling this function. */
+/* The host_lock has to be acquired before calling this function. */
static int
store_obj(const char *hostname, int type, const char *name,
- sdb_time_t last_update, sdb_store_base_t **updated_obj)
+ sdb_time_t last_update, sdb_store_obj_t **updated_obj)
{
char *host_cname = NULL, *cname = NULL;
sdb_llist_t *parent_list;
- sdb_store_base_t *old;
+ sdb_store_obj_t *old;
int status = 0;
if (last_update <= 0)
}
if (hostname) {
- sdb_store_obj_t *host;
+ sdb_host_t *host;
host_cname = sdb_plugin_cname(strdup(hostname));
if (! host_cname) {
}
if (type == SDB_HOST)
- old = STORE_BASE(sdb_llist_search_by_name(host_list, name));
+ old = STORE_OBJ(sdb_llist_search_by_name(host_list, name));
else
- old = STORE_BASE(sdb_llist_search_by_name(parent_list, name));
+ old = STORE_OBJ(sdb_llist_search_by_name(parent_list, name));
if (old) {
if (old->last_update > last_update) {
*updated_obj = old;
}
else {
- sdb_store_base_t *new;
+ sdb_store_obj_t *new;
- if (type == SDB_ATTRIBUTE)
+ if (type == SDB_ATTRIBUTE) {
/* the value will be updated by the caller */
- new = STORE_BASE(sdb_object_create(name, sdb_attribute_type,
+ new = STORE_OBJ(sdb_object_create(name, sdb_attribute_type,
type, last_update, NULL));
- else
- new = STORE_BASE(sdb_object_create(name, sdb_store_obj_type,
- type, last_update));
+ }
+ else {
+ sdb_type_t t;
+ t = type == SDB_HOST ? sdb_host_type : sdb_service_type;
+ new = STORE_OBJ(sdb_object_create(name, t, type, last_update));
+ }
if (! new) {
char errbuf[1024];
/* has_next returns false if the iterator is NULL */
while (sdb_llist_iter_has_next(iter)) {
- sdb_store_base_t *sobj = STORE_BASE(sdb_llist_iter_get_next(iter));
+ sdb_store_obj_t *sobj = STORE_OBJ(sdb_llist_iter_get_next(iter));
assert(sobj);
+ assert(sobj->type == type);
if (! sdb_strftime(time_str, sizeof(time_str),
"%F %T %z", sobj->last_update))
interval_str[sizeof(interval_str) - 1] = '\0';
sdb_strbuf_append(buf, "{\"name\": \"%s\", ", SDB_OBJ(sobj)->name);
- if (type == SDB_ATTRIBUTE) {
- char tmp[sdb_data_strlen(&SDB_ATTR(sobj)->value) + 1];
- sdb_data_format(&SDB_ATTR(sobj)->value, tmp, sizeof(tmp),
+ if (sobj->type == SDB_ATTRIBUTE) {
+ char tmp[sdb_data_strlen(&ATTR(sobj)->value) + 1];
+ sdb_data_format(&ATTR(sobj)->value, tmp, sizeof(tmp),
SDB_DOUBLE_QUOTED);
sdb_strbuf_append(buf, "\"value\": %s, \"last_update\": \"%s\", "
"\"update_interval\": \"%s\"}", tmp, time_str,
if (! name)
return -1;
- pthread_rwlock_wrlock(&obj_lock);
+ pthread_rwlock_wrlock(&host_lock);
status = store_obj(/* hostname = */ NULL,
/* stored object = */ SDB_HOST, name, last_update,
/* updated_obj = */ NULL);
- pthread_rwlock_unlock(&obj_lock);
+ pthread_rwlock_unlock(&host_lock);
return status;
} /* sdb_store_host */
_Bool
sdb_store_has_host(const char *name)
{
- sdb_store_obj_t *host;
+ sdb_host_t *host;
if (! name)
return NULL;
return host != NULL;
} /* sdb_store_has_host */
-sdb_store_base_t *
+sdb_store_obj_t *
sdb_store_get_host(const char *name)
{
- sdb_store_obj_t *host;
+ sdb_host_t *host;
if (! name)
return NULL;
return NULL;
sdb_object_ref(SDB_OBJ(host));
- return STORE_BASE(host);
+ return STORE_OBJ(host);
} /* sdb_store_get_host */
int
{
int status;
- sdb_store_base_t *updated_attr = NULL;
+ sdb_store_obj_t *updated_attr = NULL;
if ((! hostname) || (! key))
return -1;
- pthread_rwlock_wrlock(&obj_lock);
+ pthread_rwlock_wrlock(&host_lock);
status = store_obj(hostname,
/* stored object = */ SDB_ATTRIBUTE, key, last_update,
&updated_attr);
if (status >= 0) {
assert(updated_attr);
- sdb_data_free_datum(&SDB_ATTR(updated_attr)->value);
- if (sdb_data_copy(&SDB_ATTR(updated_attr)->value, value)) {
+ sdb_data_free_datum(&ATTR(updated_attr)->value);
+ if (sdb_data_copy(&ATTR(updated_attr)->value, value)) {
sdb_object_deref(SDB_OBJ(updated_attr));
status = -1;
}
}
- pthread_rwlock_unlock(&obj_lock);
+ pthread_rwlock_unlock(&host_lock);
return status;
} /* sdb_store_attribute */
if ((! hostname) || (! name))
return -1;
- pthread_rwlock_wrlock(&obj_lock);
+ pthread_rwlock_wrlock(&host_lock);
status = store_obj(hostname,
/* stored object = */ SDB_SERVICE, name, last_update,
/* updated obj = */ NULL);
- pthread_rwlock_unlock(&obj_lock);
+ pthread_rwlock_unlock(&host_lock);
return status;
} /* sdb_store_service */
int
-sdb_store_host_tojson(sdb_store_base_t *h, sdb_strbuf_t *buf, int flags)
+sdb_store_host_tojson(sdb_store_obj_t *h, sdb_strbuf_t *buf, int flags)
{
- sdb_store_obj_t *host;
+ sdb_host_t *host;
char time_str[64];
char interval_str[64];
if ((! h) || (h->type != SDB_HOST) || (! buf))
return -1;
- host = SDB_STORE_OBJ(h);
+ host = HOST(h);
if (! sdb_strftime(time_str, sizeof(time_str),
"%F %T %z", host->_last_update))
if (! buf)
return -1;
- pthread_rwlock_rdlock(&obj_lock);
+ pthread_rwlock_rdlock(&host_lock);
host_iter = sdb_llist_get_iter(host_list);
if (! host_iter) {
- pthread_rwlock_unlock(&obj_lock);
+ pthread_rwlock_unlock(&host_lock);
return -1;
}
sdb_strbuf_append(buf, "{\"hosts\":[");
while (sdb_llist_iter_has_next(host_iter)) {
- sdb_store_base_t *host = STORE_BASE(sdb_llist_iter_get_next(host_iter));
+ sdb_store_obj_t *host = STORE_OBJ(sdb_llist_iter_get_next(host_iter));
assert(host);
if (sdb_store_host_tojson(host, buf, flags))
sdb_strbuf_append(buf, "]}");
sdb_llist_iter_destroy(host_iter);
- pthread_rwlock_unlock(&obj_lock);
+ pthread_rwlock_unlock(&host_lock);
return 0;
} /* sdb_store_tojson */
sdb_llist_iter_t *host_iter;
int status = 0;
- pthread_rwlock_rdlock(&obj_lock);
+ pthread_rwlock_rdlock(&host_lock);
host_iter = sdb_llist_get_iter(host_list);
if (! host_iter)
/* has_next returns false if the iterator is NULL */
while (sdb_llist_iter_has_next(host_iter)) {
- sdb_store_base_t *host = STORE_BASE(sdb_llist_iter_get_next(host_iter));
+ sdb_store_obj_t *host = STORE_OBJ(sdb_llist_iter_get_next(host_iter));
assert(host);
if (cb(host, user_data)) {
}
sdb_llist_iter_destroy(host_iter);
- pthread_rwlock_unlock(&obj_lock);
+ pthread_rwlock_unlock(&host_lock);
return status;
} /* sdb_store_iterate */
index f57cb05cab292fa53d86b56c936d35403fc77351..489dd1ac52c6fa817df40046d5f0725b6fb45386 100644 (file)
--- a/src/core/store_lookup.c
+++ b/src/core/store_lookup.c
*/
static int
-lookup_iter(sdb_store_base_t *obj, void *user_data)
+lookup_iter(sdb_store_obj_t *obj, void *user_data)
{
lookup_iter_data_t *d = user_data;
return 0;
} /* lookup_iter */
-static sdb_store_base_t *
-attr_get(sdb_store_base_t *host, const char *name)
+static sdb_attribute_t *
+attr_get(sdb_host_t *host, const char *name)
{
sdb_llist_iter_t *iter = NULL;
- sdb_store_base_t *attr = NULL;
+ sdb_attribute_t *attr = NULL;
- assert(host->type == SDB_HOST);
-
- iter = sdb_llist_get_iter(SDB_STORE_OBJ(host)->attributes);
+ iter = sdb_llist_get_iter(host->attributes);
while (sdb_llist_iter_has_next(iter)) {
- sdb_attribute_t *a = SDB_ATTR(sdb_llist_iter_get_next(iter));
+ sdb_attribute_t *a = ATTR(sdb_llist_iter_get_next(iter));
if (strcasecmp(name, SDB_OBJ(a)->name))
continue;
- attr = STORE_BASE(a);
+
+ assert(STORE_OBJ(a)->type == SDB_ATTRIBUTE);
+ attr = a;
break;
}
sdb_llist_iter_destroy(iter);
*/
static int
-attr_cmp(sdb_store_base_t *obj, sdb_store_cond_t *cond)
+attr_cmp(sdb_host_t *host, sdb_store_cond_t *cond)
{
sdb_attribute_t *attr;
- attr = SDB_ATTR(attr_get(obj, ATTR_C(cond)->name));
+ attr = attr_get(host, ATTR_C(cond)->name);
if (! attr)
return INT_MAX;
if (attr->value.type != ATTR_C(cond)->value.type)
} /* match_string */
static int
-match_logical(sdb_store_matcher_t *m, sdb_store_base_t *obj)
+match_logical(sdb_store_matcher_t *m, sdb_host_t *host)
{
int status;
assert((m->type == MATCHER_AND) || (m->type == MATCHER_OR));
assert(OP_M(m)->left && OP_M(m)->right);
- status = sdb_store_matcher_matches(OP_M(m)->left, obj);
+ status = sdb_store_matcher_matches(OP_M(m)->left, STORE_OBJ(host));
/* lazy evaluation */
if ((! status) && (m->type == MATCHER_AND))
return status;
else if (status && (m->type == MATCHER_OR))
return status;
- return sdb_store_matcher_matches(OP_M(m)->right, obj);
+ return sdb_store_matcher_matches(OP_M(m)->right, STORE_OBJ(host));
} /* match_logical */
static int
-match_unary(sdb_store_matcher_t *m, sdb_store_base_t *obj)
+match_unary(sdb_store_matcher_t *m, sdb_host_t *host)
{
assert(m->type == MATCHER_NOT);
assert(UOP_M(m)->op);
- return !sdb_store_matcher_matches(UOP_M(m)->op, obj);
+ return !sdb_store_matcher_matches(UOP_M(m)->op, STORE_OBJ(host));
} /* match_unary */
static int
-match_name(sdb_store_matcher_t *m, sdb_store_base_t *obj)
+match_name(sdb_store_matcher_t *m, sdb_host_t *host)
{
sdb_llist_iter_t *iter = NULL;
int status = 0;
switch (NAME_M(m)->obj_type) {
case SDB_HOST:
- return match_string(&NAME_M(m)->name, obj->super.name);
+ return match_string(&NAME_M(m)->name, SDB_OBJ(host)->name);
break;
case SDB_SERVICE:
- iter = sdb_llist_get_iter(SDB_STORE_OBJ(obj)->services);
+ iter = sdb_llist_get_iter(host->services);
break;
case SDB_ATTRIBUTE:
- iter = sdb_llist_get_iter(SDB_STORE_OBJ(obj)->attributes);
+ iter = sdb_llist_get_iter(host->attributes);
break;
}
while (sdb_llist_iter_has_next(iter)) {
- sdb_store_base_t *child = STORE_BASE(sdb_llist_iter_get_next(iter));
- if (match_string(&NAME_M(m)->name, child->super.name)) {
+ sdb_object_t *child = sdb_llist_iter_get_next(iter);
+ if (match_string(&NAME_M(m)->name, child->name)) {
status = 1;
break;
}
} /* match_name */
static int
-match_attr(sdb_store_matcher_t *m, sdb_store_base_t *obj)
+match_attr(sdb_store_matcher_t *m, sdb_host_t *host)
{
sdb_attribute_t *attr;
assert(m->type == MATCHER_ATTR);
assert(ATTR_M(m)->name);
- attr = SDB_ATTR(attr_get(obj, ATTR_M(m)->name));
+ attr = attr_get(host, ATTR_M(m)->name);
if (attr) {
char buf[sdb_data_strlen(&attr->value) + 1];
if (sdb_data_format(&attr->value, buf, sizeof(buf), SDB_UNQUOTED) <= 0)
} /* match_attr */
static int
-match_lt(sdb_store_matcher_t *m, sdb_store_base_t *obj)
+match_lt(sdb_store_matcher_t *m, sdb_host_t *host)
{
int status;
assert(m->type == MATCHER_LT);
- status = COND_M(m)->cond->cmp(obj, COND_M(m)->cond);
+ status = COND_M(m)->cond->cmp(host, COND_M(m)->cond);
return (status != INT_MAX) && (status < 0);
} /* match_lt */
static int
-match_le(sdb_store_matcher_t *m, sdb_store_base_t *obj)
+match_le(sdb_store_matcher_t *m, sdb_host_t *host)
{
int status;
assert(m->type == MATCHER_LE);
- status = COND_M(m)->cond->cmp(obj, COND_M(m)->cond);
+ status = COND_M(m)->cond->cmp(host, COND_M(m)->cond);
return (status != INT_MAX) && (status <= 0);
} /* match_le */
static int
-match_eq(sdb_store_matcher_t *m, sdb_store_base_t *obj)
+match_eq(sdb_store_matcher_t *m, sdb_host_t *host)
{
int status;
assert(m->type == MATCHER_EQ);
- status = COND_M(m)->cond->cmp(obj, COND_M(m)->cond);
+ status = COND_M(m)->cond->cmp(host, COND_M(m)->cond);
return (status != INT_MAX) && (! status);
} /* match_eq */
static int
-match_ge(sdb_store_matcher_t *m, sdb_store_base_t *obj)
+match_ge(sdb_store_matcher_t *m, sdb_host_t *host)
{
int status;
assert(m->type == MATCHER_GE);
- status = COND_M(m)->cond->cmp(obj, COND_M(m)->cond);
+ status = COND_M(m)->cond->cmp(host, COND_M(m)->cond);
return (status != INT_MAX) && (status >= 0);
} /* match_ge */
static int
-match_gt(sdb_store_matcher_t *m, sdb_store_base_t *obj)
+match_gt(sdb_store_matcher_t *m, sdb_host_t *host)
{
int status;
assert(m->type == MATCHER_GT);
- status = COND_M(m)->cond->cmp(obj, COND_M(m)->cond);
+ status = COND_M(m)->cond->cmp(host, COND_M(m)->cond);
return (status != INT_MAX) && (status > 0);
} /* match_gt */
-typedef int (*matcher_cb)(sdb_store_matcher_t *, sdb_store_base_t *);
+typedef int (*matcher_cb)(sdb_store_matcher_t *, sdb_host_t *);
/* this array needs to be indexable by the matcher types;
* -> update the enum in store-private.h when updating this */
} /* sdb_store_inv_matcher */
int
-sdb_store_matcher_matches(sdb_store_matcher_t *m, sdb_store_base_t *obj)
+sdb_store_matcher_matches(sdb_store_matcher_t *m, sdb_store_obj_t *obj)
{
if (obj->type != SDB_HOST)
return 0;
if ((m->type < 0) || ((size_t)m->type >= SDB_STATIC_ARRAY_LEN(matchers)))
return 0;
- return matchers[m->type](m, obj);
+ return matchers[m->type](m, HOST(obj));
} /* sdb_store_matcher_matches */
char *
diff --git a/src/frontend/query.c b/src/frontend/query.c
index 0b582f54dce54e8481b8b6e0292b52856c48c9ec..d7476d345d48791f7cac512daca7ebfcfae49782 100644 (file)
--- a/src/frontend/query.c
+++ b/src/frontend/query.c
*/
static int
-lookup_tojson(sdb_store_base_t *obj, void *user_data)
+lookup_tojson(sdb_store_obj_t *obj, void *user_data)
{
sdb_strbuf_t *buf = user_data;
if (sdb_strbuf_len(buf) > 1)
sdb_fe_fetch(sdb_conn_t *conn, const char *name)
{
sdb_strbuf_t *buf;
- sdb_store_base_t *host;
+ sdb_store_obj_t *host;
host = sdb_store_get_host(name);
if (! host) {
index 69c18b41d0ff2cd38d432852d2b1854fee9b8ff8..3d938807f61d2c1098dae31429157946b908b2f8 100644 (file)
* and also to provide additional information to the user.
*/
enum {
- SDB_PLUGIN_INFO_NAME, /* plugin name: string */
SDB_PLUGIN_INFO_DESC, /* plugin description: string */
SDB_PLUGIN_INFO_COPYRIGHT, /* plugin copyright: string */
SDB_PLUGIN_INFO_LICENSE, /* plugin license: string */
* plugin callback functions:
* See the description of the respective register function for what arguments
* the callbacks expect.
+ *
+ * The specified name of callback functions is prepended with the plugin name
+ * before being registered with the core.
*/
typedef int (*sdb_plugin_config_cb)(oconfig_item_t *ci);
* - a negative value else
*/
int
-sdb_plugin_register_config(const char *name, sdb_plugin_config_cb callback);
+sdb_plugin_register_config(sdb_plugin_config_cb callback);
/*
* sdb_plugin_register_init:
* every plugin care about it.
*
* If non-NULL, sdb_plugin_set_ctx stores the previous context in the location
- * pointed to be 'old'.
+ * pointed to by 'old'.
*/
sdb_plugin_ctx_t
sdb_plugin_get_ctx(void);
/*
* sdb_plugin_configure:
- * Configure the plugin called 'name' (according to the registered config
- * callback) using the config tree 'ci'.
+ * Configure the plugin called 'name' using the config tree 'ci'. The plugin
+ * name is the same as the one used when loading the plugin.
*
* Returns:
* - 0 on success
index 59200815482e9d5540837dfd1fce07e19fdfd743..20656b37bdb8dbb0272db666d56dacf20fbf7583 100644 (file)
--- a/src/include/core/store.h
+++ b/src/include/core/store.h
/*
- * sdb_store_base_t represents the super-class of any object stored in the
+ * sdb_store_obj_t represents the super-class of any object stored in the
* database. It inherits from sdb_object_t and may safely be cast to a generic
* object to access its name.
*/
-struct sdb_store_base;
-typedef struct sdb_store_base sdb_store_base_t;
+struct sdb_store_obj;
+typedef struct sdb_store_obj sdb_store_obj_t;
/*
* sdb_store_clear:
_Bool
sdb_store_has_host(const char *name);
-sdb_store_base_t *
+sdb_store_obj_t *
sdb_store_get_host(const char *name);
/*
* - 0 else
*/
int
-sdb_store_matcher_matches(sdb_store_matcher_t *m, sdb_store_base_t *obj);
+sdb_store_matcher_matches(sdb_store_matcher_t *m, sdb_store_obj_t *obj);
/*
* sdb_store_matcher_tostring:
* Lookup callback. It is called for each matching object when looking up data
* in the store. The lookup aborts if the callback returns non-zero.
*/
-typedef int (*sdb_store_lookup_cb)(sdb_store_base_t *obj, void *user_data);
+typedef int (*sdb_store_lookup_cb)(sdb_store_obj_t *obj, void *user_data);
/*
* sdb_store_lookup:
* - a negative value on error
*/
int
-sdb_store_host_tojson(sdb_store_base_t *host, sdb_strbuf_t *buf, int flags);
+sdb_store_host_tojson(sdb_store_obj_t *host, sdb_strbuf_t *buf, int flags);
/*
* sdb_store_iter_cb:
* Store iterator callback. Iteration stops if the callback returns non-zero.
*/
-typedef int (*sdb_store_iter_cb)(sdb_store_base_t *obj, void *user_data);
+typedef int (*sdb_store_iter_cb)(sdb_store_obj_t *obj, void *user_data);
/*
* sdb_store_iterate:
index 26b3500e004ad51ec8e636791659278e62a2b8a9..e54ce7cd739de3face3c94ef2023a412146142e4 100644 (file)
--- a/src/plugins/cname/dns.c
+++ b/src/plugins/cname/dns.c
int
sdb_module_init(sdb_plugin_info_t *info)
{
- sdb_plugin_set_info(info, SDB_PLUGIN_INFO_NAME, "cname::dns");
sdb_plugin_set_info(info, SDB_PLUGIN_INFO_DESC,
"canonicalize hostnames by querying DNS");
sdb_plugin_set_info(info, SDB_PLUGIN_INFO_COPYRIGHT,
sdb_plugin_set_info(info, SDB_PLUGIN_INFO_VERSION, SDB_VERSION);
sdb_plugin_set_info(info, SDB_PLUGIN_INFO_PLUGIN_VERSION, SDB_VERSION);
- sdb_plugin_register_cname("cname::dns", sdb_dns_cname, NULL);
+ sdb_plugin_register_cname("main", sdb_dns_cname, NULL);
return 0;
} /* sdb_module_init */
diff --git a/src/plugins/syslog.c b/src/plugins/syslog.c
index a4875215055361dbdd950f01e74a7737654dc699..02c62414b6856cd7003c1fd677f312007826b1ce 100644 (file)
--- a/src/plugins/syslog.c
+++ b/src/plugins/syslog.c
int
sdb_module_init(sdb_plugin_info_t *info)
{
- sdb_plugin_set_info(info, SDB_PLUGIN_INFO_NAME, "syslog");
sdb_plugin_set_info(info, SDB_PLUGIN_INFO_DESC,
"log messages to the system logger");
sdb_plugin_set_info(info, SDB_PLUGIN_INFO_COPYRIGHT,
sdb_plugin_set_info(info, SDB_PLUGIN_INFO_VERSION, SDB_VERSION);
sdb_plugin_set_info(info, SDB_PLUGIN_INFO_PLUGIN_VERSION, SDB_VERSION);
- sdb_plugin_register_init("syslog", sdb_syslog_init, NULL);
- sdb_plugin_register_log("syslog", sdb_syslog_log, NULL);
- sdb_plugin_register_shutdown("syslog", sdb_syslog_shutdown, NULL);
+ sdb_plugin_register_init("main", sdb_syslog_init, NULL);
+ sdb_plugin_register_log("main", sdb_syslog_log, NULL);
+ sdb_plugin_register_shutdown("main", sdb_syslog_shutdown, NULL);
return 0;
} /* sdb_module_init */
index 992801d2be80d559b5fcf5f41e6046ac1ad6e1e0..31bfd9bae4375c8ad86507615a010acee09e0943 100644 (file)
{
sdb_plugin_ctx_t ctx = SDB_PLUGIN_CTX_INIT;
- char plugin_name[1024];
+ char plugin_name[1024];
char *name;
int i;
static int
daemon_configure_plugin(oconfig_item_t *ci)
{
+ char plugin_name[1024];
char *name;
assert(ci);
return ERR_INVALID_ARG;
}
- return sdb_plugin_configure(name, ci);
+ if (!strcasecmp(ci->key, "Backend"))
+ snprintf(plugin_name, sizeof(plugin_name), "Backend::%s", name);
+ else
+ strncpy(plugin_name, name, sizeof(plugin_name));
+ return sdb_plugin_configure(plugin_name, ci);
} /* daemon_configure_backend */
static token_parser_t token_parser_list[] = {
index 459a7e2de61f0ebda8670f22e253831402be7127..8dcb410af3492a0da588c6ba56f5cc7c3b5ddfaf 100644 (file)
exit(1);
}
- sdb_plugin_register_init("mock::init", mock_init, user_data);
- sdb_plugin_register_shutdown("mock::shutdown", mock_shutdown, user_data);
- sdb_plugin_register_collector("mock::collect", mock_collect,
+ sdb_plugin_register_init("main", mock_init, user_data);
+ sdb_plugin_register_shutdown("main", mock_shutdown, user_data);
+ sdb_plugin_register_collector("main", mock_collect,
/* interval = */ NULL, user_data);
sdb_object_deref(user_data);
int
sdb_module_init(sdb_plugin_info_t *info)
{
- sdb_plugin_set_info(info, SDB_PLUGIN_INFO_NAME, "test::integration::mock");
sdb_plugin_set_info(info, SDB_PLUGIN_INFO_DESC, "a mock plugin");
sdb_plugin_set_info(info, SDB_PLUGIN_INFO_COPYRIGHT,
"Copyright (C) 2012 Sebastian 'tokkee' Harl <sh@tokkee.org>");
sdb_plugin_set_info(info, SDB_PLUGIN_INFO_VERSION, SDB_VERSION);
sdb_plugin_set_info(info, SDB_PLUGIN_INFO_PLUGIN_VERSION, SDB_VERSION);
- sdb_plugin_register_config("test::integration::mock", mock_config);
+ sdb_plugin_register_config(mock_config);
return 0;
} /* sdb_module_init */
index 972d246065e2b598972848a11d00d5209f4ce9b1..22bd815a95f4733ef09c52f44b2996b9ca13de13 100755 (executable)
Interval 2
LoadBackend mock_plugin
-<Backend "test::integration::mock">
+<Backend "mock_plugin">
</Backend>
EOF
index 6dd7bb3fa1916a2119cc1985f9c2dc7393a3db47..1d4bf7aa267bda7a358de48ce58dd788391691aa 100644 (file)
START_TEST(test_store_match_name)
{
- sdb_store_base_t *obj;
+ sdb_store_obj_t *obj;
struct {
int type;
START_TEST(test_store_match_attr)
{
- sdb_store_base_t *obj;
+ sdb_store_obj_t *obj;
struct {
const char *attr_name;
{ "1", NULL, 1, 0 },
{ "k3", NULL, 0, 0 },
{ "k3", NULL, 1, 0 },
- { "k3", NULL, 0, 0 },
- { "k3", NULL, 1, 0 },
{ "k1", "v1", 0, 1 },
{ "k1", "v1", 1, 1 },
{ "k1", "^v1$", 1, 1 },
START_TEST(test_store_cond)
{
- sdb_store_base_t *obj;
+ sdb_store_obj_t *obj;
struct {
const char *attr;
START_TEST(test_store_match_op)
{
- sdb_store_base_t *obj;
+ sdb_store_obj_t *obj;
sdb_store_matcher_t *always = sdb_store_name_matcher(SDB_HOST, "a", 0);
sdb_store_matcher_t *never = sdb_store_name_matcher(SDB_HOST, "z", 0);
END_TEST
static int
-lookup_cb(sdb_store_base_t *obj, void *user_data)
+lookup_cb(sdb_store_obj_t *obj, void *user_data)
{
int *i = user_data;
index 07651ee602f2444cbd9f8f6dc546b9c4c41286ee..cca3968c4674df076a948d641a71d211c1257e3d 100644 (file)
--- a/t/unit/core/store_test.c
+++ b/t/unit/core/store_test.c
}
for (i = 0; i < SDB_STATIC_ARRAY_LEN(golden_hosts); ++i) {
- sdb_store_base_t *sobj1, *sobj2;
+ sdb_store_obj_t *sobj1, *sobj2;
int ref_cnt;
fail_unless(sdb_store_has_host(golden_hosts[i]),
sdb_object_deref(SDB_OBJ(sobj2));
}
for (i = 0; i < SDB_STATIC_ARRAY_LEN(unknown_hosts); ++i) {
- sdb_store_base_t *sobj;
+ sdb_store_obj_t *sobj;
fail_unless(!sdb_store_has_host(unknown_hosts[i]),
"sdb_store_has_host(%s) = TRUE; expected: FALSE",
START_TEST(test_interval)
{
- sdb_store_base_t *host;
+ sdb_store_obj_t *host;
/* 10 us interval */
sdb_store_host("host", 10);
END_TEST
static int
-iter_incr(sdb_store_base_t *obj, void *user_data)
+iter_incr(sdb_store_obj_t *obj, void *user_data)
{
intptr_t *i = user_data;
} /* iter_incr */
static int
-iter_error(sdb_store_base_t *obj, void *user_data)
+iter_error(sdb_store_obj_t *obj, void *user_data)
{
intptr_t *i = user_data;