X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Finclude%2Fcore%2Fstore.h;h=30ad0ab386b81517128c47fbe0995d8dcf030c86;hb=f05f6dfc4e48309c916c0dcb158df66c80de6c71;hp=2253d55a417ed65f75a422c244810bbdd02e6f8f;hpb=574ff0923e158af29fce5c7b71a14f4bf04d740d;p=sysdb.git diff --git a/src/include/core/store.h b/src/include/core/store.h index 2253d55..30ad0ab 100644 --- a/src/include/core/store.h +++ b/src/include/core/store.h @@ -65,7 +65,11 @@ enum { (((t) == SDB_HOST) ? "host" \ : ((t) == SDB_SERVICE) ? "service" \ : ((t) == SDB_METRIC) ? "metric" \ - : ((t) == SDB_ATTRIBUTE) ? "attribute" : "unknown") + : ((t) == SDB_ATTRIBUTE) ? "attribute" \ + : ((t) == (SDB_ATTRIBUTE | SDB_HOST)) ? "host attribute" \ + : ((t) == (SDB_ATTRIBUTE | SDB_SERVICE)) ? "service attribute" \ + : ((t) == (SDB_ATTRIBUTE | SDB_METRIC)) ? "metric attribute" \ + : "unknown") #define SDB_FIELD_TO_NAME(f) \ (((f) == SDB_FIELD_NAME) ? "name" \ @@ -90,6 +94,14 @@ enum { struct sdb_store_obj; typedef struct sdb_store_obj sdb_store_obj_t; +/* + * A metric store describes how to access a metric's data. + */ +typedef struct { + const char *type; + const char *id; +} sdb_metric_store_t; + /* * Expressions represent arithmetic expressions based on stored objects and * their various attributes. @@ -121,6 +133,28 @@ typedef struct sdb_store_matcher sdb_store_matcher_t; struct sdb_store_json_formatter; typedef struct sdb_store_json_formatter sdb_store_json_formatter_t; +/* + * A store writer describes the interface for plugins implementing a store. + */ +typedef struct { + int (*store_host)(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); + 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_attribute)(const char *hostname, + 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); + 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); +} sdb_store_writer_t; + /* * sdb_store_clear: * Clear the entire store and remove all stored objects. @@ -216,14 +250,6 @@ int sdb_store_service_attr(const char *hostname, const char *service, const char *key, const sdb_data_t *value, sdb_time_t last_update); -/* - * A metric store describes how to access a metric's data. - */ -typedef struct { - const char *type; - const char *id; -} sdb_metric_store_t; - /* * sdb_store_metric: * Add/update a metric in the store. If the metric, identified by its name,