X-Git-Url: https://git.tokkee.org/?p=sysdb.git;a=blobdiff_plain;f=src%2Fcore%2Fplugin.c;h=3611be4966b51d296557620e9ed77abda9d7ce48;hp=2cb852e45112156229a0a22899c20580f254d7ff;hb=9a96acd759c31211aa512e174339a9c178c4eb83;hpb=07d956b72b9b0498b5ef720ea647f2df517b7a90 diff --git a/src/core/plugin.c b/src/core/plugin.c index 2cb852e..3611be4 100644 --- a/src/core/plugin.c +++ b/src/core/plugin.c @@ -661,6 +661,21 @@ plugin_add_callback(sdb_llist_t **list, const char *type, return 0; } /* plugin_add_callback */ +static void +get_backend(char **backends, size_t *backends_num) +{ + const sdb_plugin_info_t *info; + + info = sdb_plugin_current(); + if ((! info) || (! info->plugin_name) || (! *info->plugin_name)) { + *backends_num = 0; + return; + } + + backends[0] = info->plugin_name; + *backends_num = 1; +} /* get_backend */ + /* * public API */ @@ -1422,7 +1437,8 @@ sdb_plugin_fetch_timeseries(const char *type, const char *id, } /* sdb_plugin_fetch_timeseries */ int -sdb_plugin_query(sdb_ast_node_t *ast, sdb_strbuf_t *buf, sdb_strbuf_t *errbuf) +sdb_plugin_query(sdb_ast_node_t *ast, + sdb_store_writer_t *w, sdb_object_t *wd, sdb_strbuf_t *errbuf) { size_t n = sdb_llist_len(reader_list); reader_t *reader; @@ -1434,8 +1450,7 @@ sdb_plugin_query(sdb_ast_node_t *ast, sdb_strbuf_t *buf, sdb_strbuf_t *errbuf) if ((ast->type != SDB_AST_TYPE_FETCH) && (ast->type != SDB_AST_TYPE_LIST) - && (ast->type != SDB_AST_TYPE_LOOKUP) - && (ast->type != SDB_AST_TYPE_TIMESERIES)) { + && (ast->type != SDB_AST_TYPE_LOOKUP)) { sdb_log(SDB_LOG_ERR, "core: Cannot execute query of type %s", SDB_AST_TYPE_TO_STRING(ast)); sdb_strbuf_sprintf(errbuf, "Cannot execute query of type %s", @@ -1457,7 +1472,8 @@ sdb_plugin_query(sdb_ast_node_t *ast, sdb_strbuf_t *buf, sdb_strbuf_t *errbuf) q = reader->impl.prepare_query(ast, errbuf, reader->r_user_data); if (q) - status = reader->impl.execute_query(q, buf, errbuf, reader->r_user_data); + status = reader->impl.execute_query(q, w, SDB_OBJ(wd), + errbuf, reader->r_user_data); else status = -1; @@ -1470,6 +1486,7 @@ int sdb_plugin_store_host(const char *name, sdb_time_t last_update) { sdb_store_host_t host = { 0 }; + char *backends[1]; char *cname; sdb_llist_iter_t *iter; @@ -1492,6 +1509,8 @@ sdb_plugin_store_host(const char *name, sdb_time_t last_update) host.name = cname; host.last_update = last_update; + host.backends = (const char * const *)backends; + get_backend(backends, &host.backends_num); iter = sdb_llist_get_iter(writer_list); while (sdb_llist_iter_has_next(iter)) { @@ -1512,6 +1531,7 @@ sdb_plugin_store_service(const char *hostname, const char *name, sdb_time_t last_update) { sdb_store_service_t service = { 0 }; + char *backends[1]; char *cname; sdb_llist_iter_t *iter; @@ -1537,6 +1557,8 @@ sdb_plugin_store_service(const char *hostname, const char *name, service.hostname = cname; service.name = name; service.last_update = last_update; + service.backends = (const char * const *)backends; + get_backend(backends, &service.backends_num); iter = sdb_llist_get_iter(writer_list); while (sdb_llist_iter_has_next(iter)) { @@ -1567,6 +1589,7 @@ sdb_plugin_store_metric(const char *hostname, const char *name, sdb_metric_store_t *store, sdb_time_t last_update) { sdb_store_metric_t metric = { 0 }; + char *backends[1]; char *cname; sdb_llist_iter_t *iter; @@ -1599,6 +1622,8 @@ sdb_plugin_store_metric(const char *hostname, const char *name, metric.store.id = store->id; } metric.last_update = last_update; + metric.backends = (const char * const *)backends; + get_backend(backends, &metric.backends_num); iter = sdb_llist_get_iter(writer_list); while (sdb_llist_iter_has_next(iter)) { @@ -1629,6 +1654,7 @@ sdb_plugin_store_attribute(const char *hostname, const char *key, const sdb_data_t *value, sdb_time_t last_update) { sdb_store_attribute_t attr = { 0 }; + char *backends[1]; char *cname; sdb_llist_iter_t *iter; @@ -1654,6 +1680,8 @@ sdb_plugin_store_attribute(const char *hostname, const char *key, attr.key = key; attr.value = *value; attr.last_update = last_update; + attr.backends = (const char * const *)backends; + get_backend(backends, &attr.backends_num); iter = sdb_llist_get_iter(writer_list); while (sdb_llist_iter_has_next(iter)) { @@ -1674,6 +1702,7 @@ sdb_plugin_store_service_attribute(const char *hostname, const char *service, const char *key, const sdb_data_t *value, sdb_time_t last_update) { sdb_store_attribute_t attr = { 0 }; + char *backends[1]; char *cname; sdb_llist_iter_t *iter; @@ -1700,6 +1729,8 @@ sdb_plugin_store_service_attribute(const char *hostname, const char *service, attr.key = key; attr.value = *value; attr.last_update = last_update; + attr.backends = (const char * const *)backends; + get_backend(backends, &attr.backends_num); iter = sdb_llist_get_iter(writer_list); while (sdb_llist_iter_has_next(iter)) { @@ -1720,6 +1751,7 @@ sdb_plugin_store_metric_attribute(const char *hostname, const char *metric, const char *key, const sdb_data_t *value, sdb_time_t last_update) { sdb_store_attribute_t attr = { 0 }; + char *backends[1]; char *cname; sdb_llist_iter_t *iter; @@ -1746,6 +1778,8 @@ sdb_plugin_store_metric_attribute(const char *hostname, const char *metric, attr.key = key; attr.value = *value; attr.last_update = last_update; + attr.backends = (const char * const *)backends; + get_backend(backends, &attr.backends_num); iter = sdb_llist_get_iter(writer_list); while (sdb_llist_iter_has_next(iter)) {