Code

Replaced sdb_store_<type> with sdb_plugin_store_<type>.
authorSebastian Harl <sh@tokkee.org>
Thu, 21 May 2015 22:47:24 +0000 (00:47 +0200)
committerSebastian Harl <sh@tokkee.org>
Thu, 21 May 2015 22:47:24 +0000 (00:47 +0200)
That is, all store updates will now directly go through the plugin API and be
distributed to all store-writer plugins from there.

13 files changed:
src/core/store.c
src/core/store_exec.c
src/include/core/store.h
src/plugins/backend/collectd/unixsock.c
src/plugins/backend/facter.cc
src/plugins/backend/mk-livestatus.c
src/plugins/backend/puppet/store-configs.c
t/integration/mock_plugin.c
t/unit/core/store_expr_test.c
t/unit/core/store_json_test.c
t/unit/core/store_lookup_test.c
t/unit/core/store_test.c
t/unit/frontend/query_test.c

index 1396669e4b58e53dd427f76ec5119f1ab1d7d669..22e965ff1858c9891cbf862e3f1af7e91d50a6c8 100644 (file)
@@ -858,50 +858,6 @@ sdb_store_clear(void)
        sdb_avltree_clear(global_store->hosts);
 } /* sdb_store_clear */
 
        sdb_avltree_clear(global_store->hosts);
 } /* sdb_store_clear */
 
-int
-sdb_store_host(const char *name, sdb_time_t last_update)
-{
-       return sdb_plugin_store_host(name, last_update);
-} /* sdb_store_host */
-
-int
-sdb_store_attribute(const char *hostname,
-               const char *key, const sdb_data_t *value,
-               sdb_time_t last_update)
-{
-       return sdb_plugin_store_attribute(hostname, key, value, last_update);
-} /* sdb_store_attribute */
-
-int
-sdb_store_service(const char *hostname, const char *name,
-               sdb_time_t last_update)
-{
-       return sdb_plugin_store_service(hostname, name, last_update);
-} /* sdb_store_service */
-
-int
-sdb_store_service_attr(const char *hostname, const char *service,
-               const char *key, const sdb_data_t *value, sdb_time_t last_update)
-{
-       return sdb_plugin_store_service_attribute(hostname, service,
-                       key, value, last_update);
-} /* sdb_store_service_attr */
-
-int
-sdb_store_metric(const char *hostname, const char *name,
-               sdb_metric_store_t *store, sdb_time_t last_update)
-{
-       return sdb_plugin_store_metric(hostname, name, store, last_update);
-} /* sdb_store_metric */
-
-int
-sdb_store_metric_attr(const char *hostname, const char *metric,
-               const char *key, const sdb_data_t *value, sdb_time_t last_update)
-{
-       return sdb_plugin_store_metric_attribute(hostname, metric,
-                       key, value, last_update);
-} /* sdb_store_metric_attr */
-
 bool
 sdb_store_has_host(const char *name)
 {
 bool
 sdb_store_has_host(const char *name)
 {
index 6c68dc5fd1d4b9fce1486dea01ff2e44d97e96ab..436b36e4aeb25f1784257eeef5a818100e805aca 100644 (file)
@@ -26,6 +26,7 @@
  */
 
 #include "core/object.h"
  */
 
 #include "core/object.h"
+#include "core/plugin.h"
 #include "core/store-private.h"
 #include "frontend/connection.h"
 #include "parser/ast.h"
 #include "core/store-private.h"
 #include "frontend/connection.h"
 #include "parser/ast.h"
@@ -227,19 +228,19 @@ exec_store(sdb_strbuf_t *buf, sdb_strbuf_t *errbuf, sdb_ast_store_t *st)
        switch (st->obj_type) {
        case SDB_HOST:
                strncpy(name, st->name, sizeof(name));
        switch (st->obj_type) {
        case SDB_HOST:
                strncpy(name, st->name, sizeof(name));
-               status = sdb_store_host(st->name, st->last_update);
+               status = sdb_plugin_store_host(st->name, st->last_update);
                break;
 
        case SDB_SERVICE:
                snprintf(name, sizeof(name), "%s.%s", st->hostname, st->name);
                break;
 
        case SDB_SERVICE:
                snprintf(name, sizeof(name), "%s.%s", st->hostname, st->name);
-               status = sdb_store_service(st->hostname, st->name, st->last_update);
+               status = sdb_plugin_store_service(st->hostname, st->name, st->last_update);
                break;
 
        case SDB_METRIC:
                snprintf(name, sizeof(name), "%s.%s", st->hostname, st->name);
                metric_store.type = st->store_type;
                metric_store.id = st->store_id;
                break;
 
        case SDB_METRIC:
                snprintf(name, sizeof(name), "%s.%s", st->hostname, st->name);
                metric_store.type = st->store_type;
                metric_store.id = st->store_id;
-               status = sdb_store_metric(st->hostname, st->name,
+               status = sdb_plugin_store_metric(st->hostname, st->name,
                                &metric_store, st->last_update);
                break;
 
                                &metric_store, st->last_update);
                break;
 
@@ -255,17 +256,17 @@ exec_store(sdb_strbuf_t *buf, sdb_strbuf_t *errbuf, sdb_ast_store_t *st)
                switch (st->parent_type) {
                case 0:
                        type |= SDB_HOST;
                switch (st->parent_type) {
                case 0:
                        type |= SDB_HOST;
-                       status = sdb_store_attribute(st->hostname,
+                       status = sdb_plugin_store_attribute(st->hostname,
                                        st->name, &st->value, st->last_update);
                        break;
 
                case SDB_SERVICE:
                                        st->name, &st->value, st->last_update);
                        break;
 
                case SDB_SERVICE:
-                       status = sdb_store_service_attr(st->hostname, st->parent,
+                       status = sdb_plugin_store_service_attribute(st->hostname, st->parent,
                                        st->name, &st->value, st->last_update);
                        break;
 
                case SDB_METRIC:
                                        st->name, &st->value, st->last_update);
                        break;
 
                case SDB_METRIC:
-                       status = sdb_store_metric_attr(st->hostname, st->parent,
+                       status = sdb_plugin_store_metric_attribute(st->hostname, st->parent,
                                        st->name, &st->value, st->last_update);
                        break;
 
                                        st->name, &st->value, st->last_update);
                        break;
 
index 4a0960c1cbe0055f77c1c1c6d64a9f32aa566b82..15f435fefdc6136a83fdb2e53a004a5cac82e8a9 100644 (file)
@@ -150,21 +150,77 @@ typedef struct sdb_store_json_formatter sdb_store_json_formatter_t;
 
 /*
  * A store writer describes the interface for plugins implementing a store.
 
 /*
  * A store writer describes the interface for plugins implementing a store.
+ *
+ * Any of the call-back functions shall return:
+ *  - 0 on success
+ *  - a positive value if the new entry is older than the currently stored
+ *    entry (in this case, no update will happen)
+ *  - a negative value on error
  */
 typedef struct {
  */
 typedef struct {
+       /*
+        * store_host:
+        * Add/update a host in the store. If the host, identified by its
+        * canonicalized name, already exists, it will be updated according to the
+        * specified name and timestamp. Else, a new entry will be created in the
+        * store.
+        */
        int (*store_host)(const char *name, sdb_time_t last_update,
                        sdb_object_t *user_data);
        int (*store_host)(const char *name, sdb_time_t last_update,
                        sdb_object_t *user_data);
+
+       /*
+        * store_service:
+        * Add/update a service in the store. If the service, identified by its
+        * name, already exists for the specified host, it will be updated
+        * according to the specified name and timestamp. If the referenced host
+        * does not exist, an error will be reported. Else, a new entry will be
+        * created in the store.
+        */
        int (*store_service)(const char *hostname, const char *name,
                        sdb_time_t last_update, sdb_object_t *user_data);
        int (*store_service)(const char *hostname, const char *name,
                        sdb_time_t last_update, sdb_object_t *user_data);
+
+       /*
+        * store_metric:
+        * Add/update a metric in the store. If the metric, identified by its
+        * name, already exists for the specified host, it will be updated
+        * according to the specified attributes. If the referenced host does not
+        * exist, an error will be reported. Else, a new entry will be created in
+        * the store.
+        */
        int (*store_metric)(const char *hostname, const char *name,
                        sdb_metric_store_t *store, sdb_time_t last_update,
                        sdb_object_t *user_data);
        int (*store_metric)(const char *hostname, const char *name,
                        sdb_metric_store_t *store, sdb_time_t last_update,
                        sdb_object_t *user_data);
+
+       /*
+        * store_attribute:
+        * Add/update a host's attribute in the store. If the attribute,
+        * identified by its key, already exists for the specified host, it will
+        * be updated to the specified values. If the referenced host does not
+        * exist, an error will be reported. Else, a new entry will be created in
+        * the store.
+        */
        int (*store_attribute)(const char *hostname,
                        const char *key, const sdb_data_t *value, sdb_time_t last_update,
                        sdb_object_t *user_data);
        int (*store_attribute)(const char *hostname,
                        const char *key, const sdb_data_t *value, sdb_time_t last_update,
                        sdb_object_t *user_data);
+
+       /*
+        * store_service_attr:
+        * Add/update a service's attribute in the store. If the attribute,
+        * identified by its key, already exists for the specified service, it
+        * will be updated to the specified value. If the references service (for
+        * the specified host) does not exist, an error will be reported.
+        */
        int (*store_service_attr)(const char *hostname, const char *service,
                        const char *key, const sdb_data_t *value, sdb_time_t last_update,
                        sdb_object_t *user_data);
        int (*store_service_attr)(const char *hostname, const char *service,
                        const char *key, const sdb_data_t *value, sdb_time_t last_update,
                        sdb_object_t *user_data);
+
+       /*
+        * store_metric_attr:
+        * Add/update a metric's attribute in the store. If the attribute,
+        * identified by its key, already exists for the specified metric, it will
+        * be updated to the specified value. If the references metric (for the
+        * specified host) does not exist, an error will be reported.
+        */
        int (*store_metric_attr)(const char *hostname, const char *metric,
                        const char *key, const sdb_data_t *value, sdb_time_t last_update,
                        sdb_object_t *user_data);
        int (*store_metric_attr)(const char *hostname, const char *metric,
                        const char *key, const sdb_data_t *value, sdb_time_t last_update,
                        sdb_object_t *user_data);
@@ -189,23 +245,6 @@ sdb_store_init(void);
 void
 sdb_store_clear(void);
 
 void
 sdb_store_clear(void);
 
-/*
- * sdb_store_host:
- * Add/update a host in the store. If the host, identified by its
- * canonicalized name, already exists, it will be updated according to the
- * specified name and timestamp. Else, a new entry will be created in the
- * store. Any memory required for storing the entry will be allocated an
- * managed by the store itself.
- *
- * Returns:
- *  - 0 on success
- *  - a positive value if the new entry is older than the currently stored
- *    entry (in this case, no update will happen)
- *  - a negative value on error
- */
-int
-sdb_store_host(const char *name, sdb_time_t last_update);
-
 /*
  * sdb_store_has_host:
  * sdb_store_get_host:
 /*
  * sdb_store_has_host:
  * sdb_store_get_host:
@@ -220,102 +259,6 @@ sdb_store_has_host(const char *name);
 sdb_store_obj_t *
 sdb_store_get_host(const char *name);
 
 sdb_store_obj_t *
 sdb_store_get_host(const char *name);
 
-/*
- * sdb_store_attribute:
- * Add/update a host's attribute in the store. If the attribute, identified by
- * its key, already exists for the specified host, it will be updated to the
- * specified values. If the referenced host does not exist, an error will be
- * reported. Else, a new entry will be created in the store. Any memory
- * required for storing the entry will be allocated and managed by the store
- * itself.
- *
- * Returns:
- *  - 0 on success
- *  - a positive value if the new entry is older than the currently stored
- *    entry (in this case, no update will happen)
- *  - a negative value on error
- */
-int
-sdb_store_attribute(const char *hostname,
-               const char *key, const sdb_data_t *value,
-               sdb_time_t last_update);
-
-/*
- * sdb_store_service:
- * Add/update a service in the store. If the service, identified by its name,
- * already exists for the specified host, it will be updated according to the
- * specified 'service' object. If the referenced host does not exist, an error
- * will be reported. Else, a new entry will be created in the store. Any
- * memory required for storing the entry will be allocated an managed by the
- * store itself.
- *
- * Returns:
- *  - 0 on success
- *  - a positive value if the new entry is older than the currently stored
- *    entry (in this case, no update will happen)
- *  - a negative value on error
- */
-int
-sdb_store_service(const char *hostname, const char *name,
-               sdb_time_t last_update);
-
-/*
- * sdb_store_service_attr:
- * Add/update a service's attribute in the store. If the attribute, identified
- * by its key, already exists for the specified service, it will be updated to
- * the specified value. If the references service (for the specified host)
- * does not exist, an error will be reported. Any memory required for storing
- * the entry will be allocated and managed by the store itself.
- *
- * Returns:
- *  - 0 on success
- *  - a positive value if the new entry is older than the currently stored
- *    entry (in this case, no update will happen)
- *  - a negative value on error
- */
-int
-sdb_store_service_attr(const char *hostname, const char *service,
-               const char *key, const sdb_data_t *value, sdb_time_t last_update);
-
-/*
- * sdb_store_metric:
- * Add/update a metric in the store. If the metric, identified by its name,
- * already exists for the specified host, it will be updated according to the
- * specified 'metric' object. If the referenced host does not exist, an error
- * will be reported. Else, a new entry will be created in the store. Any
- * memory required for storing the entry will be allocated an managed by the
- * store itself.
- *
- * If specified, the metric store describes where to access the metric's data.
- *
- * Returns:
- *  - 0 on success
- *  - a positive value if the new entry is older than the currently stored
- *    entry (in this case, no update will happen)
- *  - a negative value on error
- */
-int
-sdb_store_metric(const char *hostname, const char *name,
-               sdb_metric_store_t *store, sdb_time_t last_update);
-
-/*
- * sdb_store_metric_attr:
- * Add/update a metric's attribute in the store. If the attribute, identified
- * by its key, already exists for the specified metric, it will be updated to
- * the specified value. If the references metric (for the specified host)
- * does not exist, an error will be reported. Any memory required for storing
- * the entry will be allocated and managed by the store itself.
- *
- * Returns:
- *  - 0 on success
- *  - a positive value if the new entry is older than the currently stored
- *    entry (in this case, no update will happen)
- *  - a negative value on error
- */
-int
-sdb_store_metric_attr(const char *hostname, const char *metric,
-               const char *key, const sdb_data_t *value, sdb_time_t last_update);
-
 /*
  * sdb_store_fetch_timeseries:
  * Fetch the time-series described by the specified host's metric and
 /*
  * sdb_store_fetch_timeseries:
  * Fetch the time-series described by the specified host's metric and
index 8af5327624e135c15796b5e86c1bc6a7878cbedd..65b05845814ec6e66601cda58bc829a279956f37 100644 (file)
@@ -125,7 +125,7 @@ store_host(state_t *state, const char *hostname, sdb_time_t last_update)
                return -1;
        }
 
                return -1;
        }
 
-       status = sdb_store_host(hostname, last_update);
+       status = sdb_plugin_store_host(hostname, last_update);
 
        if (status < 0) {
                sdb_log(SDB_LOG_ERR, "collectd::unixsock backend: Failed to "
 
        if (status < 0) {
                sdb_log(SDB_LOG_ERR, "collectd::unixsock backend: Failed to "
@@ -161,10 +161,10 @@ add_metrics(const char *hostname, char *plugin, char *type,
        if (ud->ts_base) {
                snprintf(metric_id, sizeof(metric_id), "%s/%s/%s.rrd",
                                ud->ts_base, hostname, name);
        if (ud->ts_base) {
                snprintf(metric_id, sizeof(metric_id), "%s/%s/%s.rrd",
                                ud->ts_base, hostname, name);
-               status = sdb_store_metric(hostname, name, &store, last_update);
+               status = sdb_plugin_store_metric(hostname, name, &store, last_update);
        }
        else
        }
        else
-               status = sdb_store_metric(hostname, name, NULL, last_update);
+               status = sdb_plugin_store_metric(hostname, name, NULL, last_update);
        if (status < 0) {
                sdb_log(SDB_LOG_ERR, "collectd::unixsock backend: Failed to "
                                "store/update metric '%s/%s'.", hostname, name);
        if (status < 0) {
                sdb_log(SDB_LOG_ERR, "collectd::unixsock backend: Failed to "
                                "store/update metric '%s/%s'.", hostname, name);
@@ -177,7 +177,7 @@ add_metrics(const char *hostname, char *plugin, char *type,
                ++plugin_instance;
 
                data.data.string = plugin_instance;
                ++plugin_instance;
 
                data.data.string = plugin_instance;
-               sdb_store_metric_attr(hostname, name,
+               sdb_plugin_store_metric_attribute(hostname, name,
                                "plugin_instance", &data, last_update);
        }
 
                                "plugin_instance", &data, last_update);
        }
 
@@ -187,14 +187,14 @@ add_metrics(const char *hostname, char *plugin, char *type,
                ++type_instance;
 
                data.data.string = type_instance;
                ++type_instance;
 
                data.data.string = type_instance;
-               sdb_store_metric_attr(hostname, name,
+               sdb_plugin_store_metric_attribute(hostname, name,
                                "type_instance", &data, last_update);
        }
 
        data.data.string = plugin;
                                "type_instance", &data, last_update);
        }
 
        data.data.string = plugin;
-       sdb_store_metric_attr(hostname, name, "plugin", &data, last_update);
+       sdb_plugin_store_metric_attribute(hostname, name, "plugin", &data, last_update);
        data.data.string = type;
        data.data.string = type;
-       sdb_store_metric_attr(hostname, name, "type", &data, last_update);
+       sdb_plugin_store_metric_attribute(hostname, name, "type", &data, last_update);
        return 0;
 } /* add_metrics */
 
        return 0;
 } /* add_metrics */
 
index 98f7f57f18b30c23f0c56e889aa4e924900fcf75..e5561868f9d52647a8a93a298863bbf6a1454981 100644 (file)
@@ -57,7 +57,7 @@ fact_iter(std::string const &k, facter::facts::value const *v)
                return true;
 
        sdb_data_t value = { SDB_TYPE_STRING, { .string = str } };
                return true;
 
        sdb_data_t value = { SDB_TYPE_STRING, { .string = str } };
-       sdb_store_attribute(hostname, k.c_str(), &value, now);
+       sdb_plugin_store_attribute(hostname, k.c_str(), &value, now);
        return true;
 } /* fact_iter */
 
        return true;
 } /* fact_iter */
 
@@ -83,7 +83,7 @@ extern "C" {
                std::string s = ss.str();
                hostname = s.c_str();
 
                std::string s = ss.str();
                hostname = s.c_str();
 
-               sdb_store_host(hostname, now);
+               sdb_plugin_store_host(hostname, now);
                facts.each(fact_iter);
                sdb_log(SDB_LOG_DEBUG, "facter backend: Processed %zu facts "
                                "for host '%s'", facts.size(), hostname);
                facts.each(fact_iter);
                sdb_log(SDB_LOG_DEBUG, "facter backend: Processed %zu facts "
                                "for host '%s'", facts.size(), hostname);
index 7d9e320bc79c1f05524608c4d617e8ee786d6cd6..d1126db92a2e02f14835056f1d994b6c3fa2e8f5 100644 (file)
@@ -68,7 +68,7 @@ sdb_livestatus_get_host(sdb_unixsock_client_t __attribute__((unused)) *client,
        hostname  = data[0].data.string;
        timestamp = data[1].data.datetime;
 
        hostname  = data[0].data.string;
        timestamp = data[1].data.datetime;
 
-       status = sdb_store_host(hostname, timestamp);
+       status = sdb_plugin_store_host(hostname, timestamp);
 
        if (status < 0) {
                sdb_log(SDB_LOG_ERR, "MK Livestatus backend: Failed to "
 
        if (status < 0) {
                sdb_log(SDB_LOG_ERR, "MK Livestatus backend: Failed to "
@@ -104,7 +104,7 @@ sdb_livestatus_get_svc(sdb_unixsock_client_t __attribute__((unused)) *client,
        svcname   = data[1].data.string;
        timestamp = data[2].data.datetime;
 
        svcname   = data[1].data.string;
        timestamp = data[2].data.datetime;
 
-       status = sdb_store_service(hostname, svcname, timestamp);
+       status = sdb_plugin_store_service(hostname, svcname, timestamp);
 
        if (status < 0) {
                sdb_log(SDB_LOG_ERR, "MK Livestatus backend: Failed to "
 
        if (status < 0) {
                sdb_log(SDB_LOG_ERR, "MK Livestatus backend: Failed to "
index 95dd5499eea60ed090c5db712a04e732b4d370f5..800e81bdb0e4c2b2192acdd21ad62b8addd4f37b 100644 (file)
@@ -62,7 +62,7 @@ sdb_puppet_stcfg_get_hosts(sdb_dbi_client_t __attribute__((unused)) *client,
        hostname = data[0].data.string;
        timestamp = data[1].data.datetime;
 
        hostname = data[0].data.string;
        timestamp = data[1].data.datetime;
 
-       status = sdb_store_host(hostname, timestamp);
+       status = sdb_plugin_store_host(hostname, timestamp);
 
        if (status < 0) {
                sdb_log(SDB_LOG_ERR, "puppet::store-configs backend: Failed to "
 
        if (status < 0) {
                sdb_log(SDB_LOG_ERR, "puppet::store-configs backend: Failed to "
@@ -100,7 +100,7 @@ sdb_puppet_stcfg_get_attrs(sdb_dbi_client_t __attribute__((unused)) *client,
        value.data.string = data[2].data.string;
        last_update = data[3].data.datetime;
 
        value.data.string = data[2].data.string;
        last_update = data[3].data.datetime;
 
-       status = sdb_store_attribute(hostname, key, &value, last_update);
+       status = sdb_plugin_store_attribute(hostname, key, &value, last_update);
 
        if (status < 0) {
                sdb_log(SDB_LOG_ERR, "puppet::store-configs backend: Failed to "
 
        if (status < 0) {
                sdb_log(SDB_LOG_ERR, "puppet::store-configs backend: Failed to "
index 5a9718de9d7c0d2698e977a8033096673a8027ea..87c86a84f08d4f896ca50d79cc6c38d7879b8367 100644 (file)
@@ -153,14 +153,14 @@ mock_collect(sdb_object_t *user_data)
        }
 
        for (i = 0; i < SDB_STATIC_ARRAY_LEN(hostnames); ++i) {
        }
 
        for (i = 0; i < SDB_STATIC_ARRAY_LEN(hostnames); ++i) {
-               if ((check = sdb_store_host(hostnames[i], sdb_gettime()))) {
+               if ((check = sdb_plugin_store_host(hostnames[i], sdb_gettime()))) {
                        sdb_log(SDB_LOG_ERR, "mock::plugin: Failed to store host: "
                                        "status %d", check);
                        exit(1);
                }
        }
        for (i = 0; i < SDB_STATIC_ARRAY_LEN(metrics); ++i) {
                        sdb_log(SDB_LOG_ERR, "mock::plugin: Failed to store host: "
                                        "status %d", check);
                        exit(1);
                }
        }
        for (i = 0; i < SDB_STATIC_ARRAY_LEN(metrics); ++i) {
-               if ((check = sdb_store_metric(metrics[i].hostname,
+               if ((check = sdb_plugin_store_metric(metrics[i].hostname,
                                                metrics[i].metric, &metrics[i].store,
                                                sdb_gettime()))) {
                        sdb_log(SDB_LOG_ERR, "mock::plugin: Failed to store metric: "
                                                metrics[i].metric, &metrics[i].store,
                                                sdb_gettime()))) {
                        sdb_log(SDB_LOG_ERR, "mock::plugin: Failed to store metric: "
@@ -169,7 +169,7 @@ mock_collect(sdb_object_t *user_data)
                }
        }
        for (i = 0; i < SDB_STATIC_ARRAY_LEN(services); ++i) {
                }
        }
        for (i = 0; i < SDB_STATIC_ARRAY_LEN(services); ++i) {
-               if ((check = sdb_store_service(services[i].hostname,
+               if ((check = sdb_plugin_store_service(services[i].hostname,
                                                services[i].service, sdb_gettime()))) {
                        sdb_log(SDB_LOG_ERR, "mock::plugin: Failed to store service: "
                                        "status %d", check);
                                                services[i].service, sdb_gettime()))) {
                        sdb_log(SDB_LOG_ERR, "mock::plugin: Failed to store service: "
                                        "status %d", check);
@@ -180,7 +180,7 @@ mock_collect(sdb_object_t *user_data)
                sdb_data_t datum = { SDB_TYPE_STRING, { .string = NULL } };
                datum.data.string = strdup(attributes[i].value);
 
                sdb_data_t datum = { SDB_TYPE_STRING, { .string = NULL } };
                datum.data.string = strdup(attributes[i].value);
 
-               if ((check = sdb_store_attribute(attributes[i].hostname,
+               if ((check = sdb_plugin_store_attribute(attributes[i].hostname,
                                                attributes[i].name, &datum, sdb_gettime()))) {
                        sdb_log(SDB_LOG_ERR, "mock::plugin: Failed to store attribute: "
                                        "status %d", check);
                                                attributes[i].name, &datum, sdb_gettime()))) {
                        sdb_log(SDB_LOG_ERR, "mock::plugin: Failed to store attribute: "
                                        "status %d", check);
index b15809a589bc890dd36ff5c8809bdf71b75cfd84..153e52f1c84bb393bcd560541485ee71e5af8044 100644 (file)
@@ -29,6 +29,7 @@
 #      include "config.h"
 #endif
 
 #      include "config.h"
 #endif
 
+#include "core/plugin.h"
 #include "core/store.h"
 #include "core/store-private.h"
 #include "parser/parser.h"
 #include "core/store.h"
 #include "core/store-private.h"
 #include "parser/parser.h"
@@ -95,37 +96,37 @@ populate(void)
        sdb_store_init();
 
        for (i = 0; i < SDB_STATIC_ARRAY_LEN(hosts); ++i) {
        sdb_store_init();
 
        for (i = 0; i < SDB_STATIC_ARRAY_LEN(hosts); ++i) {
-               int status = sdb_store_host(hosts[i], 1);
+               int status = sdb_plugin_store_host(hosts[i], 1);
                ck_assert(status == 0);
        }
 
        for (i = 0; i < SDB_STATIC_ARRAY_LEN(metrics); ++i) {
                ck_assert(status == 0);
        }
 
        for (i = 0; i < SDB_STATIC_ARRAY_LEN(metrics); ++i) {
-               int status = sdb_store_metric(metrics[i].host,
+               int status = sdb_plugin_store_metric(metrics[i].host,
                                metrics[i].metric, /* store */ NULL, 1);
                ck_assert(status == 0);
        }
 
        for (i = 0; i < SDB_STATIC_ARRAY_LEN(services); ++i) {
                                metrics[i].metric, /* store */ NULL, 1);
                ck_assert(status == 0);
        }
 
        for (i = 0; i < SDB_STATIC_ARRAY_LEN(services); ++i) {
-               int status = sdb_store_service(services[i].host,
+               int status = sdb_plugin_store_service(services[i].host,
                                services[i].service, 1);
                ck_assert(status == 0);
        }
 
        for (i = 0; i < SDB_STATIC_ARRAY_LEN(attrs); ++i) {
                                services[i].service, 1);
                ck_assert(status == 0);
        }
 
        for (i = 0; i < SDB_STATIC_ARRAY_LEN(attrs); ++i) {
-               int status = sdb_store_attribute(attrs[i].host,
+               int status = sdb_plugin_store_attribute(attrs[i].host,
                                attrs[i].name, &attrs[i].value, 1);
                ck_assert(status == 0);
        }
 
        for (i = 0; i < SDB_STATIC_ARRAY_LEN(svc_attrs); ++i) {
                                attrs[i].name, &attrs[i].value, 1);
                ck_assert(status == 0);
        }
 
        for (i = 0; i < SDB_STATIC_ARRAY_LEN(svc_attrs); ++i) {
-               int status = sdb_store_service_attr(svc_attrs[i].host,
+               int status = sdb_plugin_store_service_attribute(svc_attrs[i].host,
                                svc_attrs[i].service, svc_attrs[i].name,
                                &svc_attrs[i].value, 1);
                ck_assert(status == 0);
        }
 
        for (i = 0; i < SDB_STATIC_ARRAY_LEN(metric_attrs); ++i) {
                                svc_attrs[i].service, svc_attrs[i].name,
                                &svc_attrs[i].value, 1);
                ck_assert(status == 0);
        }
 
        for (i = 0; i < SDB_STATIC_ARRAY_LEN(metric_attrs); ++i) {
-               int status = sdb_store_metric_attr(metric_attrs[i].host,
+               int status = sdb_plugin_store_metric_attribute(metric_attrs[i].host,
                                metric_attrs[i].metric, metric_attrs[i].name,
                                &metric_attrs[i].value, 1);
                ck_assert(status == 0);
                                metric_attrs[i].metric, metric_attrs[i].name,
                                &metric_attrs[i].value, 1);
                ck_assert(status == 0);
index ebb2daf1d22ec7cee81e267d97ca476612b5abe9..baecf8053d1986576ee2cd4b42e7bcad3e010248 100644 (file)
@@ -29,6 +29,7 @@
 #      include "config.h"
 #endif
 
 #      include "config.h"
 #endif
 
+#include "core/plugin.h"
 #include "core/store.h"
 #include "testutils.h"
 
 #include "core/store.h"
 #include "testutils.h"
 
@@ -46,41 +47,45 @@ populate(void)
 
        sdb_store_init();
 
 
        sdb_store_init();
 
-       sdb_store_host("h1", 1 * SDB_INTERVAL_SECOND);
-       sdb_store_host("h2", 3 * SDB_INTERVAL_SECOND);
+       sdb_plugin_store_host("h1", 1 * SDB_INTERVAL_SECOND);
+       sdb_plugin_store_host("h2", 3 * SDB_INTERVAL_SECOND);
 
        datum.type = SDB_TYPE_STRING;
        datum.data.string = "v1";
 
        datum.type = SDB_TYPE_STRING;
        datum.data.string = "v1";
-       sdb_store_attribute("h1", "k1", &datum, 1 * SDB_INTERVAL_SECOND);
+       sdb_plugin_store_attribute("h1", "k1", &datum, 1 * SDB_INTERVAL_SECOND);
        datum.data.string = "v2";
        datum.data.string = "v2";
-       sdb_store_attribute("h1", "k2", &datum, 2 * SDB_INTERVAL_SECOND);
+       sdb_plugin_store_attribute("h1", "k2", &datum, 2 * SDB_INTERVAL_SECOND);
        datum.data.string = "v3";
        datum.data.string = "v3";
-       sdb_store_attribute("h1", "k3", &datum, 2 * SDB_INTERVAL_SECOND);
+       sdb_plugin_store_attribute("h1", "k3", &datum, 2 * SDB_INTERVAL_SECOND);
 
        /* make sure that older updates don't overwrite existing values */
        datum.data.string = "fail";
 
        /* make sure that older updates don't overwrite existing values */
        datum.data.string = "fail";
-       sdb_store_attribute("h1", "k2", &datum, 1 * SDB_INTERVAL_SECOND);
-       sdb_store_attribute("h1", "k3", &datum, 2 * SDB_INTERVAL_SECOND);
+       sdb_plugin_store_attribute("h1", "k2", &datum, 1 * SDB_INTERVAL_SECOND);
+       sdb_plugin_store_attribute("h1", "k3", &datum, 2 * SDB_INTERVAL_SECOND);
 
 
-       sdb_store_metric("h1", "m1", /* store */ NULL, 2 * SDB_INTERVAL_SECOND);
-       sdb_store_metric("h1", "m2", /* store */ NULL, 1 * SDB_INTERVAL_SECOND);
-       sdb_store_metric("h2", "m1", /* store */ NULL, 1 * SDB_INTERVAL_SECOND);
+       sdb_plugin_store_metric("h1", "m1", /* store */ NULL, 2 * SDB_INTERVAL_SECOND);
+       sdb_plugin_store_metric("h1", "m2", /* store */ NULL, 1 * SDB_INTERVAL_SECOND);
+       sdb_plugin_store_metric("h2", "m1", /* store */ NULL, 1 * SDB_INTERVAL_SECOND);
 
 
-       sdb_store_service("h2", "s1", 1 * SDB_INTERVAL_SECOND);
-       sdb_store_service("h2", "s2", 2 * SDB_INTERVAL_SECOND);
+       sdb_plugin_store_service("h2", "s1", 1 * SDB_INTERVAL_SECOND);
+       sdb_plugin_store_service("h2", "s2", 2 * SDB_INTERVAL_SECOND);
 
        datum.type = SDB_TYPE_INTEGER;
        datum.data.integer = 42;
 
        datum.type = SDB_TYPE_INTEGER;
        datum.data.integer = 42;
-       sdb_store_metric_attr("h1", "m1", "k3", &datum, 2 * SDB_INTERVAL_SECOND);
+       sdb_plugin_store_metric_attribute("h1", "m1", "k3",
+                       &datum, 2 * SDB_INTERVAL_SECOND);
 
        datum.data.integer = 123;
 
        datum.data.integer = 123;
-       sdb_store_service_attr("h2", "s2", "k1", &datum, 2 * SDB_INTERVAL_SECOND);
+       sdb_plugin_store_service_attribute("h2", "s2", "k1",
+                       &datum, 2 * SDB_INTERVAL_SECOND);
        datum.data.integer = 4711;
        datum.data.integer = 4711;
-       sdb_store_service_attr("h2", "s2", "k2", &datum, 1 * SDB_INTERVAL_SECOND);
+       sdb_plugin_store_service_attribute("h2", "s2", "k2",
+                       &datum, 1 * SDB_INTERVAL_SECOND);
 
        /* don't overwrite k1 */
        datum.data.integer = 666;
 
        /* don't overwrite k1 */
        datum.data.integer = 666;
-       sdb_store_service_attr("h2", "s2", "k1", &datum, 2 * SDB_INTERVAL_SECOND);
+       sdb_plugin_store_service_attribute("h2", "s2", "k1",
+                       &datum, 2 * SDB_INTERVAL_SECOND);
 } /* populate */
 
 static int
 } /* populate */
 
 static int
index 913e6b78a0905bb803a5d7073e3cc27c4a457904..49f2268a24d0758dc5165934bb5c75d7908a9947 100644 (file)
@@ -29,6 +29,7 @@
 #      include "config.h"
 #endif
 
 #      include "config.h"
 #endif
 
+#include "core/plugin.h"
 #include "core/store.h"
 #include "core/store-private.h"
 #include "parser/parser.h"
 #include "core/store.h"
 #include "core/store-private.h"
 #include "parser/parser.h"
@@ -76,33 +77,33 @@ populate(void)
        sdb_store_init();
 
        for (i = 0; i < SDB_STATIC_ARRAY_LEN(hosts); ++i) {
        sdb_store_init();
 
        for (i = 0; i < SDB_STATIC_ARRAY_LEN(hosts); ++i) {
-               int status = sdb_store_host(hosts[i], 1);
+               int status = sdb_plugin_store_host(hosts[i], 1);
                fail_unless(status == 0,
                fail_unless(status == 0,
-                               "sdb_store_host(%s, 1) = %d; expected: 0",
+                               "sdb_plugin_store_host(%s, 1) = %d; expected: 0",
                                hosts[i], status);
        }
 
        for (i = 0; i < SDB_STATIC_ARRAY_LEN(metrics); ++i) {
                                hosts[i], status);
        }
 
        for (i = 0; i < SDB_STATIC_ARRAY_LEN(metrics); ++i) {
-               int status = sdb_store_metric(metrics[i].host,
+               int status = sdb_plugin_store_metric(metrics[i].host,
                                metrics[i].metric, /* store */ NULL, 1);
                fail_unless(status == 0,
                                metrics[i].metric, /* store */ NULL, 1);
                fail_unless(status == 0,
-                               "sdb_store_metric(%s, %s, NULL, 1) = %d; expected: 0",
+                               "sdb_plugin_store_metric(%s, %s, NULL, 1) = %d; expected: 0",
                                metrics[i].host, metrics[i].metric, status);
        }
 
        for (i = 0; i < SDB_STATIC_ARRAY_LEN(services); ++i) {
                                metrics[i].host, metrics[i].metric, status);
        }
 
        for (i = 0; i < SDB_STATIC_ARRAY_LEN(services); ++i) {
-               int status = sdb_store_service(services[i].host,
+               int status = sdb_plugin_store_service(services[i].host,
                                services[i].service, 1);
                fail_unless(status == 0,
                                services[i].service, 1);
                fail_unless(status == 0,
-                               "sdb_store_service(%s, %s, 1) = %d; expected: 0",
+                               "sdb_plugin_store_service(%s, %s, 1) = %d; expected: 0",
                                services[i].host, services[i].service, status);
        }
 
        for (i = 0; i < SDB_STATIC_ARRAY_LEN(attrs); ++i) {
                                services[i].host, services[i].service, status);
        }
 
        for (i = 0; i < SDB_STATIC_ARRAY_LEN(attrs); ++i) {
-               int status = sdb_store_attribute(attrs[i].host,
+               int status = sdb_plugin_store_attribute(attrs[i].host,
                                attrs[i].name, &attrs[i].value, 1);
                fail_unless(status == 0,
                                attrs[i].name, &attrs[i].value, 1);
                fail_unless(status == 0,
-                               "sdb_store_attribute(%s, %s, <val>, 1) = %d; expected: 0",
+                               "sdb_plugin_store_attribute(%s, %s, <val>, 1) = %d; expected: 0",
                                attrs[i].host, attrs[i].name, status);
        }
 } /* populate */
                                attrs[i].host, attrs[i].name, status);
        }
 } /* populate */
index 8308f3334f39d7c2c8cd71362f5903eab399c412..ed6f5d9b149944e31c4412c4c6103dd9a9f25320 100644 (file)
@@ -29,6 +29,7 @@
 #      include "config.h"
 #endif
 
 #      include "config.h"
 #endif
 
+#include "core/plugin.h"
 #include "core/store.h"
 #include "core/store-private.h"
 #include "testutils.h"
 #include "core/store.h"
 #include "core/store-private.h"
 #include "testutils.h"
@@ -48,43 +49,41 @@ populate(void)
 {
        sdb_data_t datum;
 
 {
        sdb_data_t datum;
 
-       sdb_store_init();
-
-       sdb_store_host("h1", 1);
-       sdb_store_host("h2", 3);
+       sdb_plugin_store_host("h1", 1);
+       sdb_plugin_store_host("h2", 3);
 
        datum.type = SDB_TYPE_STRING;
        datum.data.string = "v1";
 
        datum.type = SDB_TYPE_STRING;
        datum.data.string = "v1";
-       sdb_store_attribute("h1", "k1", &datum, 1);
+       sdb_plugin_store_attribute("h1", "k1", &datum, 1);
        datum.data.string = "v2";
        datum.data.string = "v2";
-       sdb_store_attribute("h1", "k2", &datum, 2);
+       sdb_plugin_store_attribute("h1", "k2", &datum, 2);
        datum.data.string = "v3";
        datum.data.string = "v3";
-       sdb_store_attribute("h1", "k3", &datum, 2);
+       sdb_plugin_store_attribute("h1", "k3", &datum, 2);
 
        /* make sure that older updates don't overwrite existing values */
        datum.data.string = "fail";
 
        /* make sure that older updates don't overwrite existing values */
        datum.data.string = "fail";
-       sdb_store_attribute("h1", "k2", &datum, 1);
-       sdb_store_attribute("h1", "k3", &datum, 2);
+       sdb_plugin_store_attribute("h1", "k2", &datum, 1);
+       sdb_plugin_store_attribute("h1", "k3", &datum, 2);
 
 
-       sdb_store_metric("h1", "m1", /* store */ NULL, 2);
-       sdb_store_metric("h1", "m2", /* store */ NULL, 1);
-       sdb_store_metric("h2", "m1", /* store */ NULL, 1);
+       sdb_plugin_store_metric("h1", "m1", /* store */ NULL, 2);
+       sdb_plugin_store_metric("h1", "m2", /* store */ NULL, 1);
+       sdb_plugin_store_metric("h2", "m1", /* store */ NULL, 1);
 
 
-       sdb_store_service("h2", "s1", 1);
-       sdb_store_service("h2", "s2", 2);
+       sdb_plugin_store_service("h2", "s1", 1);
+       sdb_plugin_store_service("h2", "s2", 2);
 
        datum.type = SDB_TYPE_INTEGER;
        datum.data.integer = 42;
 
        datum.type = SDB_TYPE_INTEGER;
        datum.data.integer = 42;
-       sdb_store_metric_attr("h1", "m1", "k3", &datum, 2);
+       sdb_plugin_store_metric_attribute("h1", "m1", "k3", &datum, 2);
 
        datum.data.integer = 123;
 
        datum.data.integer = 123;
-       sdb_store_service_attr("h2", "s2", "k1", &datum, 2);
+       sdb_plugin_store_service_attribute("h2", "s2", "k1", &datum, 2);
        datum.data.integer = 4711;
        datum.data.integer = 4711;
-       sdb_store_service_attr("h2", "s2", "k2", &datum, 1);
+       sdb_plugin_store_service_attribute("h2", "s2", "k2", &datum, 1);
 
        /* don't overwrite k1 */
        datum.data.integer = 666;
 
        /* don't overwrite k1 */
        datum.data.integer = 666;
-       sdb_store_service_attr("h2", "s2", "k1", &datum, 2);
+       sdb_plugin_store_service_attribute("h2", "s2", "k1", &datum, 2);
 } /* populate */
 
 START_TEST(test_store_host)
 } /* populate */
 
 START_TEST(test_store_host)
@@ -118,10 +117,10 @@ START_TEST(test_store_host)
        for (i = 0; i < SDB_STATIC_ARRAY_LEN(golden_data); ++i) {
                int status;
 
        for (i = 0; i < SDB_STATIC_ARRAY_LEN(golden_data); ++i) {
                int status;
 
-               status = sdb_store_host(golden_data[i].name,
+               status = sdb_plugin_store_host(golden_data[i].name,
                                golden_data[i].last_update);
                fail_unless(status == golden_data[i].expected,
                                golden_data[i].last_update);
                fail_unless(status == golden_data[i].expected,
-                               "sdb_store_host(%s, %d) = %d; expected: %d",
+                               "sdb_plugin_store_host(%s, %d) = %d; expected: %d",
                                golden_data[i].name, (int)golden_data[i].last_update,
                                status, golden_data[i].expected);
        }
                                golden_data[i].name, (int)golden_data[i].last_update,
                                status, golden_data[i].expected);
        }
@@ -144,9 +143,9 @@ START_TEST(test_store_get_host)
        size_t i;
 
        for (i = 0; i < SDB_STATIC_ARRAY_LEN(golden_hosts); ++i) {
        size_t i;
 
        for (i = 0; i < SDB_STATIC_ARRAY_LEN(golden_hosts); ++i) {
-               int status = sdb_store_host(golden_hosts[i], 1);
+               int status = sdb_plugin_store_host(golden_hosts[i], 1);
                fail_unless(status >= 0,
                fail_unless(status >= 0,
-                               "sdb_store_host(%s) = %d; expected: >=0",
+                               "sdb_plugin_store_host(%s) = %d; expected: >=0",
                                golden_hosts[i], status);
        }
 
                                golden_hosts[i], status);
        }
 
@@ -219,8 +218,8 @@ START_TEST(test_store_attr)
 
        size_t i;
 
 
        size_t i;
 
-       sdb_store_host("l", 1);
-       sdb_store_host("m", 1);
+       sdb_plugin_store_host("l", 1);
+       sdb_plugin_store_host("m", 1);
        for (i = 0; i < SDB_STATIC_ARRAY_LEN(golden_data); ++i) {
                sdb_data_t datum;
                int status;
        for (i = 0; i < SDB_STATIC_ARRAY_LEN(golden_data); ++i) {
                sdb_data_t datum;
                int status;
@@ -229,11 +228,11 @@ START_TEST(test_store_attr)
                datum.type = SDB_TYPE_STRING;
                datum.data.string = golden_data[i].value;
 
                datum.type = SDB_TYPE_STRING;
                datum.data.string = golden_data[i].value;
 
-               status = sdb_store_attribute(golden_data[i].host,
+               status = sdb_plugin_store_attribute(golden_data[i].host,
                                golden_data[i].key, &datum,
                                golden_data[i].last_update);
                fail_unless(status == golden_data[i].expected,
                                golden_data[i].key, &datum,
                                golden_data[i].last_update);
                fail_unless(status == golden_data[i].expected,
-                               "sdb_store_attribute(%s, %s, %s, %d) = %d; expected: %d",
+                               "sdb_plugin_store_attribute(%s, %s, %s, %d) = %d; expected: %d",
                                golden_data[i].host, golden_data[i].key, golden_data[i].value,
                                golden_data[i].last_update, status, golden_data[i].expected);
        }
                                golden_data[i].host, golden_data[i].key, golden_data[i].value,
                                golden_data[i].last_update, status, golden_data[i].expected);
        }
@@ -272,16 +271,16 @@ START_TEST(test_store_metric)
 
        size_t i;
 
 
        size_t i;
 
-       sdb_store_host("m", 1);
-       sdb_store_host("l", 1);
+       sdb_plugin_store_host("m", 1);
+       sdb_plugin_store_host("l", 1);
        for (i = 0; i < SDB_STATIC_ARRAY_LEN(golden_data); ++i) {
                int status;
 
        for (i = 0; i < SDB_STATIC_ARRAY_LEN(golden_data); ++i) {
                int status;
 
-               status = sdb_store_metric(golden_data[i].host,
+               status = sdb_plugin_store_metric(golden_data[i].host,
                                golden_data[i].metric, golden_data[i].store,
                                golden_data[i].last_update);
                fail_unless(status == golden_data[i].expected,
                                golden_data[i].metric, golden_data[i].store,
                                golden_data[i].last_update);
                fail_unless(status == golden_data[i].expected,
-                               "sdb_store_metric(%s, %s, %p, %d) = %d; expected: %d",
+                               "sdb_plugin_store_metric(%s, %s, %p, %d) = %d; expected: %d",
                                golden_data[i].host, golden_data[i].metric,
                                golden_data[i].store, golden_data[i].last_update,
                                status, golden_data[i].expected);
                                golden_data[i].host, golden_data[i].metric,
                                golden_data[i].store, golden_data[i].last_update,
                                status, golden_data[i].expected);
@@ -316,20 +315,20 @@ START_TEST(test_store_metric_attr)
 
        size_t i;
 
 
        size_t i;
 
-       sdb_store_host("m", 1);
-       sdb_store_host("l", 1);
-       sdb_store_metric("m", "m1", NULL, 1);
-       sdb_store_metric("l", "m1", NULL, 1);
-       sdb_store_metric("l", "m2", NULL, 1);
+       sdb_plugin_store_host("m", 1);
+       sdb_plugin_store_host("l", 1);
+       sdb_plugin_store_metric("m", "m1", NULL, 1);
+       sdb_plugin_store_metric("l", "m1", NULL, 1);
+       sdb_plugin_store_metric("l", "m2", NULL, 1);
 
        for (i = 0; i < SDB_STATIC_ARRAY_LEN(golden_data); ++i) {
                int status;
 
 
        for (i = 0; i < SDB_STATIC_ARRAY_LEN(golden_data); ++i) {
                int status;
 
-               status = sdb_store_metric_attr(golden_data[i].host,
+               status = sdb_plugin_store_metric_attribute(golden_data[i].host,
                                golden_data[i].metric, golden_data[i].attr,
                                &golden_data[i].value, golden_data[i].last_update);
                fail_unless(status == golden_data[i].expected,
                                golden_data[i].metric, golden_data[i].attr,
                                &golden_data[i].value, golden_data[i].last_update);
                fail_unless(status == golden_data[i].expected,
-                               "sdb_store_metric_attr(%s, %s, %s, %d, %d) = %d; "
+                               "sdb_plugin_store_metric_attribute(%s, %s, %s, %d, %d) = %d; "
                                "expected: %d", golden_data[i].host, golden_data[i].metric,
                                golden_data[i].attr, golden_data[i].value.data.integer,
                                golden_data[i].last_update, status, golden_data[i].expected);
                                "expected: %d", golden_data[i].host, golden_data[i].metric,
                                golden_data[i].attr, golden_data[i].value.data.integer,
                                golden_data[i].last_update, status, golden_data[i].expected);
@@ -357,15 +356,15 @@ START_TEST(test_store_service)
 
        size_t i;
 
 
        size_t i;
 
-       sdb_store_host("m", 1);
-       sdb_store_host("l", 1);
+       sdb_plugin_store_host("m", 1);
+       sdb_plugin_store_host("l", 1);
        for (i = 0; i < SDB_STATIC_ARRAY_LEN(golden_data); ++i) {
                int status;
 
        for (i = 0; i < SDB_STATIC_ARRAY_LEN(golden_data); ++i) {
                int status;
 
-               status = sdb_store_service(golden_data[i].host,
+               status = sdb_plugin_store_service(golden_data[i].host,
                                golden_data[i].svc, golden_data[i].last_update);
                fail_unless(status == golden_data[i].expected,
                                golden_data[i].svc, golden_data[i].last_update);
                fail_unless(status == golden_data[i].expected,
-                               "sdb_store_service(%s, %s, %d) = %d; expected: %d",
+                               "sdb_plugin_store_service(%s, %s, %d) = %d; expected: %d",
                                golden_data[i].host, golden_data[i].svc,
                                golden_data[i].last_update, status, golden_data[i].expected);
        }
                                golden_data[i].host, golden_data[i].svc,
                                golden_data[i].last_update, status, golden_data[i].expected);
        }
@@ -399,20 +398,20 @@ START_TEST(test_store_service_attr)
 
        size_t i;
 
 
        size_t i;
 
-       sdb_store_host("m", 1);
-       sdb_store_host("l", 1);
-       sdb_store_service("m", "s1", 1);
-       sdb_store_service("l", "s1", 1);
-       sdb_store_service("l", "s2", 1);
+       sdb_plugin_store_host("m", 1);
+       sdb_plugin_store_host("l", 1);
+       sdb_plugin_store_service("m", "s1", 1);
+       sdb_plugin_store_service("l", "s1", 1);
+       sdb_plugin_store_service("l", "s2", 1);
 
        for (i = 0; i < SDB_STATIC_ARRAY_LEN(golden_data); ++i) {
                int status;
 
 
        for (i = 0; i < SDB_STATIC_ARRAY_LEN(golden_data); ++i) {
                int status;
 
-               status = sdb_store_service_attr(golden_data[i].host,
+               status = sdb_plugin_store_service_attribute(golden_data[i].host,
                                golden_data[i].svc, golden_data[i].attr,
                                &golden_data[i].value, golden_data[i].last_update);
                fail_unless(status == golden_data[i].expected,
                                golden_data[i].svc, golden_data[i].attr,
                                &golden_data[i].value, golden_data[i].last_update);
                fail_unless(status == golden_data[i].expected,
-                               "sdb_store_service_attr(%s, %s, %s, %d, %d) = %d; "
+                               "sdb_plugin_store_service_attribute(%s, %s, %s, %d, %d) = %d; "
                                "expected: %d", golden_data[i].host, golden_data[i].svc,
                                golden_data[i].attr, golden_data[i].value.data.integer,
                                golden_data[i].last_update, status, golden_data[i].expected);
                                "expected: %d", golden_data[i].host, golden_data[i].svc,
                                golden_data[i].attr, golden_data[i].value.data.integer,
                                golden_data[i].last_update, status, golden_data[i].expected);
@@ -474,10 +473,10 @@ START_TEST(test_get_field)
        sdb_time_t now = sdb_gettime();
        int check;
 
        sdb_time_t now = sdb_gettime();
        int check;
 
-       sdb_store_host("host", 10);
-       sdb_store_host("host", 20);
-       sdb_store_attribute("host", "attr", &get_field_data[_i].value, 10);
-       sdb_store_attribute("host", "attr", &get_field_data[_i].value, 20);
+       sdb_plugin_store_host("host", 10);
+       sdb_plugin_store_host("host", 20);
+       sdb_plugin_store_attribute("host", "attr", &get_field_data[_i].value, 10);
+       sdb_plugin_store_attribute("host", "attr", &get_field_data[_i].value, 20);
 
        if (get_field_data[_i].hostname) {
                obj = sdb_store_get_host(get_field_data[_i].hostname);
 
        if (get_field_data[_i].hostname) {
                obj = sdb_store_get_host(get_field_data[_i].hostname);
@@ -631,51 +630,51 @@ START_TEST(test_interval)
        sdb_store_obj_t *host;
 
        /* 10 us interval */
        sdb_store_obj_t *host;
 
        /* 10 us interval */
-       sdb_store_host("host", 10);
-       sdb_store_host("host", 20);
-       sdb_store_host("host", 30);
-       sdb_store_host("host", 40);
+       sdb_plugin_store_host("host", 10);
+       sdb_plugin_store_host("host", 20);
+       sdb_plugin_store_host("host", 30);
+       sdb_plugin_store_host("host", 40);
 
        host = sdb_store_get_host("host");
        fail_unless(host != NULL,
                        "INTERNAL ERROR: store doesn't have host after adding it");
 
        fail_unless(host->interval == 10,
 
        host = sdb_store_get_host("host");
        fail_unless(host != NULL,
                        "INTERNAL ERROR: store doesn't have host after adding it");
 
        fail_unless(host->interval == 10,
-                       "sdb_store_host() did not calculate interval correctly: "
+                       "sdb_plugin_store_host() did not calculate interval correctly: "
                        "got: %"PRIsdbTIME"; expected: %"PRIsdbTIME, host->interval, 10);
 
        /* multiple updates for the same timestamp don't modify the interval */
                        "got: %"PRIsdbTIME"; expected: %"PRIsdbTIME, host->interval, 10);
 
        /* multiple updates for the same timestamp don't modify the interval */
-       sdb_store_host("host", 40);
-       sdb_store_host("host", 40);
-       sdb_store_host("host", 40);
-       sdb_store_host("host", 40);
+       sdb_plugin_store_host("host", 40);
+       sdb_plugin_store_host("host", 40);
+       sdb_plugin_store_host("host", 40);
+       sdb_plugin_store_host("host", 40);
 
        fail_unless(host->interval == 10,
 
        fail_unless(host->interval == 10,
-                       "sdb_store_host() changed interval when doing multiple updates "
+                       "sdb_plugin_store_host() changed interval when doing multiple updates "
                        "using the same timestamp; got: %"PRIsdbTIME"; "
                        "expected: %"PRIsdbTIME, host->interval, 10);
 
        /* multiple updates using an timestamp don't modify the interval */
                        "using the same timestamp; got: %"PRIsdbTIME"; "
                        "expected: %"PRIsdbTIME, host->interval, 10);
 
        /* multiple updates using an timestamp don't modify the interval */
-       sdb_store_host("host", 20);
-       sdb_store_host("host", 20);
-       sdb_store_host("host", 20);
-       sdb_store_host("host", 20);
+       sdb_plugin_store_host("host", 20);
+       sdb_plugin_store_host("host", 20);
+       sdb_plugin_store_host("host", 20);
+       sdb_plugin_store_host("host", 20);
 
        fail_unless(host->interval == 10,
 
        fail_unless(host->interval == 10,
-                       "sdb_store_host() changed interval when doing multiple updates "
+                       "sdb_plugin_store_host() changed interval when doing multiple updates "
                        "using an old timestamp; got: %"PRIsdbTIME"; expected: %"PRIsdbTIME,
                        host->interval, 10);
 
        /* new interval: 20 us */
                        "using an old timestamp; got: %"PRIsdbTIME"; expected: %"PRIsdbTIME,
                        host->interval, 10);
 
        /* new interval: 20 us */
-       sdb_store_host("host", 60);
+       sdb_plugin_store_host("host", 60);
        fail_unless(host->interval == 11,
        fail_unless(host->interval == 11,
-                       "sdb_store_host() did not calculate interval correctly: "
+                       "sdb_plugin_store_host() did not calculate interval correctly: "
                        "got: %"PRIsdbTIME"; expected: %"PRIsdbTIME, host->interval, 11);
 
        /* new interval: 40 us */
                        "got: %"PRIsdbTIME"; expected: %"PRIsdbTIME, host->interval, 11);
 
        /* new interval: 40 us */
-       sdb_store_host("host", 100);
+       sdb_plugin_store_host("host", 100);
        fail_unless(host->interval == 13,
        fail_unless(host->interval == 13,
-                       "sdb_store_host() did not calculate interval correctly: "
+                       "sdb_plugin_store_host() did not calculate interval correctly: "
                        "got: %"PRIsdbTIME"; expected: %"PRIsdbTIME, host->interval, 11);
 
        sdb_object_deref(SDB_OBJ(host));
                        "got: %"PRIsdbTIME"; expected: %"PRIsdbTIME, host->interval, 11);
 
        sdb_object_deref(SDB_OBJ(host));
index d7e5b30cbd7f7c2a4122c4851233eca306fbda23..7fb73a453f33dc7bf84a8989557f8c9470f93b10 100644 (file)
@@ -29,6 +29,7 @@
 #      include "config.h"
 #endif
 
 #      include "config.h"
 #endif
 
+#include "core/plugin.h"
 #include "frontend/connection.h"
 #include "frontend/connection-private.h"
 #include "testutils.h"
 #include "frontend/connection.h"
 #include "frontend/connection-private.h"
 #include "testutils.h"
@@ -46,32 +47,35 @@ populate(void)
 
        sdb_store_init();
 
 
        sdb_store_init();
 
-       sdb_store_host("h1", 1 * SDB_INTERVAL_SECOND);
-       sdb_store_host("h2", 3 * SDB_INTERVAL_SECOND);
+       sdb_plugin_store_host("h1", 1 * SDB_INTERVAL_SECOND);
+       sdb_plugin_store_host("h2", 3 * SDB_INTERVAL_SECOND);
 
        datum.type = SDB_TYPE_STRING;
        datum.data.string = "v1";
 
        datum.type = SDB_TYPE_STRING;
        datum.data.string = "v1";
-       sdb_store_attribute("h1", "k1", &datum, 1 * SDB_INTERVAL_SECOND);
+       sdb_plugin_store_attribute("h1", "k1", &datum, 1 * SDB_INTERVAL_SECOND);
        datum.data.string = "v2";
        datum.data.string = "v2";
-       sdb_store_attribute("h1", "k2", &datum, 2 * SDB_INTERVAL_SECOND);
+       sdb_plugin_store_attribute("h1", "k2", &datum, 2 * SDB_INTERVAL_SECOND);
        datum.data.string = "v3";
        datum.data.string = "v3";
-       sdb_store_attribute("h1", "k3", &datum, 2 * SDB_INTERVAL_SECOND);
+       sdb_plugin_store_attribute("h1", "k3", &datum, 2 * SDB_INTERVAL_SECOND);
 
 
-       sdb_store_metric("h1", "m1", /* store */ NULL, 2 * SDB_INTERVAL_SECOND);
-       sdb_store_metric("h1", "m2", /* store */ NULL, 1 * SDB_INTERVAL_SECOND);
-       sdb_store_metric("h2", "m1", /* store */ NULL, 1 * SDB_INTERVAL_SECOND);
+       sdb_plugin_store_metric("h1", "m1", /* store */ NULL, 2 * SDB_INTERVAL_SECOND);
+       sdb_plugin_store_metric("h1", "m2", /* store */ NULL, 1 * SDB_INTERVAL_SECOND);
+       sdb_plugin_store_metric("h2", "m1", /* store */ NULL, 1 * SDB_INTERVAL_SECOND);
 
        datum.type = SDB_TYPE_INTEGER;
        datum.data.integer = 42;
 
        datum.type = SDB_TYPE_INTEGER;
        datum.data.integer = 42;
-       sdb_store_metric_attr("h1", "m1", "k3", &datum, 2 * SDB_INTERVAL_SECOND);
+       sdb_plugin_store_metric_attribute("h1", "m1", "k3",
+                       &datum, 2 * SDB_INTERVAL_SECOND);
 
 
-       sdb_store_service("h2", "s1", 1 * SDB_INTERVAL_SECOND);
-       sdb_store_service("h2", "s2", 2 * SDB_INTERVAL_SECOND);
+       sdb_plugin_store_service("h2", "s1", 1 * SDB_INTERVAL_SECOND);
+       sdb_plugin_store_service("h2", "s2", 2 * SDB_INTERVAL_SECOND);
 
        datum.data.integer = 123;
 
        datum.data.integer = 123;
-       sdb_store_service_attr("h2", "s2", "k1", &datum, 2 * SDB_INTERVAL_SECOND);
+       sdb_plugin_store_service_attribute("h2", "s2", "k1",
+                       &datum, 2 * SDB_INTERVAL_SECOND);
        datum.data.integer = 4711;
        datum.data.integer = 4711;
-       sdb_store_service_attr("h2", "s2", "k2", &datum, 1 * SDB_INTERVAL_SECOND);
+       sdb_plugin_store_service_attribute("h2", "s2", "k2",
+                       &datum, 1 * SDB_INTERVAL_SECOND);
 } /* populate */
 
 #define HOST_H1 \
 } /* populate */
 
 #define HOST_H1 \